Skip to content

Commit

Permalink
Merge pull request #259 from andypost/phpunit-at
Browse files Browse the repository at this point in the history
Remove calls to deprecated TestCase::at()
  • Loading branch information
dbu authored Oct 6, 2020
2 parents dc6fe49 + 5fd5c0f commit 81fcbf7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testRouteEnhancerPass()

$builder = $this->createMock(ContainerBuilder::class);
$definition = new Definition('router');
$builder->expects($this->at(0))
$builder->expects($this->atLeastOnce())
->method('hasDefinition')
->with('cmf_routing.dynamic_router')
->will($this->returnValue(true))
Expand Down
20 changes: 5 additions & 15 deletions tests/Unit/Routing/ChainRouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,12 @@ public function testReSortRouters()
->setMethods(['sortRouters'])
->getMock();
$router
->expects($this->at(0))
->expects($this->exactly(2))
->method('sortRouters')
->will(
$this->returnValue(
[$high, $medium, $low]
)
)
;
// The second time sortRouters() is called, we're supposed to get the newly added router ($highest)
$router
->expects($this->at(1))
->method('sortRouters')
->will(
$this->returnValue(
[$highest, $high, $medium, $low]
)
->willReturnOnConsecutiveCalls(
[$high, $medium, $low],
// The second time sortRouters() is called, we're supposed to get the newly added router ($highest)
[$highest, $high, $medium, $low]
)
;

Expand Down
12 changes: 8 additions & 4 deletions tests/Unit/Routing/PagedRouteCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ public function testIterator($amountRoutes, $routesLoadedInParallel, $expectedCa
}
$names = array_keys($routes);

$with = [];
$will = [];
foreach ($expectedCalls as $i => $range) {
$this->routeProvider->expects($this->at($i))
->method('getRoutesPaged')
->with($range[0], $range[1])
->will($this->returnValue(array_slice($routes, $range[0], $range[1])));
$with[] = [$range[0], $range[1]];
$will[] = array_slice($routes, $range[0], $range[1]);
}
$mocker = $this->routeProvider->expects($this->exactly(\count($expectedCalls)))
->method('getRoutesPaged');
\call_user_func_array([$mocker, 'withConsecutive'], $with);
\call_user_func_array([$mocker, 'willReturnOnConsecutiveCalls'], $will);

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

Expand Down

0 comments on commit 81fcbf7

Please sign in to comment.