File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -57,18 +57,22 @@ protected function getStopwatch($events = [])
5757 $ events = \is_array ($ events ) ? $ events : [$ events ];
5858 $ stopwatch = $ this ->getMockBuilder ('Symfony\Component\Stopwatch\Stopwatch ' )->getMock ();
5959
60- $ i = -1 ;
60+ $ expectedCalls = 0 ;
61+ $ expectedStartCalls = [];
62+ $ expectedStopCalls = [];
6163 foreach ($ events as $ eventName ) {
62- $ stopwatch ->expects ($ this ->at (++$ i ))
63- ->method ('start ' )
64- ->with ($ this ->equalTo ($ eventName ), 'template ' )
65- ;
66- $ stopwatch ->expects ($ this ->at (++$ i ))
67- ->method ('stop ' )
68- ->with ($ this ->equalTo ($ eventName ))
69- ;
64+ ++$ expectedCalls ;
65+ $ expectedStartCalls [] = [$ this ->equalTo ($ eventName ), 'template ' ];
66+ $ expectedStopCalls [] = [$ this ->equalTo ($ eventName )];
7067 }
7168
69+ $ startInvocationMocker = $ stopwatch ->expects ($ this ->exactly ($ expectedCalls ))
70+ ->method ('start ' );
71+ \call_user_func_array ([$ startInvocationMocker , 'withConsecutive ' ], $ expectedStartCalls );
72+ $ stopInvocationMocker = $ stopwatch ->expects ($ this ->exactly ($ expectedCalls ))
73+ ->method ('stop ' );
74+ \call_user_func_array ([$ stopInvocationMocker , 'withConsecutive ' ], $ expectedStopCalls );
75+
7276 return $ stopwatch ;
7377 }
7478}
You can’t perform that action at this time.
0 commit comments