Skip to content

Commit

Permalink
Add test for the assertHeaderMissing response assertion (#22866)
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-aguilar authored and taylorotwell committed Jan 20, 2018
1 parent cd4029f commit 4bcffd4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Testing/TestResponse.php
Expand Up @@ -131,7 +131,7 @@ public function assertHeader($headerName, $value = null)
* @param string $headerName
* @return $this
*/
protected function assertHeaderMissing($headerName)
public function assertHeaderMissing($headerName)
{
PHPUnit::assertFalse(
$this->headers->has($headerName), "Unexpected header [{$headerName}] is present on response."
Expand Down
18 changes: 18 additions & 0 deletions tests/Foundation/FoundationTestResponseTest.php
Expand Up @@ -70,6 +70,24 @@ public function testAssertHeader()
}
}

public function testAssertHeaderMissing()
{
$baseResponse = tap(new Response, function ($response) {
$response->header('Location', '/foo');
});

$response = TestResponse::fromBaseResponse($baseResponse);

try {
$response->assertHeaderMissing('Location');
} catch (\PHPUnit\Framework\ExpectationFailedException $e) {
$this->assertContains(
'Unexpected header [Location] is present on response.',
$e->getMessage()
);
}
}

public function testAssertJsonWithArray()
{
$response = TestResponse::fromBaseResponse(new Response(new JsonSerializableSingleResourceStub));
Expand Down

0 comments on commit 4bcffd4

Please sign in to comment.