@@ -75,7 +75,7 @@ private function createValidActualRequest(): IncomingRequest
75
75
return $ request ;
76
76
}
77
77
78
- private function createCors (array $ options = [])
78
+ private function createCors (array $ options = []): Cors
79
79
{
80
80
$ passedOptions = array_merge (
81
81
[
@@ -107,7 +107,7 @@ private function assertHeader(string $name, string $value): void
107
107
$ this ->assertSame ($ value , $ this ->response ->getHeaderLine ($ name ));
108
108
}
109
109
110
- public function testItDoesModifyOnARequestWithoutOrigin ()
110
+ public function testItDoesModifyOnARequestWithoutOrigin (): void
111
111
{
112
112
$ this ->cors = $ this ->createCors ();
113
113
$ request = $ this ->createRequest ();
@@ -120,7 +120,7 @@ public function testItDoesModifyOnARequestWithoutOrigin()
120
120
);
121
121
}
122
122
123
- public function testItDoesNotModifyOnARequestWithoutOrigin ()
123
+ public function testItDoesNotModifyOnARequestWithoutOrigin (): void
124
124
{
125
125
$ this ->cors = $ this ->createCors ([
126
126
'allowedOrigins ' => ['https://www.example.com ' , 'https://app.example.com ' ],
@@ -151,7 +151,7 @@ private function handle($request): ResponseInterface
151
151
return $ response ;
152
152
}
153
153
154
- public function testItDoesModifyOnARequestWithSameOrigin ()
154
+ public function testItDoesModifyOnARequestWithSameOrigin (): void
155
155
{
156
156
$ this ->cors = $ this ->createCors (['allowedOrigins ' => ['* ' ]]);
157
157
$ request = $ this ->createRequest ();
@@ -163,7 +163,7 @@ public function testItDoesModifyOnARequestWithSameOrigin()
163
163
$ this ->assertHeader ('Access-Control-Allow-Origin ' , '* ' );
164
164
}
165
165
166
- public function testItReturnsAllowOriginHeaderOnValidActualRequest ()
166
+ public function testItReturnsAllowOriginHeaderOnValidActualRequest (): void
167
167
{
168
168
$ this ->cors = $ this ->createCors ();
169
169
$ request = $ this ->createValidActualRequest ();
@@ -174,7 +174,7 @@ public function testItReturnsAllowOriginHeaderOnValidActualRequest()
174
174
$ this ->assertHeader ('Access-Control-Allow-Origin ' , 'http://localhost ' );
175
175
}
176
176
177
- public function testItReturnsAllowOriginHeaderOnAllowAllOriginRequest ()
177
+ public function testItReturnsAllowOriginHeaderOnAllowAllOriginRequest (): void
178
178
{
179
179
$ this ->cors = $ this ->createCors (['allowedOrigins ' => ['* ' ]]);
180
180
$ request = $ this ->createRequest ();
@@ -187,7 +187,7 @@ public function testItReturnsAllowOriginHeaderOnAllowAllOriginRequest()
187
187
$ this ->assertHeader ('Access-Control-Allow-Origin ' , '* ' );
188
188
}
189
189
190
- public function testItReturnsAllowHeadersHeaderOnAllowAllHeadersRequest ()
190
+ public function testItReturnsAllowHeadersHeaderOnAllowAllHeadersRequest (): void
191
191
{
192
192
$ this ->cors = $ this ->createCors (['allowedHeaders ' => ['* ' ]]);
193
193
$ request = $ this ->createValidPreflightRequest ();
@@ -201,7 +201,7 @@ public function testItReturnsAllowHeadersHeaderOnAllowAllHeadersRequest()
201
201
$ this ->assertHeader ('Vary ' , 'Access-Control-Request-Method ' );
202
202
}
203
203
204
- public function testItDoesntPermitWildcardAllowedHeadersAndSupportsCredentials ()
204
+ public function testItDoesntPermitWildcardAllowedHeadersAndSupportsCredentials (): void
205
205
{
206
206
$ this ->expectException (ConfigException::class);
207
207
$ this ->expectExceptionMessage (
@@ -226,7 +226,7 @@ public function testItSetsAllowCredentialsHeaderWhenFlagIsSetOnValidActualReques
226
226
$ this ->assertHeader ('Access-Control-Allow-Credentials ' , 'true ' );
227
227
}
228
228
229
- public function testItDoesNotSetAllowCredentialsHeaderWhenFlagIsNotSetOnValidActualRequest ()
229
+ public function testItDoesNotSetAllowCredentialsHeaderWhenFlagIsNotSetOnValidActualRequest (): void
230
230
{
231
231
$ this ->cors = $ this ->createCors ();
232
232
$ request = $ this ->createValidActualRequest ();
@@ -236,7 +236,7 @@ public function testItDoesNotSetAllowCredentialsHeaderWhenFlagIsNotSetOnValidAct
236
236
$ this ->assertFalse ($ response ->hasHeader ('Access-Control-Allow-Credentials ' ));
237
237
}
238
238
239
- public function testItSetsExposedHeadersWhenConfiguredOnActualRequest ()
239
+ public function testItSetsExposedHeadersWhenConfiguredOnActualRequest (): void
240
240
{
241
241
$ this ->cors = $ this ->createCors (['exposedHeaders ' => ['x-exposed-header ' , 'x-another-exposed-header ' ]]);
242
242
$ request = $ this ->createValidActualRequest ();
@@ -250,7 +250,7 @@ public function testItSetsExposedHeadersWhenConfiguredOnActualRequest()
250
250
);
251
251
}
252
252
253
- public function testItDoesNotPermitWildcardAllowedOriginsAndSupportsCredentials ()
253
+ public function testItDoesNotPermitWildcardAllowedOriginsAndSupportsCredentials (): void
254
254
{
255
255
$ this ->expectException (ConfigException::class);
256
256
$ this ->expectExceptionMessage (
@@ -266,7 +266,7 @@ public function testItDoesNotPermitWildcardAllowedOriginsAndSupportsCredentials(
266
266
$ this ->handle ($ request );
267
267
}
268
268
269
- public function testItDoesNotPermitWildcardAllowedOriginsAllowedMethodAndSupportsCredentials ()
269
+ public function testItDoesNotPermitWildcardAllowedOriginsAllowedMethodAndSupportsCredentials (): void
270
270
{
271
271
$ this ->expectException (ConfigException::class);
272
272
$ this ->expectExceptionMessage (
@@ -283,7 +283,7 @@ public function testItDoesNotPermitWildcardAllowedOriginsAllowedMethodAndSupport
283
283
$ this ->handle ($ request );
284
284
}
285
285
286
- public function testItAddsAVaryHeaderWhenHasOriginPatterns ()
286
+ public function testItAddsAVaryHeaderWhenHasOriginPatterns (): void
287
287
{
288
288
$ this ->cors = $ this ->createCors ([
289
289
'allowedOriginsPatterns ' => ['http://l(o|0)calh(o|0)st ' ],
@@ -296,7 +296,7 @@ public function testItAddsAVaryHeaderWhenHasOriginPatterns()
296
296
$ this ->assertHeader ('Vary ' , 'Origin ' );
297
297
}
298
298
299
- public function testItDoesntPermitWildcardAndOrigin ()
299
+ public function testItDoesntPermitWildcardAndOrigin (): void
300
300
{
301
301
$ this ->expectException (ConfigException::class);
302
302
$ this ->expectExceptionMessage (
@@ -311,7 +311,7 @@ public function testItDoesntPermitWildcardAndOrigin()
311
311
$ this ->handle ($ request );
312
312
}
313
313
314
- public function testItDoesntAddAVaryHeaderWhenSimpleOrigins ()
314
+ public function testItDoesntAddAVaryHeaderWhenSimpleOrigins (): void
315
315
{
316
316
$ this ->cors = $ this ->createCors ([
317
317
'allowedOrigins ' => ['http://localhost ' ],
@@ -324,7 +324,7 @@ public function testItDoesntAddAVaryHeaderWhenSimpleOrigins()
324
324
$ this ->assertFalse ($ response ->hasHeader ('Vary ' ));
325
325
}
326
326
327
- public function testItAddsAVaryHeaderWhenMultipleOrigins ()
327
+ public function testItAddsAVaryHeaderWhenMultipleOrigins (): void
328
328
{
329
329
$ this ->cors = $ this ->createCors ([
330
330
'allowedOrigins ' => ['http://localhost ' , 'http://example.com ' ],
@@ -337,7 +337,7 @@ public function testItAddsAVaryHeaderWhenMultipleOrigins()
337
337
$ this ->assertTrue ($ response ->hasHeader ('Vary ' ));
338
338
}
339
339
340
- public function testItReturnsAccessControlHeadersOnCorsRequest ()
340
+ public function testItReturnsAccessControlHeadersOnCorsRequest (): void
341
341
{
342
342
$ this ->cors = $ this ->createCors ();
343
343
$ request = $ this ->createRequest ();
@@ -349,7 +349,7 @@ public function testItReturnsAccessControlHeadersOnCorsRequest()
349
349
$ this ->assertHeader ('Access-Control-Allow-Origin ' , 'http://localhost ' );
350
350
}
351
351
352
- public function testItReturnsAccessControlHeadersOnCorsRequestWithPatternOrigin ()
352
+ public function testItReturnsAccessControlHeadersOnCorsRequestWithPatternOrigin (): void
353
353
{
354
354
$ this ->cors = $ this ->createCors ([
355
355
'allowedOrigins ' => [],
@@ -365,7 +365,7 @@ public function testItReturnsAccessControlHeadersOnCorsRequestWithPatternOrigin(
365
365
$ this ->assertHeader ('Vary ' , 'Origin ' );
366
366
}
367
367
368
- public function testItReturnsAccessControlHeadersOnValidPreflightRequest ()
368
+ public function testItReturnsAccessControlHeadersOnValidPreflightRequest (): void
369
369
{
370
370
$ this ->cors = $ this ->createCors ();
371
371
$ request = $ this ->createValidPreflightRequest ();
@@ -376,7 +376,7 @@ public function testItReturnsAccessControlHeadersOnValidPreflightRequest()
376
376
$ this ->assertHeader ('Access-Control-Allow-Origin ' , 'http://localhost ' );
377
377
}
378
378
379
- public function testItReturnsOkOnValidPreflightRequestWithRequestedHeadersAllowed ()
379
+ public function testItReturnsOkOnValidPreflightRequestWithRequestedHeadersAllowed (): void
380
380
{
381
381
$ this ->cors = $ this ->createCors ();
382
382
$ requestHeaders = 'X-Allowed-Header, x-other-allowed-header ' ;
@@ -392,7 +392,7 @@ public function testItReturnsOkOnValidPreflightRequestWithRequestedHeadersAllowe
392
392
$ this ->assertHeader ('Access-Control-Allow-Headers ' , 'x-allowed-header, x-other-allowed-header ' );
393
393
}
394
394
395
- public function testItSetsAllowCredentialsHeaderWhenFlagIsSetOnValidPreflightRequest ()
395
+ public function testItSetsAllowCredentialsHeaderWhenFlagIsSetOnValidPreflightRequest (): void
396
396
{
397
397
$ this ->cors = $ this ->createCors (['supportsCredentials ' => true ]);
398
398
$ request = $ this ->createValidPreflightRequest ();
@@ -403,7 +403,7 @@ public function testItSetsAllowCredentialsHeaderWhenFlagIsSetOnValidPreflightReq
403
403
$ this ->assertHeader ('Access-Control-Allow-Credentials ' , 'true ' );
404
404
}
405
405
406
- public function testItDoesNotSetAllowCredentialsHeaderWhenFlagIsNotSetOnValidPreflightRequest ()
406
+ public function testItDoesNotSetAllowCredentialsHeaderWhenFlagIsNotSetOnValidPreflightRequest (): void
407
407
{
408
408
$ this ->cors = $ this ->createCors ();
409
409
$ request = $ this ->createValidPreflightRequest ();
@@ -413,7 +413,7 @@ public function testItDoesNotSetAllowCredentialsHeaderWhenFlagIsNotSetOnValidPre
413
413
$ this ->assertFalse ($ response ->hasHeader ('Access-Control-Allow-Credentials ' ));
414
414
}
415
415
416
- public function testItSetsMaxAgeWhenSet ()
416
+ public function testItSetsMaxAgeWhenSet (): void
417
417
{
418
418
$ this ->cors = $ this ->createCors (['maxAge ' => 42 ]);
419
419
$ request = $ this ->createValidPreflightRequest ();
@@ -424,7 +424,7 @@ public function testItSetsMaxAgeWhenSet()
424
424
$ this ->assertHeader ('Access-Control-Max-Age ' , '42 ' );
425
425
}
426
426
427
- public function testItSetsMaxAgeWhenZero ()
427
+ public function testItSetsMaxAgeWhenZero (): void
428
428
{
429
429
$ this ->cors = $ this ->createCors (['maxAge ' => 0 ]);
430
430
$ request = $ this ->createValidPreflightRequest ();
@@ -435,7 +435,7 @@ public function testItSetsMaxAgeWhenZero()
435
435
$ this ->assertHeader ('Access-Control-Max-Age ' , '0 ' );
436
436
}
437
437
438
- public function testItSkipsEmptyAccessControlRequestHeader ()
438
+ public function testItSkipsEmptyAccessControlRequestHeader (): void
439
439
{
440
440
$ this ->cors = $ this ->createCors ();
441
441
$ request = $ this ->createValidPreflightRequest ();
@@ -446,7 +446,7 @@ public function testItSkipsEmptyAccessControlRequestHeader()
446
446
$ this ->assertSame (204 , $ response ->getStatusCode ());
447
447
}
448
448
449
- public function testItAddsVaryAccessControlRequestMethodHeaderEvenIfItIsNormalOptionsRequest ()
449
+ public function testItAddsVaryAccessControlRequestMethodHeaderEvenIfItIsNormalOptionsRequest (): void
450
450
{
451
451
$ this ->cors = $ this ->createCors (['allowedHeaders ' => ['* ' ]]);
452
452
$ request = $ this ->createRequest ()->withMethod ('OPTIONS ' );
0 commit comments