These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Tests; |
||
3 | |||
4 | use Redaxscript\Header; |
||
5 | |||
6 | /** |
||
7 | * HeaderTest |
||
8 | * |
||
9 | * @since 3.3.0 |
||
10 | * |
||
11 | * @package Redaxscript |
||
12 | * @category Tests |
||
13 | * @author Henry Ruhs |
||
14 | * |
||
15 | * @covers Redaxscript\Header |
||
16 | */ |
||
17 | |||
18 | class HeaderTest extends TestCaseAbstract |
||
19 | { |
||
20 | /** |
||
21 | * testInit |
||
22 | * |
||
23 | * @since 3.3.0 |
||
24 | * |
||
25 | * @runInSeparateProcess |
||
26 | */ |
||
27 | |||
28 | public function testInit() : void |
||
29 | { |
||
30 | /* setup */ |
||
31 | |||
32 | Header::init(); |
||
33 | |||
34 | /* expect and actual */ |
||
35 | |||
36 | $expectArray = |
||
37 | [ |
||
38 | 'X-Content-Type-Options: nosniff', |
||
39 | 'X-Frame-Options: sameorigin', |
||
40 | 'X-XSS-Protection: 1; mode=block' |
||
41 | ]; |
||
42 | $actualArray = $this->getHeaderArray(); |
||
0 ignored issues
–
show
|
|||
43 | |||
44 | /* compare */ |
||
45 | |||
46 | $this->assertEquals($expectArray, $actualArray); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * testAdd |
||
51 | * |
||
52 | * @since 3.3.0 |
||
53 | * |
||
54 | * @runInSeparateProcess |
||
55 | */ |
||
56 | |||
57 | public function testAdd() : void |
||
58 | { |
||
59 | /* setup */ |
||
60 | |||
61 | Header::add('X-One: One'); |
||
62 | Header::add( |
||
63 | [ |
||
64 | 'X-Two: Two', |
||
65 | 'X-Three: Three' |
||
66 | ]); |
||
67 | |||
68 | /* expect and actual */ |
||
69 | |||
70 | $expectArray = |
||
71 | [ |
||
72 | 'X-One: One', |
||
73 | 'X-Two: Two', |
||
74 | 'X-Three: Three' |
||
75 | ]; |
||
76 | $actualArray = $this->getHeaderArray(); |
||
0 ignored issues
–
show
The method
getHeaderArray() does not seem to exist on object<Redaxscript\Tests\HeaderTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
77 | |||
78 | /* compare */ |
||
79 | |||
80 | $this->assertEquals($expectArray, $actualArray); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * testAddInvalid |
||
85 | * |
||
86 | * @since 3.3.0 |
||
87 | */ |
||
88 | |||
89 | public function testAddInvalid() : void |
||
90 | { |
||
91 | /* actual */ |
||
92 | |||
93 | $actual = Header::add(); |
||
94 | |||
95 | /* compare */ |
||
96 | |||
97 | $this->assertFalse($actual); |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * testRemoveInvalid |
||
102 | * |
||
103 | * @since 3.3.0 |
||
104 | * |
||
105 | */ |
||
106 | |||
107 | public function testRemoveInvalid() : void |
||
108 | { |
||
109 | /* actual */ |
||
110 | |||
111 | $actual = Header::remove(); |
||
112 | |||
113 | /* compare */ |
||
114 | |||
115 | $this->assertFalse($actual); |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * testResponseCode |
||
120 | * |
||
121 | * @since 4.0.0 |
||
122 | * |
||
123 | * @runInSeparateProcess |
||
124 | */ |
||
125 | |||
126 | public function testResponseCode() : void |
||
127 | { |
||
128 | /* actual */ |
||
129 | |||
130 | $actual = Header::responseCode(404); |
||
131 | |||
132 | /* compare */ |
||
133 | |||
134 | $this->assertIsInt($actual); |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * testDoRedirect |
||
139 | * |
||
140 | * @since 3.3.0 |
||
141 | * |
||
142 | * @runInSeparateProcess |
||
143 | */ |
||
144 | |||
145 | public function testDoRedirect() : void |
||
146 | { |
||
147 | /* setup */ |
||
148 | |||
149 | Header::doRedirect('install.php'); |
||
150 | |||
151 | /* expect and actual */ |
||
152 | |||
153 | $expectArray = |
||
154 | [ |
||
155 | 'Location: install.php' |
||
156 | ]; |
||
157 | $actualArray = $this->getHeaderArray(); |
||
0 ignored issues
–
show
The method
getHeaderArray() does not seem to exist on object<Redaxscript\Tests\HeaderTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
158 | |||
159 | /* compare */ |
||
160 | |||
161 | $this->assertEquals($expectArray, $actualArray); |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * testContentType |
||
166 | * |
||
167 | * @since 3.3.0 |
||
168 | * |
||
169 | * @runInSeparateProcess |
||
170 | */ |
||
171 | |||
172 | public function testContentType() : void |
||
173 | { |
||
174 | /* setup */ |
||
175 | |||
176 | Header::contentType('application/json'); |
||
177 | |||
178 | /* expect and actual */ |
||
179 | |||
180 | $expectArray = |
||
181 | [ |
||
182 | 'Content-Type: application/json' |
||
183 | ]; |
||
184 | $actualArray = $this->getHeaderArray(); |
||
0 ignored issues
–
show
The method
getHeaderArray() does not seem to exist on object<Redaxscript\Tests\HeaderTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
185 | |||
186 | /* compare */ |
||
187 | |||
188 | $this->assertEquals($expectArray, $actualArray); |
||
189 | } |
||
190 | } |
||
191 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.