Skip to content

Commit

Permalink
Merge 3195118 into dc11578
Browse files Browse the repository at this point in the history
  • Loading branch information
fmasa committed Jul 9, 2020
2 parents dc11578 + 3195118 commit 6736ae7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Messenger/DI/MessengerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ private function processBuses() : void
->setFactory(HandleMessageMiddleware::class, [$handlersLocator, $busConfig->allowNoHandlers]);

$builder->addDefinition($this->prefix($busName . '.bus'))
->setFactory(MessageBus::class, [$middleware]);
->setFactory(MessageBus::class, [$middleware])
->setTags([self::TAG_BUS_NAME => $busName]);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/Messenger/Transport/TaggedServiceLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function __construct(string $tagName, Container $container, ?string $defa
}

/**
* @param string $id
* @return object
*/
public function get($id)
Expand Down
13 changes: 13 additions & 0 deletions tests/DI/MessengerExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\RoutableMessageBus;
use Symfony\Component\Messenger\Stamp\HandledStamp;
use Symfony\Component\Messenger\Stamp\SentStamp;
use function array_map;
Expand Down Expand Up @@ -217,6 +218,18 @@ public function testCustomDefaultSerializerIsPassedToSenderWhen() : void
);
}

public function testBusLocatorReturnsCorrectBuses() : void
{
$container = $this->getContainer(__DIR__ . '/busLocator.neon');

$busLocator = $container->getService('messenger.busLocator');
assert($busLocator instanceof RoutableMessageBus);

foreach (['a', 'b', 'c'] as $busName) {
$this->assertSame($container->getService('messenger.' . $busName . '.bus'), $busLocator->getMessageBus($busName));
}
}

/**
* @param string[] $expectedResults
*/
Expand Down
10 changes: 10 additions & 0 deletions tests/DI/busLocator.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
messenger:
buses:
a:
b:
c:

services:
- Fixtures\CustomTransport
- class: Fixtures\CustomTransportFactory
tags: [messenger.transportFactory]

0 comments on commit 6736ae7

Please sign in to comment.