1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace MaxBeckers\AmazonAlexa\Test\Response\Directives\APL\Component; |
6
|
|
|
|
7
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\ContainerComponent; |
8
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\AlignItems; |
9
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
10
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Direction; |
11
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\JustifyContent; |
12
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Wrap; |
13
|
|
|
use PHPUnit\Framework\TestCase; |
14
|
|
|
|
15
|
|
|
class ContainerComponentTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
public function testConstructorWithAllParameters(): void |
18
|
|
|
{ |
19
|
|
|
$alignItems = AlignItems::CENTER; |
20
|
|
|
$direction = Direction::ROW; |
21
|
|
|
$justifyContent = JustifyContent::SPACE_BETWEEN; |
22
|
|
|
$numbered = true; |
23
|
|
|
$wrap = Wrap::WRAP; |
24
|
|
|
|
25
|
|
|
$component = new ContainerComponent($alignItems, $direction, $justifyContent, $numbered, $wrap); |
26
|
|
|
|
27
|
|
|
$this->assertSame($alignItems, $component->alignItems); |
28
|
|
|
$this->assertSame($direction, $component->direction); |
29
|
|
|
$this->assertSame($justifyContent, $component->justifyContent); |
30
|
|
|
$this->assertTrue($component->numbered); |
31
|
|
|
$this->assertSame($wrap, $component->wrap); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testConstructorWithDefaultParameters(): void |
35
|
|
|
{ |
36
|
|
|
$component = new ContainerComponent(); |
37
|
|
|
|
38
|
|
|
$this->assertNull($component->alignItems); |
39
|
|
|
$this->assertNull($component->direction); |
40
|
|
|
$this->assertNull($component->justifyContent); |
41
|
|
|
$this->assertFalse($component->numbered); |
42
|
|
|
$this->assertNull($component->wrap); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testJsonSerializeWithAllProperties(): void |
46
|
|
|
{ |
47
|
|
|
$alignItems = AlignItems::START; |
48
|
|
|
$direction = Direction::COLUMN; |
49
|
|
|
$justifyContent = JustifyContent::CENTER; |
50
|
|
|
$wrap = Wrap::NO_WRAP; |
51
|
|
|
|
52
|
|
|
$component = new ContainerComponent($alignItems, $direction, $justifyContent, true, $wrap); |
53
|
|
|
$result = $component->jsonSerialize(); |
54
|
|
|
|
55
|
|
|
$this->assertSame(APLComponentType::CONTAINER->value, $result['type']); |
56
|
|
|
$this->assertSame($alignItems->value, $result['alignItems']); |
57
|
|
|
$this->assertSame($direction->value, $result['direction']); |
58
|
|
|
$this->assertSame($justifyContent->value, $result['justifyContent']); |
59
|
|
|
$this->assertTrue($result['numbered']); |
60
|
|
|
$this->assertSame($wrap->value, $result['wrap']); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function testJsonSerializeWithDefaultNumbered(): void |
64
|
|
|
{ |
65
|
|
|
$component = new ContainerComponent(); |
66
|
|
|
$result = $component->jsonSerialize(); |
67
|
|
|
|
68
|
|
|
$this->assertArrayNotHasKey('numbered', $result); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function testJsonSerializeWithNumberedTrue(): void |
72
|
|
|
{ |
73
|
|
|
$component = new ContainerComponent(numbered: true); |
74
|
|
|
$result = $component->jsonSerialize(); |
75
|
|
|
|
76
|
|
|
$this->assertTrue($result['numbered']); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function testJsonSerializeWithNullValues(): void |
80
|
|
|
{ |
81
|
|
|
$component = new ContainerComponent(); |
82
|
|
|
$result = $component->jsonSerialize(); |
83
|
|
|
|
84
|
|
|
$this->assertSame(APLComponentType::CONTAINER->value, $result['type']); |
85
|
|
|
$this->assertArrayNotHasKey('alignItems', $result); |
86
|
|
|
$this->assertArrayNotHasKey('direction', $result); |
87
|
|
|
$this->assertArrayNotHasKey('justifyContent', $result); |
88
|
|
|
$this->assertArrayNotHasKey('wrap', $result); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function testTypeConstant(): void |
92
|
|
|
{ |
93
|
|
|
$this->assertSame(APLComponentType::CONTAINER, ContainerComponent::TYPE); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function testExtendsMultiChildComponent(): void |
97
|
|
|
{ |
98
|
|
|
$component = new ContainerComponent(); |
99
|
|
|
|
100
|
|
|
$this->assertInstanceOf(\MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\MultiChildComponent::class, $component); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function testImplementsJsonSerializable(): void |
104
|
|
|
{ |
105
|
|
|
$component = new ContainerComponent(); |
106
|
|
|
|
107
|
|
|
$this->assertInstanceOf(\JsonSerializable::class, $component); |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|