diff --git a/packages/Amqp/tests/Integration/AmqpMessageChannelTest.php b/packages/Amqp/tests/Integration/AmqpMessageChannelTest.php index fb56b0f11..3d4118a6d 100644 --- a/packages/Amqp/tests/Integration/AmqpMessageChannelTest.php +++ b/packages/Amqp/tests/Integration/AmqpMessageChannelTest.php @@ -121,17 +121,51 @@ public function test_using_amqp_channel_with_custom_queue_name() /** Message should be waiting in the queue */ $this->assertEquals([], $ecotoneLite->getQueryBus()->sendWithRouting('order.getOrders')); - $ecotoneLite->run('orders', ExecutionPollingMetadata::createWithDefaults()->withTestingSetup()); - /** Message should cosumed from the queue */ + $ecotoneLite->run($channelName, ExecutionPollingMetadata::createWithDefaults()->withTestingSetup()); + /** Message should be consumed from the queue */ $this->assertEquals(['milk'], $ecotoneLite->getQueryBus()->sendWithRouting('order.getOrders')); - $ecotoneLite->run('orders', ExecutionPollingMetadata::createWithDefaults()->withTestingSetup()); + $ecotoneLite->run($channelName, ExecutionPollingMetadata::createWithDefaults()->withTestingSetup()); /** Nothing should change, as we have not sent any new command message */ $this->assertEquals(['milk'], $ecotoneLite->getQueryBus()->sendWithRouting('order.getOrders')); $this->getRabbitConnectionFactory()->createContext()->purgeQueue(new AmqpQueue($queueName)); } + /** + * @depends test_using_amqp_channel_with_custom_queue_name + */ + public function test_using_amqp_channel_with_duplicated_queue_name() + { + $channelName = 'orders'; + $queueName = 'orders_queue'; + $this->getRabbitConnectionFactory()->createContext()->purgeQueue(new AmqpQueue($queueName)); + + $ecotoneLite = EcotoneLite::bootstrapForTesting( + [OrderService::class], + [ + new OrderService(), + AmqpConnectionFactory::class => $this->getCachedConnectionFactory(), + ], + ServiceConfiguration::createWithDefaults() + ->withSkippedModulePackageNames(ModulePackageList::allPackagesExcept([ModulePackageList::AMQP_PACKAGE, ModulePackageList::ASYNCHRONOUS_PACKAGE])) + ->withExtensionObjects([ + AmqpBackedMessageChannelBuilder::create( + channelName: $channelName, + queueName: $queueName, + ), + ]) + ); + + $ecotoneLite->getCommandBus()->sendWithRouting('order.register', 'milk'); + + $ecotoneLite->run($channelName, ExecutionPollingMetadata::createWithDefaults()->withTestingSetup()); + /** Message should be consumed from the queue */ + $this->assertEquals(['milk'], $ecotoneLite->getQueryBus()->sendWithRouting('order.getOrders')); + + $this->getRabbitConnectionFactory()->createContext()->purgeQueue(new AmqpQueue($queueName)); + } + public function test_failing_to_receive_message_when_not_declared() { $queueName = Uuid::uuid4()->toString();