|
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\RemoveItemCommand; |
|
8
|
|
|
use PHPUnit\Framework\TestCase; |
|
9
|
|
|
|
|
10
|
|
|
class RemoveItemCommandTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
public function testConstructorWithComponentId(): void |
|
13
|
|
|
{ |
|
14
|
|
|
$componentId = 'myListComponent'; |
|
15
|
|
|
|
|
16
|
|
|
$command = new RemoveItemCommand($componentId); |
|
17
|
|
|
|
|
18
|
|
|
$this->assertSame($componentId, $command->componentId); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function testConstructorWithDefaultParameters(): void |
|
22
|
|
|
{ |
|
23
|
|
|
$command = new RemoveItemCommand(); |
|
24
|
|
|
|
|
25
|
|
|
$this->assertNull($command->componentId); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function testJsonSerializeWithComponentId(): void |
|
29
|
|
|
{ |
|
30
|
|
|
$componentId = 'testList'; |
|
31
|
|
|
|
|
32
|
|
|
$command = new RemoveItemCommand($componentId); |
|
33
|
|
|
$result = $command->jsonSerialize(); |
|
34
|
|
|
|
|
35
|
|
|
$this->assertSame(RemoveItemCommand::TYPE, $result['type']); |
|
36
|
|
|
$this->assertSame($componentId, $result['componentId']); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function testJsonSerializeWithNullValue(): void |
|
40
|
|
|
{ |
|
41
|
|
|
$command = new RemoveItemCommand(); |
|
42
|
|
|
$result = $command->jsonSerialize(); |
|
43
|
|
|
|
|
44
|
|
|
$this->assertSame(RemoveItemCommand::TYPE, $result['type']); |
|
45
|
|
|
$this->assertArrayNotHasKey('componentId', $result); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function testJsonSerializeWithEmptyString(): void |
|
49
|
|
|
{ |
|
50
|
|
|
$command = new RemoveItemCommand(''); |
|
51
|
|
|
$result = $command->jsonSerialize(); |
|
52
|
|
|
|
|
53
|
|
|
$this->assertSame(RemoveItemCommand::TYPE, $result['type']); |
|
54
|
|
|
$this->assertSame('', $result['componentId']); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function testImplementsJsonSerializable(): void |
|
58
|
|
|
{ |
|
59
|
|
|
$command = new RemoveItemCommand(); |
|
60
|
|
|
|
|
61
|
|
|
$this->assertInstanceOf(\JsonSerializable::class, $command); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function testTypeConstant(): void |
|
65
|
|
|
{ |
|
66
|
|
|
$this->assertSame('RemoveItem', RemoveItemCommand::TYPE); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|