@@ -303,9 +303,21 @@ public function testGetRoutesByNames(): void
303303 ;
304304
305305 $ this ->candidatesMock
306+ ->expects ($ this ->exactly (4 ))
306307 ->method ('isCandidate ' )
307- ->withConsecutive (['/cms/routes/test-route ' ], ['/cms/simple/other-route ' ], ['/cms/routes/not-a-route ' ], ['/outside/prefix ' ])
308- ->willReturnOnConsecutiveCalls (true , true , true , false )
308+ ->willReturnCallback (function (string $ path ): bool {
309+ static $ expectedCalls = [
310+ ['/cms/routes/test-route ' , true ],
311+ ['/cms/simple/other-route ' , true ],
312+ ['/cms/routes/not-a-route ' , true ],
313+ ['/outside/prefix ' , false ],
314+ ];
315+
316+ [$ expectedPath , $ returnValue ] = array_shift ($ expectedCalls );
317+ $ this ->assertSame ($ expectedPath , $ path );
318+
319+ return $ returnValue ;
320+ })
309321 ;
310322
311323 $ paths [] = '/outside/prefix ' ;
@@ -331,9 +343,19 @@ public function testGetRoutesByNamesNotCandidates(): void
331343 ;
332344
333345 $ this ->candidatesMock
346+ ->expects ($ this ->exactly (3 ))
334347 ->method ('isCandidate ' )
335- ->withConsecutive (['/cms/routes/test-route ' ], ['/cms/simple/other-route ' ], ['/cms/routes/not-a-route ' ])
336- ->willReturn (false )
348+ ->willReturnCallback (function (string $ path ): bool {
349+ static $ expectedCalls = [
350+ '/cms/routes/test-route ' ,
351+ '/cms/simple/other-route ' ,
352+ '/cms/routes/not-a-route ' ,
353+ ];
354+
355+ $ this ->assertSame (array_shift ($ expectedCalls ), $ path );
356+
357+ return false ;
358+ })
337359 ;
338360
339361 $ routeProvider = new RouteProvider ($ this ->managerRegistryMock , $ this ->candidatesMock );
@@ -373,15 +395,39 @@ public function testGetRoutesByNamesUuid(): void
373395 ->willReturn ($ uow )
374396 ;
375397 $ uow
398+ ->expects ($ this ->exactly (2 ))
376399 ->method ('getDocumentId ' )
377- ->withConsecutive ([$ route1 ], [$ route2 ])
378- ->willReturnOnConsecutiveCalls ('/cms/routes/test-route ' , '/cms/routes/other-route ' )
400+ ->willReturnCallback (function ($ route ) use ($ route1 , $ route2 ): string {
401+ static $ expectedCalls = [];
402+
403+ if ([] === $ expectedCalls ) {
404+ $ expectedCalls = [
405+ [$ route1 , '/cms/routes/test-route ' ],
406+ [$ route2 , '/cms/routes/other-route ' ],
407+ ];
408+ }
409+
410+ [$ expectedRoute , $ returnValue ] = array_shift ($ expectedCalls );
411+ $ this ->assertSame ($ expectedRoute , $ route );
412+
413+ return $ returnValue ;
414+ })
379415 ;
380416
381417 $ this ->candidatesMock
418+ ->expects ($ this ->exactly (2 ))
382419 ->method ('isCandidate ' )
383- ->withConsecutive (['/cms/routes/test-route ' ], ['/cms/routes/other-route ' ])
384- ->willReturnOnConsecutiveCalls (true , false )
420+ ->willReturnCallback (function (string $ path ): bool {
421+ static $ expectedCalls = [
422+ ['/cms/routes/test-route ' , true ],
423+ ['/cms/routes/other-route ' , false ],
424+ ];
425+
426+ [$ expectedPath , $ returnValue ] = array_shift ($ expectedCalls );
427+ $ this ->assertSame ($ expectedPath , $ path );
428+
429+ return $ returnValue ;
430+ })
385431 ;
386432
387433 $ routeProvider = new RouteProvider ($ this ->managerRegistryMock , $ this ->candidatesMock );
0 commit comments