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 = [])
57
57
$ events = \is_array ($ events ) ? $ events : [$ events ];
58
58
$ stopwatch = $ this ->getMockBuilder ('Symfony\Component\Stopwatch\Stopwatch ' )->getMock ();
59
59
60
- $ i = -1 ;
60
+ $ expectedCalls = 0 ;
61
+ $ expectedStartCalls = [];
62
+ $ expectedStopCalls = [];
61
63
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 )];
70
67
}
71
68
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
+
72
76
return $ stopwatch ;
73
77
}
74
78
}
You can’t perform that action at this time.
0 commit comments