@@ -137,14 +137,10 @@ public function testCreateFromChoicesSameValueClosure()
137137 $ list2 = new ArrayChoiceList ([]);
138138 $ closure = function () {};
139139
140- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
141- ->method ('createListFromChoices ' )
142- ->with ($ choices , $ closure )
143- ->willReturn ($ list1 );
144- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
140+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
145141 ->method ('createListFromChoices ' )
146142 ->with ($ choices , $ closure )
147- ->willReturn ( $ list2 );
143+ ->willReturnOnConsecutiveCalls ( $ list1 , $ list2 );
148144
149145 $ this ->assertSame ($ list1 , $ this ->factory ->createListFromChoices ($ choices , $ closure ));
150146 $ this ->assertSame ($ list2 , $ this ->factory ->createListFromChoices ($ choices , $ closure ));
@@ -194,14 +190,10 @@ public function testCreateFromChoicesSameFilterClosure()
194190 $ list2 = new ArrayChoiceList ([]);
195191 $ filter = function () {};
196192
197- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
198- ->method ('createListFromChoices ' )
199- ->with ($ choices , null , $ filter )
200- ->willReturn ($ list1 );
201- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
193+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
202194 ->method ('createListFromChoices ' )
203195 ->with ($ choices , null , $ filter )
204- ->willReturn ( $ list2 );
196+ ->willReturnOnConsecutiveCalls ( $ list1 , $ list2 );
205197
206198 $ this ->assertSame ($ list1 , $ this ->factory ->createListFromChoices ($ choices , null , $ filter ));
207199 $ this ->assertSame ($ list2 , $ this ->factory ->createListFromChoices ($ choices , null , $ filter ));
@@ -232,14 +224,13 @@ public function testCreateFromChoicesDifferentFilterClosure()
232224 $ closure1 = function () {};
233225 $ closure2 = function () {};
234226
235- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
236- ->method ('createListFromChoices ' )
237- ->with ($ choices , null , $ closure1 )
238- ->willReturn ($ list1 );
239- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
227+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
240228 ->method ('createListFromChoices ' )
241- ->with ($ choices , null , $ closure2 )
242- ->willReturn ($ list2 );
229+ ->withConsecutive (
230+ [$ choices , null , $ closure1 ],
231+ [$ choices , null , $ closure2 ]
232+ )
233+ ->willReturnOnConsecutiveCalls ($ list1 , $ list2 );
243234
244235 $ this ->assertSame ($ list1 , $ this ->factory ->createListFromChoices ($ choices , null , $ closure1 ));
245236 $ this ->assertSame ($ list2 , $ this ->factory ->createListFromChoices ($ choices , null , $ closure2 ));
@@ -251,16 +242,10 @@ public function testCreateFromLoaderSameLoader()
251242 $ list = new ArrayChoiceList ([]);
252243 $ list2 = new ArrayChoiceList ([]);
253244
254- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
255- ->method ('createListFromLoader ' )
256- ->with ($ loader )
257- ->willReturn ($ list )
258- ;
259- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
245+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
260246 ->method ('createListFromLoader ' )
261247 ->with ($ loader )
262- ->willReturn ($ list2 )
263- ;
248+ ->willReturnOnConsecutiveCalls ($ list , $ list2 );
264249
265250 $ this ->assertSame ($ list , $ this ->factory ->createListFromLoader ($ loader ));
266251 $ this ->assertSame ($ list2 , $ this ->factory ->createListFromLoader ($ loader ));
@@ -309,16 +294,10 @@ public function testCreateFromLoaderSameValueClosure()
309294 $ list2 = new ArrayChoiceList ([]);
310295 $ closure = function () {};
311296
312- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
313- ->method ('createListFromLoader ' )
314- ->with ($ loader , $ closure )
315- ->willReturn ($ list )
316- ;
317- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
297+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
318298 ->method ('createListFromLoader ' )
319299 ->with ($ loader , $ closure )
320- ->willReturn ($ list2 )
321- ;
300+ ->willReturnOnConsecutiveCalls ($ list , $ list2 );
322301
323302 $ this ->assertSame ($ list , $ this ->factory ->createListFromLoader (ChoiceList::loader ($ type , $ loader ), $ closure ));
324303 $ this ->assertSame ($ list2 , $ this ->factory ->createListFromLoader (ChoiceList::loader ($ type , $ this ->createMock (ChoiceLoaderInterface::class)), $ closure ));
@@ -376,16 +355,10 @@ public function testCreateFromLoaderSameFilterClosure()
376355 $ list2 = new ArrayChoiceList ([]);
377356 $ closure = function () {};
378357
379- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
380- ->method ('createListFromLoader ' )
381- ->with ($ loader , null , $ closure )
382- ->willReturn ($ list )
383- ;
384- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
358+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
385359 ->method ('createListFromLoader ' )
386360 ->with ($ loader , null , $ closure )
387- ->willReturn ($ list2 )
388- ;
361+ ->willReturnOnConsecutiveCalls ($ list , $ list2 );
389362
390363 $ this ->assertSame ($ list , $ this ->factory ->createListFromLoader (ChoiceList::loader ($ type , $ loader ), null , $ closure ));
391364 $ this ->assertSame ($ list2 , $ this ->factory ->createListFromLoader (ChoiceList::loader ($ type , $ this ->createMock (ChoiceLoaderInterface::class)), null , $ closure ));
@@ -425,14 +398,13 @@ public function testCreateFromLoaderDifferentFilterClosure()
425398 $ closure1 = function () {};
426399 $ closure2 = function () {};
427400
428- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
429- ->method ('createListFromLoader ' )
430- ->with ($ loader , null , $ closure1 )
431- ->willReturn ($ list1 );
432- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
401+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
433402 ->method ('createListFromLoader ' )
434- ->with ($ loader , null , $ closure2 )
435- ->willReturn ($ list2 );
403+ ->withConsecutive (
404+ [$ loader , null , $ closure1 ],
405+ [$ loader , null , $ closure2 ]
406+ )
407+ ->willReturnOnConsecutiveCalls ($ list1 , $ list2 );
436408
437409 $ this ->assertSame ($ list1 , $ this ->factory ->createListFromLoader (ChoiceList::loader ($ type , $ loader ), null , $ closure1 ));
438410 $ this ->assertSame ($ list2 , $ this ->factory ->createListFromLoader (ChoiceList::loader ($ type , $ this ->createMock (ChoiceLoaderInterface::class)), null , $ closure2 ));
@@ -445,16 +417,10 @@ public function testCreateViewSamePreferredChoices()
445417 $ view = new ChoiceListView ();
446418 $ view2 = new ChoiceListView ();
447419
448- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
449- ->method ('createView ' )
450- ->with ($ list , $ preferred )
451- ->willReturn ($ view )
452- ;
453- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
420+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
454421 ->method ('createView ' )
455422 ->with ($ list , $ preferred )
456- ->willReturn ($ view2 )
457- ;
423+ ->willReturnOnConsecutiveCalls ($ view , $ view2 );
458424
459425 $ this ->assertSame ($ view , $ this ->factory ->createView ($ list , $ preferred ));
460426 $ this ->assertSame ($ view2 , $ this ->factory ->createView ($ list , $ preferred ));
@@ -504,16 +470,10 @@ public function testCreateViewSamePreferredChoicesClosure()
504470 $ view = new ChoiceListView ();
505471 $ view2 = new ChoiceListView ();
506472
507- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
508- ->method ('createView ' )
509- ->with ($ list , $ preferred )
510- ->willReturn ($ view )
511- ;
512- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
473+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
513474 ->method ('createView ' )
514475 ->with ($ list , $ preferred )
515- ->willReturn ($ view2 )
516- ;
476+ ->willReturnOnConsecutiveCalls ($ view , $ view2 );
517477
518478 $ this ->assertSame ($ view , $ this ->factory ->createView ($ list , $ preferred ));
519479 $ this ->assertSame ($ view2 , $ this ->factory ->createView ($ list , $ preferred ));
@@ -563,16 +523,10 @@ public function testCreateViewSameLabelClosure()
563523 $ view = new ChoiceListView ();
564524 $ view2 = new ChoiceListView ();
565525
566- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
567- ->method ('createView ' )
568- ->with ($ list , null , $ labels )
569- ->willReturn ($ view )
570- ;
571- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
526+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
572527 ->method ('createView ' )
573528 ->with ($ list , null , $ labels )
574- ->willReturn ($ view2 )
575- ;
529+ ->willReturnOnConsecutiveCalls ($ view , $ view2 );
576530
577531 $ this ->assertSame ($ view , $ this ->factory ->createView ($ list , null , $ labels ));
578532 $ this ->assertSame ($ view2 , $ this ->factory ->createView ($ list , null , $ labels ));
@@ -622,16 +576,10 @@ public function testCreateViewSameIndexClosure()
622576 $ view = new ChoiceListView ();
623577 $ view2 = new ChoiceListView ();
624578
625- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
626- ->method ('createView ' )
627- ->with ($ list , null , null , $ index )
628- ->willReturn ($ view )
629- ;
630- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
579+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
631580 ->method ('createView ' )
632581 ->with ($ list , null , null , $ index )
633- ->willReturn ($ view2 )
634- ;
582+ ->willReturnOnConsecutiveCalls ($ view , $ view2 );
635583
636584 $ this ->assertSame ($ view , $ this ->factory ->createView ($ list , null , null , $ index ));
637585 $ this ->assertSame ($ view2 , $ this ->factory ->createView ($ list , null , null , $ index ));
@@ -681,16 +629,10 @@ public function testCreateViewSameGroupByClosure()
681629 $ view = new ChoiceListView ();
682630 $ view2 = new ChoiceListView ();
683631
684- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
685- ->method ('createView ' )
686- ->with ($ list , null , null , null , $ groupBy )
687- ->willReturn ($ view )
688- ;
689- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
632+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
690633 ->method ('createView ' )
691634 ->with ($ list , null , null , null , $ groupBy )
692- ->willReturn ($ view2 )
693- ;
635+ ->willReturnOnConsecutiveCalls ($ view , $ view2 );
694636
695637 $ this ->assertSame ($ view , $ this ->factory ->createView ($ list , null , null , null , $ groupBy ));
696638 $ this ->assertSame ($ view2 , $ this ->factory ->createView ($ list , null , null , null , $ groupBy ));
@@ -740,16 +682,10 @@ public function testCreateViewSameAttributes()
740682 $ view = new ChoiceListView ();
741683 $ view2 = new ChoiceListView ();
742684
743- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
744- ->method ('createView ' )
745- ->with ($ list , null , null , null , null , $ attr )
746- ->willReturn ($ view )
747- ;
748- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
685+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
749686 ->method ('createView ' )
750687 ->with ($ list , null , null , null , null , $ attr )
751- ->willReturn ($ view2 )
752- ;
688+ ->willReturnOnConsecutiveCalls ($ view , $ view2 );
753689
754690 $ this ->assertSame ($ view , $ this ->factory ->createView ($ list , null , null , null , null , $ attr ));
755691 $ this ->assertSame ($ view2 , $ this ->factory ->createView ($ list , null , null , null , null , $ attr ));
@@ -798,16 +734,10 @@ public function testCreateViewSameAttributesClosure()
798734 $ view = new ChoiceListView ();
799735 $ view2 = new ChoiceListView ();
800736
801- $ this ->decoratedFactory ->expects ($ this ->at (0 ))
802- ->method ('createView ' )
803- ->with ($ list , null , null , null , null , $ attr )
804- ->willReturn ($ view )
805- ;
806- $ this ->decoratedFactory ->expects ($ this ->at (1 ))
737+ $ this ->decoratedFactory ->expects ($ this ->exactly (2 ))
807738 ->method ('createView ' )
808739 ->with ($ list , null , null , null , null , $ attr )
809- ->willReturn ($ view2 )
810- ;
740+ ->willReturnOnConsecutiveCalls ($ view , $ view2 );
811741
812742 $ this ->assertSame ($ view , $ this ->factory ->createView ($ list , null , null , null , null , $ attr ));
813743 $ this ->assertSame ($ view2 , $ this ->factory ->createView ($ list , null , null , null , null , $ attr ));
0 commit comments