Skip to content

Commit

Permalink
Merge pull request #28913 from SjorsO/5.8
Browse files Browse the repository at this point in the history
[5.8] Don't check for status code in assertJsonMissingValidationErrors()
  • Loading branch information
taylorotwell authored Jun 22, 2019
2 parents d1b422b + 1e4e640 commit 7593d65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Testing/TestResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ public function assertJsonValidationErrors($errors)
*/
public function assertJsonMissingValidationErrors($keys = null)
{
if (empty($this->getContent()) && $this->getStatusCode() == 204) {
if ($this->getContent() === '') {
PHPUnit::assertTrue(true);

return $this;
Expand Down
17 changes: 11 additions & 6 deletions tests/Foundation/FoundationTestResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -581,18 +581,23 @@ public function testAssertJsonMissingValidationErrorsWithoutArgumentCanFail()

public function testAssertJsonMissingValidationErrorsOnAnEmptyResponse()
{
$emptyTestResponse204 = TestResponse::fromBaseResponse(
$emptyResponse = TestResponse::fromBaseResponse(
(new Response)->setContent('')
);
$emptyTestResponse204->setStatusCode(204);
$emptyTestResponse204->assertJsonMissingValidationErrors();

$emptyResponse->assertJsonMissingValidationErrors();
}

public function testAssertJsonMissingValidationErrorsOnInvalidJson()
{
$this->expectException(AssertionFailedError::class);
$this->expectExceptionMessage('Invalid JSON was returned from the route.');

$emptyTestResponseNot204 = TestResponse::fromBaseResponse(
(new Response)->setContent('')
$invalidJsonResponse = TestResponse::fromBaseResponse(
(new Response)->setContent('~invalid json')
);
$emptyTestResponseNot204->assertJsonMissingValidationErrors();

$invalidJsonResponse->assertJsonMissingValidationErrors();
}

public function testMacroable()
Expand Down

0 comments on commit 7593d65

Please sign in to comment.