use Symfony\Component\Messenger\EventListener\StopWorkerOnCustomStopExceptionListener;
use Symfony\Component\Messenger\Exception\HandlerFailedException;
use Symfony\Component\Messenger\Exception\StopWorkerException;
use Symfony\Component\Messenger\Exception\StopWorkerExceptionInterface;
use Symfony\Component\Messenger\Worker;
class StopWorkerOnCustomStopExceptionListenerTest extends TestCase
{ public static function provideTests(): \Generator
{ yield 'it should not stop (1)' =>
[new \
Exception(), false
];
yield 'it should not stop (2)' =>
[new HandlerFailedException(new Envelope(new \
stdClass()),
[new \
Exception()]), false
];
$t =
new class() extends \Exception
implements StopWorkerExceptionInterface
{};
yield 'it should stop with custom exception' =>
[$t, true
];
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
];
}