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

Projects
None yet
2 participants
@derekmd
Copy link
Contributor

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

2 checks passed

continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@derekmd derekmd deleted the derekmd:test-response-dump-method-chaining branch Jun 27, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.