1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace MaxBeckers\AmazonAlexa\Test\Response\Directives\APL\Gesture; |
6
|
|
|
|
7
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\GestureType; |
8
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Gesture\LongPress; |
9
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
10
|
|
|
use PHPUnit\Framework\TestCase; |
11
|
|
|
|
12
|
|
|
class LongPressTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
public function testConstructorWithAllParameters(): void |
15
|
|
|
{ |
16
|
|
|
$onLongPressStart = [$this->createMock(AbstractStandardCommand::class)]; |
17
|
|
|
$onLongPressEnd = [$this->createMock(AbstractStandardCommand::class)]; |
18
|
|
|
$onCancel = [$this->createMock(AbstractStandardCommand::class)]; |
19
|
|
|
$when = false; |
20
|
|
|
|
21
|
|
|
$gesture = new LongPress($onLongPressStart, $onLongPressEnd, $onCancel, $when); |
22
|
|
|
|
23
|
|
|
$this->assertSame($onLongPressStart, $gesture->onLongPressStart); |
24
|
|
|
$this->assertSame($onLongPressEnd, $gesture->onLongPressEnd); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function testConstructorWithDefaultParameters(): void |
28
|
|
|
{ |
29
|
|
|
$gesture = new LongPress(); |
30
|
|
|
|
31
|
|
|
$this->assertNull($gesture->onLongPressStart); |
32
|
|
|
$this->assertNull($gesture->onLongPressEnd); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testJsonSerializeWithAllCommands(): void |
36
|
|
|
{ |
37
|
|
|
$onLongPressStart = [$this->createMock(AbstractStandardCommand::class)]; |
38
|
|
|
$onLongPressEnd = [$this->createMock(AbstractStandardCommand::class)]; |
39
|
|
|
$onCancel = [$this->createMock(AbstractStandardCommand::class)]; |
40
|
|
|
|
41
|
|
|
$gesture = new LongPress($onLongPressStart, $onLongPressEnd, $onCancel, false); |
42
|
|
|
$result = $gesture->jsonSerialize(); |
43
|
|
|
|
44
|
|
|
$this->assertSame(GestureType::LONG_PRESS->value, $result['type']); |
45
|
|
|
$this->assertSame($onLongPressStart, $result['onLongPressStart']); |
46
|
|
|
$this->assertSame($onLongPressEnd, $result['onLongPressEnd']); |
47
|
|
|
$this->assertSame($onCancel, $result['onCancel']); |
48
|
|
|
$this->assertFalse($result['when']); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function testJsonSerializeWithEmptyArrays(): void |
52
|
|
|
{ |
53
|
|
|
$gesture = new LongPress([], []); |
54
|
|
|
$result = $gesture->jsonSerialize(); |
55
|
|
|
|
56
|
|
|
$this->assertArrayNotHasKey('onLongPressStart', $result); |
57
|
|
|
$this->assertArrayNotHasKey('onLongPressEnd', $result); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function testJsonSerializeWithNullValues(): void |
61
|
|
|
{ |
62
|
|
|
$gesture = new LongPress(); |
63
|
|
|
$result = $gesture->jsonSerialize(); |
64
|
|
|
|
65
|
|
|
$this->assertSame(GestureType::LONG_PRESS->value, $result['type']); |
66
|
|
|
$this->assertArrayNotHasKey('onLongPressStart', $result); |
67
|
|
|
$this->assertArrayNotHasKey('onLongPressEnd', $result); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|