diff --git a/src/DependencyInjection/BrefMessengerExtension.php b/src/DependencyInjection/BrefMessengerExtension.php index 728a31d..5d8c57e 100644 --- a/src/DependencyInjection/BrefMessengerExtension.php +++ b/src/DependencyInjection/BrefMessengerExtension.php @@ -21,9 +21,7 @@ public function prepend(ContainerBuilder $container): void $frameworkConfig = $container->getExtensionConfig('framework'); $messengerTransports = $this->getMessengerTransports($frameworkConfig); - if (! empty($messengerTransports)) { - $container->setParameter('messenger.transports', $messengerTransports); - } + $container->setParameter('messenger.transports', $messengerTransports); } private function getMessengerTransports(array $frameworkConfig): array diff --git a/tests/Unit/DependencyInjection/BrefMessengerExtensionTest.php b/tests/Unit/DependencyInjection/BrefMessengerExtensionTest.php index db8bade..255e934 100644 --- a/tests/Unit/DependencyInjection/BrefMessengerExtensionTest.php +++ b/tests/Unit/DependencyInjection/BrefMessengerExtensionTest.php @@ -210,52 +210,28 @@ public function providePrependSetsMessengerTransportsParameterCases(): iterable ], ], ]; - } - - /** - * @dataProvider provideDoesNotSetMessengerTransportsParameterCases - */ - public function testPrependDoesNotSetMessengerTransportsParameterWhenNoMessengerConfigExists( - array $config, - ): void { - $container = self::createMock(ContainerBuilder::class); - $container->method('getExtensionConfig') - ->with('framework') - ->willReturn($config); - - $container->expects(self::never())->method('setParameter'); - $extension = new BrefMessengerExtension; - $extension->prepend($container); - } - - public function provideDoesNotSetMessengerTransportsParameterCases(): iterable - { - yield 'empty config' => [ - 'config' => [], - ]; - - yield 'empty messenger config' => [ - 'config' => [ - 'messenger' => [], - ], - ]; - - yield 'not empty messenger config without transports key' => [ - 'config' => [ - 'messenger' => [ - 'busses' => [], + yield 'empty transports config when messenger only consuming messages' => [ + 'existConfig' => [ + [ + 'messenger' => [ + 'transports' => [], + ], ], ], + 'expectedTransportsParameter' => [], ]; - yield 'not empty messenger config with empty transports key' => [ - 'config' => [ - 'messenger' => [ - 'transports' => [], - 'busses' => [], + yield 'multiple messenger configs with empty transports key when messenger only consuming messages' => [ + 'existConfig' => [ + [ + 'messenger' => [ + 'transports' => [], + 'busses' => [], + ], ], ], + 'expectedTransportsParameter' => [], ]; } }