Skip to content

Commit d52f07b

Browse files
committed
test: add return types
1 parent 2664c06 commit d52f07b

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

tests/system/Filters/CorsTest.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private function createValidActualRequest(): IncomingRequest
7575
return $request;
7676
}
7777

78-
private function createCors(array $options = [])
78+
private function createCors(array $options = []): Cors
7979
{
8080
$passedOptions = array_merge(
8181
[
@@ -107,7 +107,7 @@ private function assertHeader(string $name, string $value): void
107107
$this->assertSame($value, $this->response->getHeaderLine($name));
108108
}
109109

110-
public function testItDoesModifyOnARequestWithoutOrigin()
110+
public function testItDoesModifyOnARequestWithoutOrigin(): void
111111
{
112112
$this->cors = $this->createCors();
113113
$request = $this->createRequest();
@@ -120,7 +120,7 @@ public function testItDoesModifyOnARequestWithoutOrigin()
120120
);
121121
}
122122

123-
public function testItDoesNotModifyOnARequestWithoutOrigin()
123+
public function testItDoesNotModifyOnARequestWithoutOrigin(): void
124124
{
125125
$this->cors = $this->createCors([
126126
'allowedOrigins' => ['https://www.example.com', 'https://app.example.com'],
@@ -151,7 +151,7 @@ private function handle($request): ResponseInterface
151151
return $response;
152152
}
153153

154-
public function testItDoesModifyOnARequestWithSameOrigin()
154+
public function testItDoesModifyOnARequestWithSameOrigin(): void
155155
{
156156
$this->cors = $this->createCors(['allowedOrigins' => ['*']]);
157157
$request = $this->createRequest();
@@ -163,7 +163,7 @@ public function testItDoesModifyOnARequestWithSameOrigin()
163163
$this->assertHeader('Access-Control-Allow-Origin', '*');
164164
}
165165

166-
public function testItReturnsAllowOriginHeaderOnValidActualRequest()
166+
public function testItReturnsAllowOriginHeaderOnValidActualRequest(): void
167167
{
168168
$this->cors = $this->createCors();
169169
$request = $this->createValidActualRequest();
@@ -174,7 +174,7 @@ public function testItReturnsAllowOriginHeaderOnValidActualRequest()
174174
$this->assertHeader('Access-Control-Allow-Origin', 'http://localhost');
175175
}
176176

177-
public function testItReturnsAllowOriginHeaderOnAllowAllOriginRequest()
177+
public function testItReturnsAllowOriginHeaderOnAllowAllOriginRequest(): void
178178
{
179179
$this->cors = $this->createCors(['allowedOrigins' => ['*']]);
180180
$request = $this->createRequest();
@@ -187,7 +187,7 @@ public function testItReturnsAllowOriginHeaderOnAllowAllOriginRequest()
187187
$this->assertHeader('Access-Control-Allow-Origin', '*');
188188
}
189189

190-
public function testItReturnsAllowHeadersHeaderOnAllowAllHeadersRequest()
190+
public function testItReturnsAllowHeadersHeaderOnAllowAllHeadersRequest(): void
191191
{
192192
$this->cors = $this->createCors(['allowedHeaders' => ['*']]);
193193
$request = $this->createValidPreflightRequest();
@@ -201,7 +201,7 @@ public function testItReturnsAllowHeadersHeaderOnAllowAllHeadersRequest()
201201
$this->assertHeader('Vary', 'Access-Control-Request-Method');
202202
}
203203

204-
public function testItDoesntPermitWildcardAllowedHeadersAndSupportsCredentials()
204+
public function testItDoesntPermitWildcardAllowedHeadersAndSupportsCredentials(): void
205205
{
206206
$this->expectException(ConfigException::class);
207207
$this->expectExceptionMessage(
@@ -226,7 +226,7 @@ public function testItSetsAllowCredentialsHeaderWhenFlagIsSetOnValidActualReques
226226
$this->assertHeader('Access-Control-Allow-Credentials', 'true');
227227
}
228228

229-
public function testItDoesNotSetAllowCredentialsHeaderWhenFlagIsNotSetOnValidActualRequest()
229+
public function testItDoesNotSetAllowCredentialsHeaderWhenFlagIsNotSetOnValidActualRequest(): void
230230
{
231231
$this->cors = $this->createCors();
232232
$request = $this->createValidActualRequest();
@@ -236,7 +236,7 @@ public function testItDoesNotSetAllowCredentialsHeaderWhenFlagIsNotSetOnValidAct
236236
$this->assertFalse($response->hasHeader('Access-Control-Allow-Credentials'));
237237
}
238238

239-
public function testItSetsExposedHeadersWhenConfiguredOnActualRequest()
239+
public function testItSetsExposedHeadersWhenConfiguredOnActualRequest(): void
240240
{
241241
$this->cors = $this->createCors(['exposedHeaders' => ['x-exposed-header', 'x-another-exposed-header']]);
242242
$request = $this->createValidActualRequest();
@@ -250,7 +250,7 @@ public function testItSetsExposedHeadersWhenConfiguredOnActualRequest()
250250
);
251251
}
252252

253-
public function testItDoesNotPermitWildcardAllowedOriginsAndSupportsCredentials()
253+
public function testItDoesNotPermitWildcardAllowedOriginsAndSupportsCredentials(): void
254254
{
255255
$this->expectException(ConfigException::class);
256256
$this->expectExceptionMessage(
@@ -266,7 +266,7 @@ public function testItDoesNotPermitWildcardAllowedOriginsAndSupportsCredentials(
266266
$this->handle($request);
267267
}
268268

269-
public function testItDoesNotPermitWildcardAllowedOriginsAllowedMethodAndSupportsCredentials()
269+
public function testItDoesNotPermitWildcardAllowedOriginsAllowedMethodAndSupportsCredentials(): void
270270
{
271271
$this->expectException(ConfigException::class);
272272
$this->expectExceptionMessage(
@@ -283,7 +283,7 @@ public function testItDoesNotPermitWildcardAllowedOriginsAllowedMethodAndSupport
283283
$this->handle($request);
284284
}
285285

286-
public function testItAddsAVaryHeaderWhenHasOriginPatterns()
286+
public function testItAddsAVaryHeaderWhenHasOriginPatterns(): void
287287
{
288288
$this->cors = $this->createCors([
289289
'allowedOriginsPatterns' => ['http://l(o|0)calh(o|0)st'],
@@ -296,7 +296,7 @@ public function testItAddsAVaryHeaderWhenHasOriginPatterns()
296296
$this->assertHeader('Vary', 'Origin');
297297
}
298298

299-
public function testItDoesntPermitWildcardAndOrigin()
299+
public function testItDoesntPermitWildcardAndOrigin(): void
300300
{
301301
$this->expectException(ConfigException::class);
302302
$this->expectExceptionMessage(
@@ -311,7 +311,7 @@ public function testItDoesntPermitWildcardAndOrigin()
311311
$this->handle($request);
312312
}
313313

314-
public function testItDoesntAddAVaryHeaderWhenSimpleOrigins()
314+
public function testItDoesntAddAVaryHeaderWhenSimpleOrigins(): void
315315
{
316316
$this->cors = $this->createCors([
317317
'allowedOrigins' => ['http://localhost'],
@@ -324,7 +324,7 @@ public function testItDoesntAddAVaryHeaderWhenSimpleOrigins()
324324
$this->assertFalse($response->hasHeader('Vary'));
325325
}
326326

327-
public function testItAddsAVaryHeaderWhenMultipleOrigins()
327+
public function testItAddsAVaryHeaderWhenMultipleOrigins(): void
328328
{
329329
$this->cors = $this->createCors([
330330
'allowedOrigins' => ['http://localhost', 'http://example.com'],
@@ -337,7 +337,7 @@ public function testItAddsAVaryHeaderWhenMultipleOrigins()
337337
$this->assertTrue($response->hasHeader('Vary'));
338338
}
339339

340-
public function testItReturnsAccessControlHeadersOnCorsRequest()
340+
public function testItReturnsAccessControlHeadersOnCorsRequest(): void
341341
{
342342
$this->cors = $this->createCors();
343343
$request = $this->createRequest();
@@ -349,7 +349,7 @@ public function testItReturnsAccessControlHeadersOnCorsRequest()
349349
$this->assertHeader('Access-Control-Allow-Origin', 'http://localhost');
350350
}
351351

352-
public function testItReturnsAccessControlHeadersOnCorsRequestWithPatternOrigin()
352+
public function testItReturnsAccessControlHeadersOnCorsRequestWithPatternOrigin(): void
353353
{
354354
$this->cors = $this->createCors([
355355
'allowedOrigins' => [],
@@ -365,7 +365,7 @@ public function testItReturnsAccessControlHeadersOnCorsRequestWithPatternOrigin(
365365
$this->assertHeader('Vary', 'Origin');
366366
}
367367

368-
public function testItReturnsAccessControlHeadersOnValidPreflightRequest()
368+
public function testItReturnsAccessControlHeadersOnValidPreflightRequest(): void
369369
{
370370
$this->cors = $this->createCors();
371371
$request = $this->createValidPreflightRequest();
@@ -376,7 +376,7 @@ public function testItReturnsAccessControlHeadersOnValidPreflightRequest()
376376
$this->assertHeader('Access-Control-Allow-Origin', 'http://localhost');
377377
}
378378

379-
public function testItReturnsOkOnValidPreflightRequestWithRequestedHeadersAllowed()
379+
public function testItReturnsOkOnValidPreflightRequestWithRequestedHeadersAllowed(): void
380380
{
381381
$this->cors = $this->createCors();
382382
$requestHeaders = 'X-Allowed-Header, x-other-allowed-header';
@@ -392,7 +392,7 @@ public function testItReturnsOkOnValidPreflightRequestWithRequestedHeadersAllowe
392392
$this->assertHeader('Access-Control-Allow-Headers', 'x-allowed-header, x-other-allowed-header');
393393
}
394394

395-
public function testItSetsAllowCredentialsHeaderWhenFlagIsSetOnValidPreflightRequest()
395+
public function testItSetsAllowCredentialsHeaderWhenFlagIsSetOnValidPreflightRequest(): void
396396
{
397397
$this->cors = $this->createCors(['supportsCredentials' => true]);
398398
$request = $this->createValidPreflightRequest();
@@ -403,7 +403,7 @@ public function testItSetsAllowCredentialsHeaderWhenFlagIsSetOnValidPreflightReq
403403
$this->assertHeader('Access-Control-Allow-Credentials', 'true');
404404
}
405405

406-
public function testItDoesNotSetAllowCredentialsHeaderWhenFlagIsNotSetOnValidPreflightRequest()
406+
public function testItDoesNotSetAllowCredentialsHeaderWhenFlagIsNotSetOnValidPreflightRequest(): void
407407
{
408408
$this->cors = $this->createCors();
409409
$request = $this->createValidPreflightRequest();
@@ -413,7 +413,7 @@ public function testItDoesNotSetAllowCredentialsHeaderWhenFlagIsNotSetOnValidPre
413413
$this->assertFalse($response->hasHeader('Access-Control-Allow-Credentials'));
414414
}
415415

416-
public function testItSetsMaxAgeWhenSet()
416+
public function testItSetsMaxAgeWhenSet(): void
417417
{
418418
$this->cors = $this->createCors(['maxAge' => 42]);
419419
$request = $this->createValidPreflightRequest();
@@ -424,7 +424,7 @@ public function testItSetsMaxAgeWhenSet()
424424
$this->assertHeader('Access-Control-Max-Age', '42');
425425
}
426426

427-
public function testItSetsMaxAgeWhenZero()
427+
public function testItSetsMaxAgeWhenZero(): void
428428
{
429429
$this->cors = $this->createCors(['maxAge' => 0]);
430430
$request = $this->createValidPreflightRequest();
@@ -435,7 +435,7 @@ public function testItSetsMaxAgeWhenZero()
435435
$this->assertHeader('Access-Control-Max-Age', '0');
436436
}
437437

438-
public function testItSkipsEmptyAccessControlRequestHeader()
438+
public function testItSkipsEmptyAccessControlRequestHeader(): void
439439
{
440440
$this->cors = $this->createCors();
441441
$request = $this->createValidPreflightRequest();
@@ -446,7 +446,7 @@ public function testItSkipsEmptyAccessControlRequestHeader()
446446
$this->assertSame(204, $response->getStatusCode());
447447
}
448448

449-
public function testItAddsVaryAccessControlRequestMethodHeaderEvenIfItIsNormalOptionsRequest()
449+
public function testItAddsVaryAccessControlRequestMethodHeaderEvenIfItIsNormalOptionsRequest(): void
450450
{
451451
$this->cors = $this->createCors(['allowedHeaders' => ['*']]);
452452
$request = $this->createRequest()->withMethod('OPTIONS');

0 commit comments

Comments
 (0)