|
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\ControlMediaCommand as ControlMediaCommandType; |
|
8
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\ControlMediaCommand; |
|
9
|
|
|
use PHPUnit\Framework\TestCase; |
|
10
|
|
|
|
|
11
|
|
|
class ControlMediaCommandTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
public function testConstructorWithAllParameters(): void |
|
14
|
|
|
{ |
|
15
|
|
|
$command = ControlMediaCommandType::PLAY; |
|
16
|
|
|
$componentId = 'myVideo'; |
|
17
|
|
|
$value = 1000; |
|
18
|
|
|
|
|
19
|
|
|
$controlMediaCommand = new ControlMediaCommand($command, $componentId, $value); |
|
20
|
|
|
|
|
21
|
|
|
$this->assertSame($command, $controlMediaCommand->command); |
|
22
|
|
|
$this->assertSame($componentId, $controlMediaCommand->componentId); |
|
23
|
|
|
$this->assertSame($value, $controlMediaCommand->value); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testConstructorWithDefaultParameters(): void |
|
27
|
|
|
{ |
|
28
|
|
|
$command = new ControlMediaCommand(); |
|
29
|
|
|
|
|
30
|
|
|
$this->assertNull($command->command); |
|
31
|
|
|
$this->assertNull($command->componentId); |
|
32
|
|
|
$this->assertNull($command->value); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testJsonSerializeWithAllProperties(): void |
|
36
|
|
|
{ |
|
37
|
|
|
$commandType = ControlMediaCommandType::PAUSE; |
|
38
|
|
|
$componentId = 'testVideo'; |
|
39
|
|
|
$value = 2000; |
|
40
|
|
|
|
|
41
|
|
|
$command = new ControlMediaCommand($commandType, $componentId, $value); |
|
42
|
|
|
$result = $command->jsonSerialize(); |
|
43
|
|
|
|
|
44
|
|
|
$this->assertSame(ControlMediaCommand::TYPE, $result['type']); |
|
45
|
|
|
$this->assertSame($commandType->value, $result['command']); |
|
46
|
|
|
$this->assertSame($componentId, $result['componentId']); |
|
47
|
|
|
$this->assertSame($value, $result['value']); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function testJsonSerializeWithNullValues(): void |
|
51
|
|
|
{ |
|
52
|
|
|
$command = new ControlMediaCommand(); |
|
53
|
|
|
$result = $command->jsonSerialize(); |
|
54
|
|
|
|
|
55
|
|
|
$this->assertSame(ControlMediaCommand::TYPE, $result['type']); |
|
56
|
|
|
$this->assertArrayNotHasKey('command', $result); |
|
57
|
|
|
$this->assertArrayNotHasKey('componentId', $result); |
|
58
|
|
|
$this->assertArrayNotHasKey('value', $result); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function testJsonSerializeWithPartialProperties(): void |
|
62
|
|
|
{ |
|
63
|
|
|
$command = new ControlMediaCommand(ControlMediaCommandType::PLAY, 'video1'); |
|
64
|
|
|
$result = $command->jsonSerialize(); |
|
65
|
|
|
|
|
66
|
|
|
$this->assertSame(ControlMediaCommand::TYPE, $result['type']); |
|
67
|
|
|
$this->assertSame(ControlMediaCommandType::PLAY->value, $result['command']); |
|
68
|
|
|
$this->assertSame('video1', $result['componentId']); |
|
69
|
|
|
$this->assertArrayNotHasKey('value', $result); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|