You are here

public function PagedRouteCollectionTest::testIterator in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony-cmf/routing/Tests/Routing/PagedRouteCollectionTest.php \Symfony\Cmf\Component\Routing\PagedRouteCollectionTest::testIterator()

Tests iterating a small amount of routes.

@dataProvider providerIterator

File

vendor/symfony-cmf/routing/Tests/Routing/PagedRouteCollectionTest.php, line 41

Class

PagedRouteCollectionTest
Tests the page route collection.

Namespace

Symfony\Cmf\Component\Routing

Code

public function testIterator($amountRoutes, $routesLoadedInParallel, $expectedCalls = array()) {
  $routes = array();
  for ($i = 0; $i < $amountRoutes; $i++) {
    $routes['test_' . $i] = new Route("/example-{$i}");
  }
  $names = array_keys($routes);
  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])));
  }
  $route_collection = new PagedRouteCollection($this->routeProvider, $routesLoadedInParallel);
  $counter = 0;
  foreach ($route_collection as $route_name => $route) {

    // Ensure the route did not changed.
    $this
      ->assertEquals($routes[$route_name], $route);

    // Ensure that the order did not changed.
    $this
      ->assertEquals($route_name, $names[$counter]);
    $counter++;
  }
}