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.4] TestResponse::fromBaseResponse() is not always receiving an illuminate object #17590

Merged
merged 1 commit into from
Jan 27, 2017

Conversation

iWader
Copy link
Contributor

@iWader iWader commented Jan 26, 2017

  • Laravel Version: 5.4.5
  • PHP Version: 7.0.3
  • Database Driver & Version: MySQL 5.7
  • Passport Version: 2.0.1

Description:

I found an instance when the response given to the TestResponse::fromBaseResponse() method is not an illuminate response, but a symfony response. Calling the status method resulted in an undefined method exception.

I was reluctant to update the param on the docblock as the original and exception properties are specific to the illuminate response.

Steps To Reproduce:

  • Fresh laravel install
  • Install passport
  • Run the following test
    public function testingPassportPasswordGrant()
    {
        $client = $this->app->make(ClientRepository::class)
            ->createPasswordGrantClient(null, 'Password Grant Client', 'http://localhost');

        $user = factory(User::class)->create();

        $response = $this->post('/oauth/token', [
            'grant_type' => 'password',
            'client_id' => $client->id,
            'client_secret' => $client->secret,
            'username' => $user->email,
            'password' => 'secret',
            'scope' => '*',
        ]);

        $response->assertStatus(200);
    }
1) Tests\Feature\ExampleTest::testingPassportPasswordGrant
Error: Call to undefined method Symfony\Component\HttpFoundation\Response::status()

/home/vagrant/Code/testing-new/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:23
/home/vagrant/Code/testing-new/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:320
/home/vagrant/Code/testing-new/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:239
/home/vagrant/Code/testing-new/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:84
/home/vagrant/Code/testing-new/tests/Feature/ExampleTest.php:53

@GrahamCampbell GrahamCampbell changed the title TestResponse::fromBaseResponse() is not always receiving an illuminate object [5.4] TestResponse::fromBaseResponse() is not always receiving an illuminate object Jan 26, 2017
@taylorotwell taylorotwell merged commit fbcabd1 into laravel:5.4 Jan 27, 2017
@arcanedev-maroc
Copy link
Contributor

arcanedev-maroc commented Jan 27, 2017

Same here but with:

Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::status()

And after applying this fix, i got a new issue:

The Response content must be a string or object implementing __toString(), "boolean" given.

The $content equals to false at https://github.com/symfony/http-foundation/blob/master/Response.php#L441-L450

Is not working when i want to assert a download method:

return response()->download(...);

Any idea @GrahamCampbell ?

@GrahamCampbell
Copy link
Member

Already fixed. Use latest 5.4-dev. :)

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.

4 participants