|
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\Document\RepeatMode; |
|
8
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Value; |
|
9
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AnimateItemCommand; |
|
10
|
|
|
use PHPUnit\Framework\TestCase; |
|
11
|
|
|
|
|
12
|
|
|
class AnimateItemCommandTest extends TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
public function testConstructorWithAllParameters(): void |
|
15
|
|
|
{ |
|
16
|
|
|
$componentId = 'myComponent'; |
|
17
|
|
|
$duration = 1000; |
|
18
|
|
|
$easing = 'ease-in-out'; |
|
19
|
|
|
$repeatCount = 3; |
|
20
|
|
|
$repeatMode = RepeatMode::REVERSE; |
|
21
|
|
|
$value = $this->createMock(Value::class); |
|
22
|
|
|
|
|
23
|
|
|
$command = new AnimateItemCommand($componentId, $duration, $easing, $repeatCount, $repeatMode, $value); |
|
24
|
|
|
|
|
25
|
|
|
$this->assertSame($componentId, $command->componentId); |
|
26
|
|
|
$this->assertSame($duration, $command->duration); |
|
27
|
|
|
$this->assertSame($easing, $command->easing); |
|
28
|
|
|
$this->assertSame($repeatCount, $command->repeatCount); |
|
29
|
|
|
$this->assertSame($repeatMode, $command->repeatMode); |
|
30
|
|
|
$this->assertSame($value, $command->value); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function testConstructorWithDefaultParameters(): void |
|
34
|
|
|
{ |
|
35
|
|
|
$command = new AnimateItemCommand(); |
|
36
|
|
|
|
|
37
|
|
|
$this->assertNull($command->componentId); |
|
38
|
|
|
$this->assertNull($command->duration); |
|
39
|
|
|
$this->assertNull($command->easing); |
|
40
|
|
|
$this->assertNull($command->repeatCount); |
|
41
|
|
|
$this->assertNull($command->repeatMode); |
|
42
|
|
|
$this->assertNull($command->value); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testJsonSerializeWithAllProperties(): void |
|
46
|
|
|
{ |
|
47
|
|
|
$componentId = 'testComponent'; |
|
48
|
|
|
$duration = 2000; |
|
49
|
|
|
$easing = 'linear'; |
|
50
|
|
|
$repeatCount = 5; |
|
51
|
|
|
$repeatMode = RepeatMode::RESTART; |
|
52
|
|
|
$value = $this->createMock(Value::class); |
|
53
|
|
|
|
|
54
|
|
|
$command = new AnimateItemCommand($componentId, $duration, $easing, $repeatCount, $repeatMode, $value); |
|
55
|
|
|
$result = $command->jsonSerialize(); |
|
56
|
|
|
|
|
57
|
|
|
$this->assertSame(AnimateItemCommand::TYPE, $result['type']); |
|
58
|
|
|
$this->assertSame($componentId, $result['componentId']); |
|
59
|
|
|
$this->assertSame($duration, $result['duration']); |
|
60
|
|
|
$this->assertSame($easing, $result['easing']); |
|
61
|
|
|
$this->assertSame($repeatCount, $result['repeatCount']); |
|
62
|
|
|
$this->assertSame($repeatMode->value, $result['repeatMode']); |
|
63
|
|
|
$this->assertSame($value, $result['value']); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function testJsonSerializeWithNullValues(): void |
|
67
|
|
|
{ |
|
68
|
|
|
$command = new AnimateItemCommand(); |
|
69
|
|
|
$result = $command->jsonSerialize(); |
|
70
|
|
|
|
|
71
|
|
|
$this->assertSame(AnimateItemCommand::TYPE, $result['type']); |
|
72
|
|
|
$this->assertArrayNotHasKey('componentId', $result); |
|
73
|
|
|
$this->assertArrayNotHasKey('duration', $result); |
|
74
|
|
|
$this->assertArrayNotHasKey('easing', $result); |
|
75
|
|
|
$this->assertArrayNotHasKey('repeatCount', $result); |
|
76
|
|
|
$this->assertArrayNotHasKey('repeatMode', $result); |
|
77
|
|
|
$this->assertArrayNotHasKey('value', $result); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function testJsonSerializeWithPartialProperties(): void |
|
81
|
|
|
{ |
|
82
|
|
|
$command = new AnimateItemCommand('component1', 500); |
|
83
|
|
|
$result = $command->jsonSerialize(); |
|
84
|
|
|
|
|
85
|
|
|
$this->assertSame(AnimateItemCommand::TYPE, $result['type']); |
|
86
|
|
|
$this->assertSame('component1', $result['componentId']); |
|
87
|
|
|
$this->assertSame(500, $result['duration']); |
|
88
|
|
|
$this->assertArrayNotHasKey('easing', $result); |
|
89
|
|
|
$this->assertArrayNotHasKey('repeatCount', $result); |
|
90
|
|
|
$this->assertArrayNotHasKey('repeatMode', $result); |
|
91
|
|
|
$this->assertArrayNotHasKey('value', $result); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|