Skip to content

Commit 92d1830

Browse files
stephane-monnottaylorotwell
authored andcommitted
Fix inversion of expected and actual on assertHeader (#19110)
1 parent fc5c7a1 commit 92d1830

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Illuminate/Foundation/Testing/TestResponse.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function assertHeader($headerName, $value = null)
114114

115115
if (! is_null($value)) {
116116
PHPUnit::assertEquals(
117-
$this->headers->get($headerName), $value,
117+
$value, $this->headers->get($headerName),
118118
"Header [{$headerName}] was found, but value [{$actual}] does not match [{$value}]."
119119
);
120120
}

tests/Foundation/FoundationTestResponseTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ public function testAssertSeeText()
3939
$response->assertSeeText('foobar');
4040
}
4141

42+
public function testAssertHeader()
43+
{
44+
$baseResponse = tap(new Response, function ($response) {
45+
$response->header('Location', '/foo');
46+
});
47+
48+
$response = TestResponse::fromBaseResponse($baseResponse);
49+
50+
try {
51+
$response->assertHeader('Location', '/bar');
52+
} catch (\PHPUnit_Framework_ExpectationFailedException $e) {
53+
$this->assertEquals('/bar', $e->getComparisonFailure()->getExpected());
54+
$this->assertEquals('/foo', $e->getComparisonFailure()->getActual());
55+
}
56+
}
57+
4258
public function testAssertJsonWithArray()
4359
{
4460
$response = TestResponse::fromBaseResponse(new Response(new JsonSerializableSingleResourceStub));

0 commit comments

Comments
 (0)