From 686d5a04361166bd2636f619ceba03df58dbaba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Monnot=20St=C3=A9phane?= Date: Tue, 9 May 2017 01:15:56 +0200 Subject: [PATCH] Fix inversion of expected and actual on assertHeader --- .../Foundation/Testing/TestResponse.php | 2 +- tests/Foundation/FoundationTestResponseTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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));