use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\RoutableMessageBus;
use Symfony\Component\Messenger\Stamp\BusNameStamp;
use Symfony\Component\Messenger\Stamp\DelayStamp;
class RoutableMessageBusTest extends TestCase
{ public function testItRoutesToTheCorrectBus() { $envelope =
new Envelope(new \
stdClass(),
[new BusNameStamp('foo_bus'
)]);
$bus1 =
$this->
createMock(MessageBusInterface::
class);
$bus2 =
$this->
createMock(MessageBusInterface::
class);
$container =
$this->
createMock(ContainerInterface::
class);
$container->
expects($this->
once())->
method('has'
)->
with('foo_bus'
)->
willReturn(true
);
$container->
expects($this->
once())->
method('get'
)->
willReturn($bus2);
$stamp =
new DelayStamp(5
);
$bus1->
expects($this->
never())->
method('dispatch'
);
$bus2->
expects($this->
once())->
method('dispatch'
)->
with($envelope,
[$stamp])->
willReturn($envelope);