Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DI/Pass/TransportFactoryPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function beforePassCompile(): void
{
$builder = $this->getContainerBuilder();

// Register Doctrine transport factory when ConnectionRegistry is available
// Register Doctrine transport factory when ConnectionRegistry is available (unless already defined via config)
if (class_exists(DoctrineTransportFactory::class) && interface_exists(ConnectionRegistry::class)) {
if (
$builder->getByType(ConnectionRegistry::class, false) !== null
Expand Down
21 changes: 21 additions & 0 deletions tests/Cases/DI/MessengerExtension.transport.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,27 @@ Toolkit::test(function (): void {
Assert::count(1, $container->findByTag(MessengerExtension::FAILURE_TRANSPORT_TAG));
});

// Doctrine transport factory registered when explicitly defined in NEON
Toolkit::test(static function (): void {
$container = Container::of()
->withDefaults()
->withCompiler(static function (Compiler $compiler): void {
$compiler->addConfig(Helpers::neon(<<<'NEON'
messenger:
transportFactory:
doctrine: Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineTransportFactory
services:
connectionRegistry: Tests\Mocks\Doctrine\DummyConnectionRegistry
NEON
));
})
->build();

// 6 = sync + inMemory + amqp + redis + doctrine + main TransportFactory
Assert::count(6, $container->findByType(TransportFactoryInterface::class));
Assert::true($container->hasService('messenger.transportFactory.doctrine'));
});

// Doctrine transport factory not registered without ConnectionRegistry
Toolkit::test(static function (): void {
$container = Container::of()
Expand Down
Loading