diff --git a/src/Illuminate/Foundation/Testing/TestResponse.php b/src/Illuminate/Foundation/Testing/TestResponse.php index ab983b1d54fb..bca952baf553 100644 --- a/src/Illuminate/Foundation/Testing/TestResponse.php +++ b/src/Illuminate/Foundation/Testing/TestResponse.php @@ -114,7 +114,7 @@ public function assertHeader($headerName, $value = null) if (! is_null($value)) { PHPUnit::assertEquals( - $this->headers->get($headerName), $value, + $value, $this->headers->get($headerName), "Header [{$headerName}] was found, but value [{$actual}] does not match [{$value}]." ); } diff --git a/tests/Foundation/FoundationTestResponseTest.php b/tests/Foundation/FoundationTestResponseTest.php index c6eaef310dae..f7ced8e81f57 100644 --- a/tests/Foundation/FoundationTestResponseTest.php +++ b/tests/Foundation/FoundationTestResponseTest.php @@ -39,6 +39,22 @@ public function testAssertSeeText() $response->assertSeeText('foobar'); } + public function testAssertHeader() + { + $baseResponse = tap(new Response, function ($response) { + $response->header('Location', '/foo'); + }); + + $response = TestResponse::fromBaseResponse($baseResponse); + + try { + $response->assertHeader('Location', '/bar'); + } catch (\PHPUnit_Framework_ExpectationFailedException $e) { + $this->assertEquals('/bar', $e->getComparisonFailure()->getExpected()); + $this->assertEquals('/foo', $e->getComparisonFailure()->getActual()); + } + } + public function testAssertJsonWithArray() { $response = TestResponse::fromBaseResponse(new Response(new JsonSerializableSingleResourceStub));