zenstruck / messenger-test

Assertions and helpers for testing your symfony/messenger queues.
MIT License
218 stars 15 forks source link

Multiple transports setup issue #63

Closed hristonev closed 1 year ago

hristonev commented 1 year ago

Hello, I'm trying to set up this library. According to the documentation I have:

#config/packages/messenger.yaml

when@test:
    framework:
        messenger:
            transports:
                reporting: test://
#tests/Api/StatementTest.php

use Zenstruck\Messenger\Test\InteractsWithMessenger;

class StatementTest extends BaseWebTestCase
{
    use InteractsWithMessenger;

    #[TestDox('$name')]
    #[DataProvider('statementProvider')]
    public function testCRUD(string $name, array $request, array $responseExpected)
    {
        $this->transport('reporting')->queue();
...

Seems that Bundle can't read yaml-configuration because of the error:

✘ Check·report·message·was·sent
   ┐
   ├ LogicException: Transport "reporting" needs to be set to "test://" in your test config to use this feature.
   │
   │ /var/www/html/vendor/zenstruck/messenger-test/src/Transport/TestTransportRegistry.php:50
   │ /var/www/html/vendor/zenstruck/messenger-test/src/InteractsWithMessenger.php:90
   │ /var/www/html/tests/Api/StatementTest.php:37

I have multiple messenger transports. Please help with any suggestions. Thanks in advance.

nikophil commented 1 year ago

hi!

this is weird: I use this lib in projects which multiple transports and it is OK

could you please run this command, and check if your configuration is well understood by Symfony? (meaning your reporting transport has test:// as DSN)

$ bin/console debug:config framework messenger  --env=test
kbond commented 1 year ago

I can't immediately see the issue. The bundle is clearly registered but for some reason your config isn't being picked up.

Sanity check: your tests are run in the test environment?

hristonev commented 1 year ago

Thanks for the debug command! I was looking for that. After I checked that config is overwritten by an external bundle config!

hristonev commented 1 year ago

Thanks a lot, guys!