use Symfony\Component\Messenger\Stamp\DelayStamp;
use Symfony\Component\Messenger\Stamp\HandledStamp;
use Symfony\Component\Messenger\Tests\Fixtures\AnEnvelopeStamp;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
use Symfony\Component\Messenger\Tests\Fixtures\TestTracesWithHandleTraitAction;
use Symfony\Component\Messenger\TraceableMessageBus;
class TraceableMessageBusTest extends TestCase
{ public function testItTracesDispatch() { $message =
new DummyMessage('Hello'
);
$stamp =
new DelayStamp(5
);
$bus =
$this->
createMock(MessageBusInterface::
class);
$bus->
expects($this->
once())->
method('dispatch'
)->
with($message,
[$stamp])->
willReturn(new Envelope($message,
[$stamp]));
$traceableBus =
new TraceableMessageBus($bus);
$line = __LINE__ + 1;
$traceableBus->
dispatch($message,
[$stamp]);
$this->
assertCount(1,
$tracedMessages =
$traceableBus->
getDispatchedMessages());
$actualTracedMessage =
$tracedMessages[0
];
unset($actualTracedMessage['callTime'
]); // don't check, too variable