@@ -172,12 +172,12 @@ public function testCloseJob()
172172 $ this ->em ->persist ($ b );
173173 $ this ->em ->flush ();
174174
175- $ this ->dispatcher ->expects ($ this -> at ( 0 ))
175+ $ this ->dispatcher ->expects (self :: exactly ( 2 ))
176176 ->method ('dispatch ' )
177- ->with ( new StateChangeEvent ( $ a , ' terminated ' ), ' jms_job_queue.job_state_change ' );
178- $ this -> dispatcher -> expects ( $ this -> at ( 1 ))
179- -> method ( ' dispatch ' )
180- -> with ( new StateChangeEvent ( $ b , ' canceled ' ), ' jms_job_queue.job_state_change ' );
177+ ->withConsecutive (
178+ [ new StateChangeEvent ( $ a , ' terminated ' ), ' jms_job_queue.job_state_change ' ],
179+ [ new StateChangeEvent ( $ b , ' canceled ' ), ' jms_job_queue.job_state_change ' ],
180+ );
181181
182182 $ this ->assertEquals ('running ' , $ a ->getState ());
183183 $ this ->assertEquals ('pending ' , $ b ->getState ());
@@ -197,13 +197,12 @@ public function testCloseJobDoesNotCreateRetryJobsWhenCanceled()
197197 $ this ->em ->persist ($ b );
198198 $ this ->em ->flush ();
199199
200- $ this ->dispatcher ->expects ($ this ->at (0 ))
201- ->method ('dispatch ' )
202- ->with (new StateChangeEvent ($ a , 'canceled ' ), 'jms_job_queue.job_state_change ' );
203-
204- $ this ->dispatcher ->expects ($ this ->at (1 ))
200+ $ this ->dispatcher ->expects (self ::exactly (2 ))
205201 ->method ('dispatch ' )
206- ->with (new StateChangeEvent ($ b , 'canceled ' ), 'jms_job_queue.job_state_change ' );
202+ ->withConsecutive (
203+ [new StateChangeEvent ($ a , 'canceled ' ), 'jms_job_queue.job_state_change ' ],
204+ [new StateChangeEvent ($ b , 'canceled ' ), 'jms_job_queue.job_state_change ' ],
205+ );
207206
208207 $ this ->jobManager ->closeJob ($ a , 'canceled ' );
209208 $ this ->assertEquals ('canceled ' , $ a ->getState ());
@@ -220,15 +219,13 @@ public function testCloseJobDoesNotCreateMoreThanAllowedRetries()
220219 $ this ->em ->persist ($ a );
221220 $ this ->em ->flush ();
222221
223- $ this ->dispatcher ->expects ($ this ->at (0 ))
224- ->method ('dispatch ' )
225- ->with (new StateChangeEvent ($ a , 'failed ' ), 'jms_job_queue.job_state_change ' );
226- $ this ->dispatcher ->expects ($ this ->at (1 ))
227- ->method ('dispatch ' )
228- ->with (new LogicalNot ($ this ->equalTo (new StateChangeEvent ($ a , 'failed ' ))), 'jms_job_queue.job_state_change ' );
229- $ this ->dispatcher ->expects ($ this ->at (2 ))
222+ $ this ->dispatcher ->expects (self ::exactly (3 ))
230223 ->method ('dispatch ' )
231- ->with (new LogicalNot ($ this ->equalTo (new StateChangeEvent ($ a , 'failed ' ))), 'jms_job_queue.job_state_change ' );
224+ ->withConsecutive (
225+ [new StateChangeEvent ($ a , 'failed ' ), 'jms_job_queue.job_state_change ' ],
226+ [new LogicalNot ($ this ->equalTo (new StateChangeEvent ($ a , 'failed ' ))), 'jms_job_queue.job_state_change ' ],
227+ [new LogicalNot ($ this ->equalTo (new StateChangeEvent ($ a , 'failed ' ))), 'jms_job_queue.job_state_change ' ],
228+ );
232229
233230 $ this ->assertCount (0 , $ a ->getRetryJobs ());
234231 $ this ->jobManager ->closeJob ($ a , 'failed ' );
0 commit comments