|
14 | 14 | use Laminas\Router\RouteMatch; |
15 | 15 | use Laminas\Uri\Uri; |
16 | 16 |
|
17 | | -describe('ForceHttps', function () { |
| 17 | +describe('ForceHttps', function (): void { |
18 | 18 |
|
19 | | - beforeAll(function () { |
| 19 | + beforeAll(function (): void { |
20 | 20 | $this->eventManager = Double::instance(['implements' => EventManagerInterface::class]); |
21 | 21 | }); |
22 | 22 |
|
23 | | - describe('->attach()', function () { |
| 23 | + describe('->attach()', function (): void { |
24 | 24 |
|
25 | | - it('not attach on route on console', function () { |
| 25 | + it('not attach on route on console', function (): void { |
26 | 26 |
|
27 | 27 | allow(ForceHttps::class)->toReceive('isInConsole')->andReturn(true); |
28 | 28 | $listener = new ForceHttps([ |
|
38 | 38 |
|
39 | 39 | }); |
40 | 40 |
|
41 | | - it('not attach when not enabled', function () { |
| 41 | + it('not attach when not enabled', function (): void { |
42 | 42 |
|
43 | 43 | allow(ForceHttps::class)->toReceive('isInConsole')->andReturn(false); |
44 | 44 | $listener = new ForceHttps([ |
|
54 | 54 |
|
55 | 55 | }); |
56 | 56 |
|
57 | | - it('attach on route event on non-console and enable', function () { |
| 57 | + it('attach on route event on non-console and enable', function (): void { |
58 | 58 |
|
59 | 59 | allow(ForceHttps::class)->toReceive('isInConsole')->andReturn(false); |
60 | 60 | $listener = new ForceHttps([ |
|
74 | 74 |
|
75 | 75 | }); |
76 | 76 |
|
77 | | - describe('->forceHttpsScheme()', function () { |
| 77 | + describe('->forceHttpsScheme()', function (): void { |
78 | 78 |
|
79 | | - beforeEach(function () { |
| 79 | + beforeEach(function (): void { |
80 | 80 | $this->mvcEvent = Double::instance(['extends' => MvcEvent::class, 'methods' => '__construct']); |
81 | 81 | $this->response = Double::instance(['extends' => Response::class]); |
82 | 82 | $this->request = Double::instance(['extends' => Request::class]); |
|
86 | 86 | Quit::disable(); |
87 | 87 | }); |
88 | 88 |
|
89 | | - context('on current scheme is https', function () { |
| 89 | + context('on current scheme is https', function (): void { |
90 | 90 |
|
91 | | - it('not redirect if uri already has https scheme and without strict_transport_security', function () { |
| 91 | + it('not redirect if uri already has https scheme and without strict_transport_security', function (): void { |
92 | 92 |
|
93 | 93 | $listener = new ForceHttps([ |
94 | 94 | 'enable' => true, |
|
109 | 109 |
|
110 | 110 | }); |
111 | 111 |
|
112 | | - it('not redirect if router not match', function () { |
| 112 | + it('not redirect if router not match', function (): void { |
113 | 113 |
|
114 | 114 | $listener = new ForceHttps([ |
115 | 115 | 'enable' => true, |
|
132 | 132 |
|
133 | 133 | }); |
134 | 134 |
|
135 | | - context('on current scheme is http', function () { |
| 135 | + context('on current scheme is http', function (): void { |
136 | 136 |
|
137 | | - it('not redirect if force_all_routes is false and route name not in force_specific_routes config', function () { |
| 137 | + it('not redirect if force_all_routes is false and route name not in force_specific_routes config', function (): void { |
138 | 138 |
|
139 | 139 | $listener = new ForceHttps([ |
140 | 140 | 'enable' => true, |
|
157 | 157 |
|
158 | 158 | }); |
159 | 159 |
|
160 | | - it('not redirect on router not match', function () { |
| 160 | + it('not redirect on router not match', function (): void { |
161 | 161 |
|
162 | 162 | $listener = new ForceHttps([ |
163 | 163 | 'enable' => true, |
|
174 | 174 |
|
175 | 175 | }); |
176 | 176 |
|
177 | | - it('redirect if force_all_routes is false and route name in force_specific_routes config', function () { |
| 177 | + it('redirect if force_all_routes is false and route name in force_specific_routes config', function (): void { |
178 | 178 |
|
179 | 179 | $listener = new ForceHttps([ |
180 | 180 | 'enable' => true, |
|
196 | 196 | allow($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://example.com/about'); |
197 | 197 | allow($this->response)->toReceive('send'); |
198 | 198 |
|
199 | | - $closure = function () use ($listener) { |
| 199 | + $closure = function () use ($listener): void { |
200 | 200 | $listener->forceHttpsScheme($this->mvcEvent); |
201 | 201 | }; |
202 | 202 | expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
|
205 | 205 |
|
206 | 206 | }); |
207 | 207 |
|
208 | | - it('not redirect if force_all_routes is true and route name in exclude_specific_routes config', function () { |
| 208 | + it('not redirect if force_all_routes is true and route name in exclude_specific_routes config', function (): void { |
209 | 209 |
|
210 | 210 | $listener = new ForceHttps([ |
211 | 211 | 'enable' => true, |
|
230 | 230 | }); |
231 | 231 |
|
232 | 232 |
|
233 | | - it('redirect if force_all_routes is true and route name not in exclude_specific_routes config', function () { |
| 233 | + it('redirect if force_all_routes is true and route name not in exclude_specific_routes config', function (): void { |
234 | 234 |
|
235 | 235 | $listener = new ForceHttps([ |
236 | 236 | 'enable' => true, |
|
253 | 253 | allow($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://example.com/about'); |
254 | 254 | allow($this->response)->toReceive('send'); |
255 | 255 |
|
256 | | - $closure = function () use ($listener) { |
| 256 | + $closure = function () use ($listener): void { |
257 | 257 | $listener->forceHttpsScheme($this->mvcEvent); |
258 | 258 | }; |
259 | 259 | expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
260 | 260 |
|
261 | 261 | expect($this->mvcEvent)->toReceive('getResponse'); |
262 | 262 | }); |
263 | 263 |
|
264 | | - it('redirect if force_all_routes is true', function () { |
| 264 | + it('redirect if force_all_routes is true', function (): void { |
265 | 265 |
|
266 | 266 | $listener = new ForceHttps([ |
267 | 267 | 'enable' => true, |
|
287 | 287 | allow($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://example.com/about'); |
288 | 288 | allow($this->response)->toReceive('send'); |
289 | 289 |
|
290 | | - $closure = function () use ($listener) { |
| 290 | + $closure = function () use ($listener): void { |
291 | 291 | $listener->forceHttpsScheme($this->mvcEvent); |
292 | 292 | }; |
293 | 293 | expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
|
296 | 296 |
|
297 | 297 | }); |
298 | 298 |
|
299 | | - it('redirect if force_all_routes is true and strict_transport_security config exists', function () { |
| 299 | + it('redirect if force_all_routes is true and strict_transport_security config exists', function (): void { |
300 | 300 |
|
301 | 301 | $listener = new ForceHttps([ |
302 | 302 | 'enable' => true, |
|
320 | 320 | allow($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://example.com/about'); |
321 | 321 | allow($this->response)->toReceive('send'); |
322 | 322 |
|
323 | | - $closure = function () use ($listener) { |
| 323 | + $closure = function () use ($listener): void { |
324 | 324 | $listener->forceHttpsScheme($this->mvcEvent); |
325 | 325 | }; |
326 | 326 | expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
|
331 | 331 | }); |
332 | 332 |
|
333 | 333 |
|
334 | | - it('redirect no router not match, but allow_404 is true', function () { |
| 334 | + it('redirect no router not match, but allow_404 is true', function (): void { |
335 | 335 |
|
336 | 336 | $listener = new ForceHttps([ |
337 | 337 | 'enable' => true, |
|
349 | 349 | allow($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://example.com/404'); |
350 | 350 | allow($this->response)->toReceive('send'); |
351 | 351 |
|
352 | | - $closure = function () use ($listener) { |
| 352 | + $closure = function () use ($listener): void { |
353 | 353 | $listener->forceHttpsScheme($this->mvcEvent); |
354 | 354 | }; |
355 | 355 | expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
|
359 | 359 |
|
360 | 360 | }); |
361 | 361 |
|
362 | | - it('redirect with www prefix with configurable "add_www_prefix" on force_all_routes', function () { |
| 362 | + it('redirect with www prefix with configurable "add_www_prefix" on force_all_routes', function (): void { |
363 | 363 |
|
364 | 364 | $listener = new ForceHttps([ |
365 | 365 | 'enable' => true, |
|
384 | 384 | allow($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://example.com/about'); |
385 | 385 | allow($this->response)->toReceive('send'); |
386 | 386 |
|
387 | | - $closure = function () use ($listener) { |
| 387 | + $closure = function () use ($listener): void { |
388 | 388 | $listener->forceHttpsScheme($this->mvcEvent); |
389 | 389 | }; |
390 | 390 | expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
|
394 | 394 |
|
395 | 395 | }); |
396 | 396 |
|
397 | | - it('redirect without www prefix for already has www prefix with configurable "remove_www_prefix" on force_all_routes', function () { |
| 397 | + it('redirect without www prefix for already has www prefix with configurable "remove_www_prefix" on force_all_routes', function (): void { |
398 | 398 |
|
399 | 399 | $listener = new ForceHttps([ |
400 | 400 | 'enable' => true, |
|
424 | 424 | allow($this->response)->toReceive('setStatusCode')->with(308)->andReturn($this->response); |
425 | 425 | allow($this->response)->toReceive('send'); |
426 | 426 |
|
427 | | - $closure = function () use ($listener) { |
| 427 | + $closure = function () use ($listener): void { |
428 | 428 | $listener->forceHttpsScheme($this->mvcEvent); |
429 | 429 | }; |
430 | 430 | expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
|
433 | 433 |
|
434 | 434 | }); |
435 | 435 |
|
436 | | - it('not redirect with set strict_transport_security exists and uri already has https scheme', function () { |
| 436 | + it('not redirect with set strict_transport_security exists and uri already has https scheme', function (): void { |
437 | 437 |
|
438 | 438 | $listener = new ForceHttps([ |
439 | 439 | 'enable' => true, |
|
459 | 459 |
|
460 | 460 | }); |
461 | 461 |
|
462 | | - it('set Strict-Transport-Security if force_specific_routes has its value, match and strict_transport_security config exists', function () { |
| 462 | + it('set Strict-Transport-Security if force_specific_routes has its value, match and strict_transport_security config exists', function (): void { |
463 | 463 |
|
464 | 464 | $listener = new ForceHttps([ |
465 | 465 | 'enable' => true, |
|
492 | 492 |
|
493 | 493 | }); |
494 | 494 |
|
495 | | - it('set Strict-Transport-Security to expire if force_specific_routes has its value, match and strict_transport_security config exists', function () { |
| 495 | + it('set Strict-Transport-Security to expire if force_specific_routes has its value, match and strict_transport_security config exists', function (): void { |
496 | 496 |
|
497 | 497 | $listener = new ForceHttps([ |
498 | 498 | 'enable' => true, |
|
0 commit comments