minor #28336 [Messenger] Ensure the tests and implementation matches the PR #28190 (sroze)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Messenger] Ensure the tests and implementation matches the PR #28190

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #28190
| License       | MIT
| Doc PR        | ø

And we should have master green.

Commits
-------

ba6248546a Ensure the tests and implementation matches the merged #28190 PR
This commit is contained in:
Nicolas Grekas 2018-09-02 19:00:56 +02:00
commit c6ac2a42a6
2 changed files with 14 additions and 4 deletions

View File

@ -69,7 +69,7 @@ class MessengerPass implements CompilerPassInterface
}
}
$this->registerReceivers($container);
$this->registerReceivers($container, $busIds);
$this->registerSenders($container);
$this->registerHandlers($container, $busIds);
}
@ -232,7 +232,7 @@ class MessengerPass implements CompilerPassInterface
return array((string) $parameters[0]->getType());
}
private function registerReceivers(ContainerBuilder $container)
private function registerReceivers(ContainerBuilder $container, array $busIds)
{
$receiverMapping = array();
@ -256,7 +256,15 @@ class MessengerPass implements CompilerPassInterface
foreach ($receiverMapping as $name => $reference) {
$receiverNames[(string) $reference] = $name;
}
$container->getDefinition('console.command.messenger_consume_messages')->replaceArgument(3, array_values($receiverNames));
$buses = array();
foreach ($busIds as $busId) {
$buses[$busId] = new Reference($busId);
}
$container->getDefinition('console.command.messenger_consume_messages')
->replaceArgument(0, ServiceLocatorTagPass::register($container, $buses))
->replaceArgument(3, array_values($receiverNames))
->replaceArgument(4, $busIds);
}
$container->getDefinition('messenger.receiver_locator')->replaceArgument(0, $receiverMapping);

View File

@ -241,10 +241,11 @@ class MessengerPassTest extends TestCase
{
$container = $this->getContainerBuilder();
$container->register('console.command.messenger_consume_messages', ConsumeMessagesCommand::class)->setArguments(array(
new Reference('message_bus'),
null,
new Reference('messenger.receiver_locator'),
null,
null,
null,
));
$container->register(AmqpReceiver::class, AmqpReceiver::class)->addTag('messenger.receiver', array('alias' => 'amqp'));
@ -253,6 +254,7 @@ class MessengerPassTest extends TestCase
(new MessengerPass())->process($container);
$this->assertSame(array('amqp', 'dummy'), $container->getDefinition('console.command.messenger_consume_messages')->getArgument(3));
$this->assertSame(array('message_bus'), $container->getDefinition('console.command.messenger_consume_messages')->getArgument(4));
}
public function testItRegistersSenders()