Skip to content

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

Merged
taylorotwell merged 1 commit into
laravel:11.xfrom
tben:patch-1
Feb 5, 2025
Merged

[11.x] Fix assertContent on laravel test that respond with Symfony Response Object#54467
taylorotwell merged 1 commit into
laravel:11.xfrom
tben:patch-1

Conversation

@tben

@tben tben commented Feb 4, 2025

Copy link
Copy Markdown
Contributor

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
@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.

2 participants