|
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
|
|
|
|