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

[11.x] Fix assertContent on laravel test that respond with Symfony Response Object #54467

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

tben
Copy link
Contributor

@tben tben commented Feb 4, 2025

This pull request fixes an issue when a controller is returning a Symfony\Component\HttpFoundation\Response object instead of the usual Laravel Response object. This is down to Symfony response object not having content function defined.

I noticed that the rest of the TestResponse class uses ->getContent(), which works with the Symfony object. So I've applied that to this function as well.

Test:

$test = \Illuminate\Testing\TestResponse::fromBaseResponse(
    new \Symfony\Component\HttpFoundation\Response('testing', 200)
 );

$test->assertContent('testing');

@taylorotwell taylorotwell merged commit 2e6ff4f into laravel:11.x Feb 5, 2025
40 checks passed
@tben tben deleted the patch-1 branch February 17, 2025 13:28
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.

None yet

2 participants