Skip to content

[Turbo] TurboStreamListenRenderer service doesn't register correctly when Mercure Hub is mocked #2775

Open
@milankaranovic

Description

@milankaranovic

Hey everyone! 👋🏻

I updated symfony/ux-turbo from v2.23.0 to 2.25.2 and my tests (WebTestCase) started failing with this error

ErrorException: An exception has been thrown during the rendering of a template 
("Too few arguments to function Symfony\UX\Turbo\Bridge\Mercure\TurboStreamListenRenderer::__construct(), 
3 passed in /app/var/cache/test/ContainerO3ffV3d/getTurbo_Mercure_Default_RendererService.php
 on line 31 and exactly 4 expected") in "foo.html.twig" at line 31.

On line 31 is turbo_stream_listen.

Additionally, I havemercure.hub.default mocked according to these instructions https://symfony.com/doc/current/mercure.html#testing

I see that this PR #2447 has been merged in v2.24.0, and a lot of things related to turbo_stream_listen has changed, including RegisterMercureHubsPass. It loops through mercure.hub tags, so I ended up with this solution

# config/services_test.yaml
services:
    mercure.hub.default:
        class: Tests\Services\MockMercureHub
        tags:
            - 'mercure.hub'

Reporting this because I'm not sure if this is a bug or if the documentation has to be updated.

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