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
$this->
assertEquals([ 'message' =>
$message,
'stamps' =>
[$stamp],
'stamps_after_dispatch' =>
[$stamp],
'caller' =>
[ 'name' => 'TraceableMessageBusTest.php',