$dispatcher->
removeListener(WorkerMessageFailedEvent::
class,
$failedListener);
return $throwable;
};
// send the message
$envelope =
new Envelope(new DummyMessage('API'
));
$bus->
dispatch($envelope);
// message has been sent
$this->
assertCount(1,
$transport1->
getMessagesWaitingToBeReceived());
$this->
assertCount(1,
$transport2->
getMessagesWaitingToBeReceived());
$this->
assertCount(0,
$failureTransport->
getMessagesWaitingToBeReceived());
// receive the message - one handler will fail and the message
// will be sent back to transport1 to be retried
/*
* Receive the message from "transport1"
*/
$throwable =
$runWorker('transport1'
);
// make sure this is failing for the reason we think
$this->
assertInstanceOf(HandlerFailedException::
class,
$throwable);