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

[BrowserKit] [HttpKernel] StreamedResponse is not working with BrowserKit after Symfony is upgraded to 6.1 #46445

Open
HtunHtunHtet opened this issue May 24, 2022 · 4 comments

Comments

@HtunHtunHtet
Copy link
Contributor

Symfony version(s) affected

6.1

Description

Symfony\Component\HttpFoundation\StreamedResponse is not working in tests (BrowserKit) after Symfony is upgraded to 6.1 - the output is not rendered.

How to reproduce

When asserting that following StreamedResponse using BrowserKit produces 'test' output:

return new StreamedResponse(static function (): void {
    echo 'test';
});

the test is passing on Symfony 6.0 (see reproducer app: https://github.com/HtunHtunHtet/bug_app/tree/main) but starts to fail after upgrading to 6.1-RC1 (see: https://github.com/HtunHtunHtet/bug_app/tree/symfony-6.1) as the output is empty:

Below information is the output of the PHPUnit test.

Time: 00:00.150, Memory: 12.00 MB

There was 1 failure:

1) App\Tests\DefaultControllerTest::testSomething
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'test'
+''

Only the tests are affected as navigating to the controller page returns a correct response.

Possible Solution

No response

Additional Context

It might be related to recent StreamedResponseListener deprecation: #45476

@HtunHtunHtet HtunHtunHtet changed the title StreamedResponse is not working with BrowserKit after Symfony is upgraded to 6.1 [BrowserKit] [HttpKernel] StreamedResponse is not working with BrowserKit after Symfony is upgraded to 6.1 May 24, 2022
@minorbug
Copy link

Thank you @HtunHtunHtet for creating this bug report! This indeed looks like a bug. I reproduced the bug in the "symfony-6.1" branch of https://github.com/HtunHtunHtet/bug_app.

Status: Reviewed

@m-idler
Copy link

m-idler commented Jun 1, 2022

I think i got a similar problem regarding a test for a StreamedResponse:

working test with symfony 6.0

ob_start();
$client->request(Request::METHOD_GET, 'myTestUrl');
$content = \ob_get_clean();
self::assertEquals('foo', $content);

What (know) works for me with symfony 6.1:

$client->request(Request::METHOD_GET, 'myTestUrl');
$content = $client->getInternalResponse()->getContent();
self::assertEquals('foo', $content);

@DaDeather
Copy link

If it's currently still unclear why this is happening:
#45476 (comment)

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants