Passed
Pull Request — master (#97)
by Maximilian
04:17
created

AutoPageCommandTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 40
dl 0
loc 66
rs 10
c 1
b 0
f 1
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructorWithDefaultParameters() 0 8 1
A testJsonSerializeWithNullValues() 0 10 1
A testJsonSerializeWithPartialProperties() 0 10 1
A testJsonSerializeWithAllProperties() 0 15 1
A testConstructorWithAllParameters() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Test\Response\Directives\APL\StandardCommand;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AutoPageCommand;
8
use PHPUnit\Framework\TestCase;
9
10
class AutoPageCommandTest extends TestCase
11
{
12
    public function testConstructorWithAllParameters(): void
13
    {
14
        $componentId = 'myPager';
15
        $count = 3;
16
        $duration = 5000;
17
        $transitionDuration = 500;
18
19
        $command = new AutoPageCommand($componentId, $count, $duration, $transitionDuration);
20
21
        $this->assertSame($componentId, $command->componentId);
22
        $this->assertSame($count, $command->count);
23
        $this->assertSame($duration, $command->duration);
24
        $this->assertSame($transitionDuration, $command->transitionDuration);
25
    }
26
27
    public function testConstructorWithDefaultParameters(): void
28
    {
29
        $command = new AutoPageCommand();
30
31
        $this->assertNull($command->componentId);
32
        $this->assertNull($command->count);
33
        $this->assertNull($command->duration);
34
        $this->assertNull($command->transitionDuration);
35
    }
36
37
    public function testJsonSerializeWithAllProperties(): void
38
    {
39
        $componentId = 'testPager';
40
        $count = 2;
41
        $duration = 3000;
42
        $transitionDuration = 300;
43
44
        $command = new AutoPageCommand($componentId, $count, $duration, $transitionDuration);
45
        $result = $command->jsonSerialize();
46
47
        $this->assertSame(AutoPageCommand::TYPE, $result['type']);
48
        $this->assertSame($componentId, $result['componentId']);
49
        $this->assertSame($count, $result['count']);
50
        $this->assertSame($duration, $result['duration']);
51
        $this->assertSame($transitionDuration, $result['transitionDuration']);
52
    }
53
54
    public function testJsonSerializeWithNullValues(): void
55
    {
56
        $command = new AutoPageCommand();
57
        $result = $command->jsonSerialize();
58
59
        $this->assertSame(AutoPageCommand::TYPE, $result['type']);
60
        $this->assertArrayNotHasKey('componentId', $result);
61
        $this->assertArrayNotHasKey('count', $result);
62
        $this->assertArrayNotHasKey('duration', $result);
63
        $this->assertArrayNotHasKey('transitionDuration', $result);
64
    }
65
66
    public function testJsonSerializeWithPartialProperties(): void
67
    {
68
        $command = new AutoPageCommand('pager1', 1);
69
        $result = $command->jsonSerialize();
70
71
        $this->assertSame(AutoPageCommand::TYPE, $result['type']);
72
        $this->assertSame('pager1', $result['componentId']);
73
        $this->assertSame(1, $result['count']);
74
        $this->assertArrayNotHasKey('duration', $result);
75
        $this->assertArrayNotHasKey('transitionDuration', $result);
76
    }
77
}
78