ExportTest   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 146
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 84
dl 0
loc 146
rs 10
c 1
b 0
f 1
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructorWithDefaultParameters() 0 8 1
A testJsonSerializeWithPartialProperties() 0 15 1
A testJsonSerializeWithAllProperties() 0 17 1
A testConstructorWithAllParameters() 0 20 1
A testJsonSerializeWithOnlyLayouts() 0 11 1
A testJsonSerializeWithEmptyArrays() 0 10 1
A testJsonSerializeWithOnlyGraphics() 0 14 1
A testImplementsJsonSerializable() 0 5 1
A testJsonSerializeWithOnlyStyles() 0 11 1
A testJsonSerializeWithOnlyResources() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Test\Response\Directives\APL\Document;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Export;
8
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\ExportItem;
9
use PHPUnit\Framework\TestCase;
10
11
class ExportTest extends TestCase
12
{
13
    public function testConstructorWithAllParameters(): void
14
    {
15
        $graphics = [$this->createMock(ExportItem::class)];
16
        $layouts = [
17
            $this->createMock(ExportItem::class),
18
            $this->createMock(ExportItem::class),
19
        ];
20
        $resources = [$this->createMock(ExportItem::class)];
21
        $styles = [
22
            $this->createMock(ExportItem::class),
23
            $this->createMock(ExportItem::class),
24
            $this->createMock(ExportItem::class),
25
        ];
26
27
        $export = new Export($graphics, $layouts, $resources, $styles);
28
29
        $this->assertSame($graphics, $export->graphics);
30
        $this->assertSame($layouts, $export->layouts);
31
        $this->assertSame($resources, $export->resources);
32
        $this->assertSame($styles, $export->styles);
33
    }
34
35
    public function testConstructorWithDefaultParameters(): void
36
    {
37
        $export = new Export();
38
39
        $this->assertEmpty($export->graphics);
40
        $this->assertEmpty($export->layouts);
41
        $this->assertEmpty($export->resources);
42
        $this->assertEmpty($export->styles);
43
    }
44
45
    public function testJsonSerializeWithAllProperties(): void
46
    {
47
        $graphics = [$this->createMock(ExportItem::class)];
48
        $layouts = [
49
            $this->createMock(ExportItem::class),
50
            $this->createMock(ExportItem::class),
51
        ];
52
        $resources = [$this->createMock(ExportItem::class)];
53
        $styles = [$this->createMock(ExportItem::class)];
54
55
        $export = new Export($graphics, $layouts, $resources, $styles);
56
        $result = $export->jsonSerialize();
57
58
        $this->assertSame($graphics, $result['graphics']);
59
        $this->assertSame($layouts, $result['layouts']);
60
        $this->assertSame($resources, $result['resources']);
61
        $this->assertSame($styles, $result['styles']);
62
    }
63
64
    public function testJsonSerializeWithEmptyArrays(): void
65
    {
66
        $export = new Export();
67
        $result = $export->jsonSerialize();
68
69
        $this->assertEmpty($result);
70
        $this->assertArrayNotHasKey('graphics', $result);
71
        $this->assertArrayNotHasKey('layouts', $result);
72
        $this->assertArrayNotHasKey('resources', $result);
73
        $this->assertArrayNotHasKey('styles', $result);
74
    }
75
76
    public function testJsonSerializeWithPartialProperties(): void
77
    {
78
        $layouts = [$this->createMock(ExportItem::class)];
79
        $styles = [
80
            $this->createMock(ExportItem::class),
81
            $this->createMock(ExportItem::class),
82
        ];
83
84
        $export = new Export([], $layouts, [], $styles);
85
        $result = $export->jsonSerialize();
86
87
        $this->assertSame($layouts, $result['layouts']);
88
        $this->assertSame($styles, $result['styles']);
89
        $this->assertArrayNotHasKey('graphics', $result);
90
        $this->assertArrayNotHasKey('resources', $result);
91
    }
92
93
    public function testJsonSerializeWithOnlyGraphics(): void
94
    {
95
        $graphics = [
96
            $this->createMock(ExportItem::class),
97
            $this->createMock(ExportItem::class),
98
        ];
99
100
        $export = new Export($graphics);
101
        $result = $export->jsonSerialize();
102
103
        $this->assertSame($graphics, $result['graphics']);
104
        $this->assertArrayNotHasKey('layouts', $result);
105
        $this->assertArrayNotHasKey('resources', $result);
106
        $this->assertArrayNotHasKey('styles', $result);
107
    }
108
109
    public function testJsonSerializeWithOnlyLayouts(): void
110
    {
111
        $layouts = [$this->createMock(ExportItem::class)];
112
113
        $export = new Export([], $layouts);
114
        $result = $export->jsonSerialize();
115
116
        $this->assertSame($layouts, $result['layouts']);
117
        $this->assertArrayNotHasKey('graphics', $result);
118
        $this->assertArrayNotHasKey('resources', $result);
119
        $this->assertArrayNotHasKey('styles', $result);
120
    }
121
122
    public function testJsonSerializeWithOnlyResources(): void
123
    {
124
        $resources = [
125
            $this->createMock(ExportItem::class),
126
            $this->createMock(ExportItem::class),
127
            $this->createMock(ExportItem::class),
128
        ];
129
130
        $export = new Export([], [], $resources);
131
        $result = $export->jsonSerialize();
132
133
        $this->assertSame($resources, $result['resources']);
134
        $this->assertArrayNotHasKey('graphics', $result);
135
        $this->assertArrayNotHasKey('layouts', $result);
136
        $this->assertArrayNotHasKey('styles', $result);
137
    }
138
139
    public function testJsonSerializeWithOnlyStyles(): void
140
    {
141
        $styles = [$this->createMock(ExportItem::class)];
142
143
        $export = new Export([], [], [], $styles);
144
        $result = $export->jsonSerialize();
145
146
        $this->assertSame($styles, $result['styles']);
147
        $this->assertArrayNotHasKey('graphics', $result);
148
        $this->assertArrayNotHasKey('layouts', $result);
149
        $this->assertArrayNotHasKey('resources', $result);
150
    }
151
152
    public function testImplementsJsonSerializable(): void
153
    {
154
        $export = new Export();
155
156
        $this->assertInstanceOf(\JsonSerializable::class, $export);
157
    }
158
}
159