yield 'it should stop with core exception' =>
[new StopWorkerException(), true
];
yield 'it should stop with custom exception wrapped (1)' =>
[new HandlerFailedException(new Envelope(new \
stdClass()),
[new StopWorkerException()]), true
];
yield 'it should stop with custom exception wrapped (2)' =>
[new HandlerFailedException(new Envelope(new \
stdClass()),
[new \
Exception(),
new StopWorkerException()]), true
];
yield 'it should stop with core exception wrapped (1)' =>
[new HandlerFailedException(new Envelope(new \
stdClass()),
[$t]), true
];
yield 'it should stop with core exception wrapped (2)' =>
[new HandlerFailedException(new Envelope(new \
stdClass()),
[new \
Exception(),
$t]), true
];
} /** @dataProvider provideTests */
public function test(\Throwable
$throwable, bool
$shouldStop) { $listener =
new StopWorkerOnCustomStopExceptionListener();
$envelope =
new Envelope(new \
stdClass());
$failedEvent =
new WorkerMessageFailedEvent($envelope, 'my_receiver',
$throwable);
$listener->
onMessageFailed($failedEvent);
$worker =
$this->
createMock(Worker::
class);
$worker->
expects($shouldStop ?
$this->
once() :
$this->
never())->
method('stop'
);
$runningEvent =
new WorkerRunningEvent($worker, false
);
$listener->
onWorkerRunning($runningEvent);
}