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