Skip to content

Commit 5fd5c0f

Browse files
committed
Remove calls to deprecated TestCase::at()
Ref to sebastianbergmann/phpunit#4297
1 parent dc6fe49 commit 5fd5c0f

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

tests/Unit/DependencyInjection/Compiler/RegisterRouteEnhancersPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testRouteEnhancerPass()
3030

3131
$builder = $this->createMock(ContainerBuilder::class);
3232
$definition = new Definition('router');
33-
$builder->expects($this->at(0))
33+
$builder->expects($this->atLeastOnce())
3434
->method('hasDefinition')
3535
->with('cmf_routing.dynamic_router')
3636
->will($this->returnValue(true))

tests/Unit/Routing/ChainRouterTest.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,12 @@ public function testReSortRouters()
130130
->setMethods(['sortRouters'])
131131
->getMock();
132132
$router
133-
->expects($this->at(0))
133+
->expects($this->exactly(2))
134134
->method('sortRouters')
135-
->will(
136-
$this->returnValue(
137-
[$high, $medium, $low]
138-
)
139-
)
140-
;
141-
// The second time sortRouters() is called, we're supposed to get the newly added router ($highest)
142-
$router
143-
->expects($this->at(1))
144-
->method('sortRouters')
145-
->will(
146-
$this->returnValue(
147-
[$highest, $high, $medium, $low]
148-
)
135+
->willReturnOnConsecutiveCalls(
136+
[$high, $medium, $low],
137+
// The second time sortRouters() is called, we're supposed to get the newly added router ($highest)
138+
[$highest, $high, $medium, $low]
149139
)
150140
;
151141

tests/Unit/Routing/PagedRouteCollectionTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@ public function testIterator($amountRoutes, $routesLoadedInParallel, $expectedCa
4747
}
4848
$names = array_keys($routes);
4949

50+
$with = [];
51+
$will = [];
5052
foreach ($expectedCalls as $i => $range) {
51-
$this->routeProvider->expects($this->at($i))
52-
->method('getRoutesPaged')
53-
->with($range[0], $range[1])
54-
->will($this->returnValue(array_slice($routes, $range[0], $range[1])));
53+
$with[] = [$range[0], $range[1]];
54+
$will[] = array_slice($routes, $range[0], $range[1]);
5555
}
56+
$mocker = $this->routeProvider->expects($this->exactly(\count($expectedCalls)))
57+
->method('getRoutesPaged');
58+
\call_user_func_array([$mocker, 'withConsecutive'], $with);
59+
\call_user_func_array([$mocker, 'willReturnOnConsecutiveCalls'], $will);
5660

5761
$route_collection = new PagedRouteCollection($this->routeProvider, $routesLoadedInParallel);
5862

0 commit comments

Comments
 (0)