You are here

public function PagedRouteCollectionTest::testIteratingAndRewind in Zircon Profile 8

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

Tests the rewind method once the iterator is at the end.

File

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

Class

PagedRouteCollectionTest
Tests the page route collection.

Namespace

Symfony\Cmf\Component\Routing

Code

public function testIteratingAndRewind() {
  $routes = array();
  for ($i = 0; $i < 30; $i++) {
    $routes['test_' . $i] = new Route("/example-{$i}");
  }
  $this->routeProvider
    ->expects($this
    ->any())
    ->method('getRoutesPaged')
    ->will($this
    ->returnValueMap(array(
    array(
      0,
      10,
      array_slice($routes, 0, 10),
    ),
    array(
      10,
      10,
      array_slice($routes, 9, 10),
    ),
    array(
      20,
      10,
      array(),
    ),
  )));
  $routeCollection = new PagedRouteCollection($this->routeProvider, 10);

  // Force the iterating process.
  $routeCollection
    ->rewind();
  for ($i = 0; $i < 29; $i++) {
    $routeCollection
      ->next();
  }
  $routeCollection
    ->rewind();
  $this
    ->assertEquals('test_0', $routeCollection
    ->key());
  $this
    ->assertEquals($routes['test_0'], $routeCollection
    ->current());
}