Skip to content

Commit ca629c1

Browse files
authored
Merge pull request #3228 from peter279k/assertion_enhancement
Using assertSame to let assert equal be restricted
2 parents 3d7ea05 + 3c13502 commit ca629c1

18 files changed

Lines changed: 174 additions & 174 deletions

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
steps:
2020
- name: Checkout
21-
uses: actions/checkout@v2
21+
uses: actions/checkout@v3
2222

2323
- name: Set up PHP ${{ matrix.php }}
2424
uses: shivammathur/setup-php@v2
@@ -27,7 +27,7 @@ jobs:
2727
coverage: xdebug
2828

2929
- name: Install dependencies with Composer
30-
uses: ramsey/composer-install@v1
30+
uses: ramsey/composer-install@v2
3131

3232
- name: Coding standards
3333
if: matrix.analysis

tests/AppTest.php

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function testGetPostPutPatchDeleteOptionsMethods(string $method): void
201201
});
202202
$response = $app->handle($requestProphecy->reveal());
203203

204-
$this->assertEquals('Hello World', (string) $response->getBody());
204+
$this->assertSame('Hello World', (string) $response->getBody());
205205
}
206206

207207
public function testAnyRoute(): void
@@ -236,7 +236,7 @@ public function testAnyRoute(): void
236236

237237
$response = $app->handle($requestProphecy->reveal());
238238

239-
$this->assertEquals('Hello World', (string) $response->getBody());
239+
$this->assertSame('Hello World', (string) $response->getBody());
240240
}
241241
}
242242

@@ -290,7 +290,7 @@ public function testMapRoute(string $method): void
290290
});
291291
$response = $app->handle($requestProphecy->reveal());
292292

293-
$this->assertEquals('Hello World', (string) $response->getBody());
293+
$this->assertSame('Hello World', (string) $response->getBody());
294294
}
295295

296296
public function testRedirectRoute(): void
@@ -333,8 +333,8 @@ public function testRedirectRoute(): void
333333
$response = $app->handle($requestProphecy->reveal());
334334

335335
$responseFactoryProphecy->createResponse(301)->shouldHaveBeenCalled();
336-
$this->assertEquals(301, $response->getStatusCode());
337-
$this->assertEquals($to, $response->getHeaderLine('Location'));
336+
$this->assertSame(301, $response->getStatusCode());
337+
$this->assertSame($to, $response->getHeaderLine('Location'));
338338
}
339339

340340
public function testRouteWithInternationalCharacters(): void
@@ -369,7 +369,7 @@ public function testRouteWithInternationalCharacters(): void
369369
$response = $app->handle($requestProphecy->reveal());
370370

371371
$this->assertInstanceOf(ResponseInterface::class, $response);
372-
$this->assertEquals('Hello World', (string) $response->getBody());
372+
$this->assertSame('Hello World', (string) $response->getBody());
373373
}
374374

375375
/********************************************************************************
@@ -402,7 +402,7 @@ public function testRoutePatterns(string $pattern): void
402402
$routeCollector = $app->getRouteCollector();
403403
$route = $routeCollector->lookupRoute('route0');
404404

405-
$this->assertEquals($pattern, $route->getPattern());
405+
$this->assertSame($pattern, $route->getPattern());
406406
}
407407

408408
/********************************************************************************
@@ -566,7 +566,7 @@ public function testRouteGroupCombinations(array $sequence, string $expectedPath
566566
$routeCollector = $app->getRouteCollector();
567567
$route = $routeCollector->lookupRoute('route0');
568568

569-
$this->assertEquals($expectedPath, $route->getPattern());
569+
$this->assertSame($expectedPath, $route->getPattern());
570570
}
571571

572572
public function testRouteGroupPattern(): void
@@ -579,7 +579,7 @@ public function testRouteGroupPattern(): void
579579
$group = $app->group('/foo', function () {
580580
});
581581

582-
$this->assertEquals('/foo', $group->getPattern());
582+
$this->assertSame('/foo', $group->getPattern());
583583
}
584584

585585
/********************************************************************************
@@ -855,7 +855,7 @@ public function testAddMiddlewareOnRoute(): void
855855

856856
$app->handle($requestProphecy->reveal());
857857

858-
$this->assertEquals('In2In1CenterOut1Out2', $output);
858+
$this->assertSame('In2In1CenterOut1Out2', $output);
859859
}
860860

861861
public function testAddMiddlewareOnRouteGroup(): void
@@ -937,7 +937,7 @@ public function testAddMiddlewareOnRouteGroup(): void
937937

938938
$app->handle($requestProphecy->reveal());
939939

940-
$this->assertEquals('In2In1CenterOut1Out2', $output);
940+
$this->assertSame('In2In1CenterOut1Out2', $output);
941941
}
942942

943943
public function testAddMiddlewareOnTwoRouteGroup(): void
@@ -1057,7 +1057,7 @@ public function testAddMiddlewareOnTwoRouteGroup(): void
10571057

10581058
$app->handle($requestProphecy->reveal());
10591059

1060-
$this->assertEquals('In1In2In3CenterOut3Out2Out1', $output);
1060+
$this->assertSame('In1In2In3CenterOut3Out2Out1', $output);
10611061
}
10621062

10631063
public function testAddMiddlewareAsStringNotImplementingInterfaceThrowsException(): void
@@ -1132,7 +1132,7 @@ public function testInvokeWithMatchingRoute(): void
11321132
$response = $app->handle($requestProphecy->reveal());
11331133

11341134
$this->assertInstanceOf(ResponseInterface::class, $response);
1135-
$this->assertEquals('Hello World', (string) $response->getBody());
1135+
$this->assertSame('Hello World', (string) $response->getBody());
11361136
}
11371137

11381138
public function testInvokeWithMatchingRouteWithSetArgument(): void
@@ -1172,7 +1172,7 @@ public function testInvokeWithMatchingRouteWithSetArgument(): void
11721172
$response = $app->handle($requestProphecy->reveal());
11731173

11741174
$this->assertInstanceOf(ResponseInterface::class, $response);
1175-
$this->assertEquals('Hello World', (string) $response->getBody());
1175+
$this->assertSame('Hello World', (string) $response->getBody());
11761176
}
11771177

11781178
public function testInvokeWithMatchingRouteWithSetArguments(): void
@@ -1212,7 +1212,7 @@ public function testInvokeWithMatchingRouteWithSetArguments(): void
12121212
$response = $app->handle($requestProphecy->reveal());
12131213

12141214
$this->assertInstanceOf(ResponseInterface::class, $response);
1215-
$this->assertEquals('Hello World', (string) $response->getBody());
1215+
$this->assertSame('Hello World', (string) $response->getBody());
12161216
}
12171217

12181218
public function testInvokeWithMatchingRouteWithNamedParameterRequestResponseStrategy(): void
@@ -1252,7 +1252,7 @@ public function testInvokeWithMatchingRouteWithNamedParameterRequestResponseStra
12521252
$response = $app->handle($requestProphecy->reveal());
12531253

12541254
$this->assertInstanceOf(ResponseInterface::class, $response);
1255-
$this->assertEquals('Hello World', (string) $response->getBody());
1255+
$this->assertSame('Hello World', (string) $response->getBody());
12561256
}
12571257

12581258
public function testInvokeWithMatchingRouteWithNamedParameterRequestResponseArgStrategy(): void
@@ -1293,7 +1293,7 @@ public function testInvokeWithMatchingRouteWithNamedParameterRequestResponseArgS
12931293
$response = $app->handle($requestProphecy->reveal());
12941294

12951295
$this->assertInstanceOf(ResponseInterface::class, $response);
1296-
$this->assertEquals('Hello World', (string) $response->getBody());
1296+
$this->assertSame('Hello World', (string) $response->getBody());
12971297
}
12981298

12991299
public function testInvokeWithMatchingRouteWithNamedParameterRequestResponseNamedArgsStrategy(): void
@@ -1341,7 +1341,7 @@ function (ServerRequestInterface $request, ResponseInterface $response, $name, $
13411341
$response = $app->handle($requestProphecy->reveal());
13421342

13431343
$this->assertInstanceOf(ResponseInterface::class, $response);
1344-
$this->assertEquals('Hello World', (string) $response->getBody());
1344+
$this->assertSame('Hello World', (string) $response->getBody());
13451345
}
13461346

13471347
public function testInvokeWithMatchingRouteWithNamedParameterOverwritesSetArgument(): void
@@ -1381,7 +1381,7 @@ public function testInvokeWithMatchingRouteWithNamedParameterOverwritesSetArgume
13811381
$response = $app->handle($requestProphecy->reveal());
13821382

13831383
$this->assertInstanceOf(ResponseInterface::class, $response);
1384-
$this->assertEquals('Hello World', (string) $response->getBody());
1384+
$this->assertSame('Hello World', (string) $response->getBody());
13851385
}
13861386

13871387
public function testInvokeWithoutMatchingRoute(): void
@@ -1447,7 +1447,7 @@ public function foo(ServerRequestInterface $request, ResponseInterface $response
14471447
$response = $app->handle($requestProphecy->reveal());
14481448

14491449
$this->assertInstanceOf(ResponseInterface::class, $response);
1450-
$this->assertEquals('Hello World', (string) $response->getBody());
1450+
$this->assertSame('Hello World', (string) $response->getBody());
14511451
}
14521452

14531453
public function testInvokeWithNonExistentMethodOnCallableRegisteredInContainer(): void
@@ -1527,7 +1527,7 @@ public function testInvokeWithCallableInContainerViaCallMagicMethod(): void
15271527

15281528
$expectedPayload = json_encode(['name' => 'foo', 'arguments' => []]);
15291529
$this->assertInstanceOf(ResponseInterface::class, $response);
1530-
$this->assertEquals($expectedPayload, (string) $response->getBody());
1530+
$this->assertSame($expectedPayload, (string) $response->getBody());
15311531
}
15321532

15331533
public function testInvokeFunctionName(): void
@@ -1573,7 +1573,7 @@ function handle($request, ResponseInterface $response)
15731573
$response = $app->handle($requestProphecy->reveal());
15741574

15751575
$this->assertInstanceOf(ResponseInterface::class, $response);
1576-
$this->assertEquals('Hello World', (string) $response->getBody());
1576+
$this->assertSame('Hello World', (string) $response->getBody());
15771577
}
15781578

15791579
public function testCurrentRequestAttributesAreNotLostWhenAddingRouteArguments(): void
@@ -1613,7 +1613,7 @@ public function testCurrentRequestAttributesAreNotLostWhenAddingRouteArguments()
16131613
$response = $app->handle($requestProphecy->reveal()->withAttribute('greeting', 'Hello'));
16141614

16151615
$this->assertInstanceOf(ResponseInterface::class, $response);
1616-
$this->assertEquals('Hello World', (string) $response->getBody());
1616+
$this->assertSame('Hello World', (string) $response->getBody());
16171617
}
16181618

16191619
public function testCurrentRequestAttributesAreNotLostWhenAddingRouteArgumentsRequestResponseArg(): void
@@ -1654,7 +1654,7 @@ public function testCurrentRequestAttributesAreNotLostWhenAddingRouteArgumentsRe
16541654
$response = $app->handle($requestProphecy->reveal()->withAttribute('greeting', 'Hello'));
16551655

16561656
$this->assertInstanceOf(ResponseInterface::class, $response);
1657-
$this->assertEquals('Hello World', (string) $response->getBody());
1657+
$this->assertSame('Hello World', (string) $response->getBody());
16581658
}
16591659

16601660
public function testRun(): void
@@ -1801,7 +1801,7 @@ public function testHandleReturnsEmptyResponseBodyWithHeadRequestMethod(): void
18011801

18021802
$response = $app->handle($requestProphecy->reveal());
18031803

1804-
$this->assertEquals(1, $called);
1804+
$this->assertSame(1, $called);
18051805
$this->assertEmpty((string) $response->getBody());
18061806
}
18071807

@@ -1917,7 +1917,7 @@ public function testCanBeReExecutedRecursivelyDuringDispatch(): void
19171917

19181918
$this->assertSame(204, $response->getStatusCode());
19191919
$this->assertSame(['nested', 'outer'], $response->getHeader('X-TRACE'));
1920-
$this->assertEquals('11', (string) $response->getBody());
1920+
$this->assertSame('11', (string) $response->getBody());
19211921
}
19221922

19231923
// TODO: Re-add testUnsupportedMethodWithoutRoute
@@ -1959,7 +1959,7 @@ public function testContainerSetToRoute(): void
19591959

19601960
$response = $app->handle($requestProphecy->reveal());
19611961

1962-
$this->assertEquals('Hello World', (string) $response->getBody());
1962+
$this->assertSame('Hello World', (string) $response->getBody());
19631963
}
19641964

19651965
public function testAppIsARequestHandler(): void
@@ -2005,7 +2005,7 @@ public function testInvokeSequentialProcessToAPathWithOptionalArgsAndWithoutOpti
20052005
});
20062006

20072007
$response = $app->handle($requestProphecy->reveal());
2008-
$this->assertEquals('1', (string) $response->getBody());
2008+
$this->assertSame('1', (string) $response->getBody());
20092009

20102010
$uriProphecy2 = $this->prophesize(UriInterface::class);
20112011
$uriProphecy2->getPath()->willReturn('/Hello');
@@ -2021,7 +2021,7 @@ public function testInvokeSequentialProcessToAPathWithOptionalArgsAndWithoutOpti
20212021

20222022
$streamProphecy->__toString()->willReturn('');
20232023
$response = $app->handle($requestProphecy2->reveal());
2024-
$this->assertEquals('0', (string) $response->getBody());
2024+
$this->assertSame('0', (string) $response->getBody());
20252025
}
20262026

20272027
public function testInvokeSequentialProcessToAPathWithOptionalArgsAndWithoutOptionalArgsAndKeepSetedArgs(): void
@@ -2059,7 +2059,7 @@ public function testInvokeSequentialProcessToAPathWithOptionalArgsAndWithoutOpti
20592059
});
20602060

20612061
$response = $app->handle($requestProphecy->reveal());
2062-
$this->assertEquals('2', (string) $response->getBody());
2062+
$this->assertSame('2', (string) $response->getBody());
20632063

20642064
$uriProphecy2 = $this->prophesize(UriInterface::class);
20652065
$uriProphecy2->getPath()->willReturn('/Hello');
@@ -2075,7 +2075,7 @@ public function testInvokeSequentialProcessToAPathWithOptionalArgsAndWithoutOpti
20752075

20762076
$streamProphecy->__toString()->willReturn('');
20772077
$response = $app->handle($requestProphecy2->reveal());
2078-
$this->assertEquals('1', (string) $response->getBody());
2078+
$this->assertSame('1', (string) $response->getBody());
20792079
}
20802080

20812081
public function testInvokeSequentialProcessAfterAddingAnotherRouteArgument(): void
@@ -2118,12 +2118,12 @@ public function testInvokeSequentialProcessAfterAddingAnotherRouteArgument(): vo
21182118
});
21192119

21202120
$response = $app->handle($requestProphecy->reveal());
2121-
$this->assertEquals('2', (string) $response->getBody());
2121+
$this->assertSame('2', (string) $response->getBody());
21222122

21232123
$route->setArgument('extra2', 'value2');
21242124

21252125
$streamProphecy->__toString()->willReturn('');
21262126
$response = $app->handle($requestProphecy->reveal());
2127-
$this->assertEquals('3', (string) $response->getBody());
2127+
$this->assertSame('3', (string) $response->getBody());
21282128
}
21292129
}

0 commit comments

Comments
 (0)