function RouteProviderTest::testGetRoutesPaged

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::testGetRoutesPaged()

Tests getRoutesPaged().

File

core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php, line 709

Class

RouteProviderTest
Confirm that the default route provider is working correctly.

Namespace

Drupal\KernelTests\Core\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));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.