You are here

public function RouteProviderTest::testGetRoutesPaged in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Tests/Routing/RouteProviderTest.php \Drupal\system\Tests\Routing\RouteProviderTest::testGetRoutesPaged()

Tests getRoutesPaged().

File

core/modules/system/src/Tests/Routing/RouteProviderTest.php, line 591
Contains \Drupal\system\Tests\Routing\RouteProviderTest.

Class

RouteProviderTest
Confirm that the default route provider is working correctly.

Namespace

Drupal\system\Tests\Routing

Code

public function testGetRoutesPaged() {
  $connection = Database::getConnection();
  $provider = new RouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
  $this->fixtures
    ->createTables($connection);
  $dumper = new MatcherDumper($connection, $this->state, 'test_routes');
  $dumper
    ->addRoutes($this->fixtures
    ->sampleRouteCollection());
  $dumper
    ->dump();
  $fixture_routes = $this->fixtures
    ->staticSampleRouteCollection();

  // Query all the routes.
  $routes = $provider
    ->getRoutesPaged(0);
  $this
    ->assertEqual(array_keys($routes), array_keys($fixture_routes));

  // Query non routes.
  $routes = $provider
    ->getRoutesPaged(0, 0);
  $this
    ->assertEqual(array_keys($routes), []);

  // Query a limited sets of routes.
  $routes = $provider
    ->getRoutesPaged(1, 2);
  $this
    ->assertEqual(array_keys($routes), array_slice(array_keys($fixture_routes), 1, 2));
}