Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
createFailedEvent example
class
StopWorkerOnFailureLimitListenerTest
extends
TestCase
{
/** * @dataProvider countProvider */
public
function
testWorkerStopsWhenMaximumCountReached
(
int
$max
, bool
$shouldStop
)
{
$worker
=
$this
->
createMock
(
Worker::
class
)
;
$worker
->
expects
(
$shouldStop
?
$this
->
atLeastOnce
(
)
:
$this
->
never
(
)
)
->
method
(
'stop'
)
;
$failedEvent
=
$this
->
createFailedEvent
(
)
;
$runningEvent
=
new
WorkerRunningEvent
(
$worker
, false
)
;
$failureLimitListener
=
new
StopWorkerOnFailureLimitListener
(
$max
)
;
// simulate three messages (of which 2 failed)
$failureLimitListener
->
onMessageFailed
(
$failedEvent
)
;
$failureLimitListener
->
onWorkerRunning
(
$runningEvent
)
;
$failureLimitListener
->
onWorkerRunning
(
$runningEvent
)
;
$failureLimitListener
->
onMessageFailed
(
$failedEvent
)
;
$failureLimitListener
->
onWorkerRunning
(
$runningEvent
)
;
}