Skip to content

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

@HtunHtunHtet

Description

@HtunHtunHtet

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions