Skip to content

[5.8] Allow TestResponse dump method chaining#28967

Merged
taylorotwell merged 1 commit into
laravel:5.8from
derekmd:test-response-dump-method-chaining
Jun 27, 2019
Merged

[5.8] Allow TestResponse dump method chaining#28967
taylorotwell merged 1 commit into
laravel:5.8from
derekmd:test-response-dump-method-chaining

Conversation

@derekmd

@derekmd derekmd commented Jun 27, 2019

Copy link
Copy Markdown
Contributor

#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