Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.8] Allow TestResponse dump method chaining #28967

Merged

Conversation

derekmd
Copy link
Contributor

@derekmd derekmd commented Jun 27, 2019

#28960 merged today no longer exits PHPUnit when calling dump() nor dumpHeaders(). However method chaining for the typical HTTP feature test won't work.

This change allows the test to continue as normal, showing PHPUnit's test case Pass/Fail along with the TestResponse dump.

Example dump() chaining

$this->getJson(route('posts.show', $post))
    ->dump() // now returns null
    ->assertStatus(Response::HTTP_UNAUTHORIZED)
    ->assertJson([
        'error' => 'token_not_provided',
    ]);

Before

  Feature
    Tests\Feature\PostsTest
        testShowDeniesAuthorizationToGuest        {#8568
  +"status": "success"
}
ERROR
     
Error: Call to a member function assertStatus() on null

After

  Feature
    Tests\Feature\PostsTest
        testShowDeniesAuthorizationToGuest       {#8568
  +"status": "success"
}
FAIL
    
Response status code [200] does not match expected 401 status code.
Failed asserting that false is true.

@taylorotwell taylorotwell merged commit effec60 into laravel:5.8 Jun 27, 2019
@derekmd derekmd deleted the test-response-dump-method-chaining branch June 27, 2019 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants