function RouteProviderTest::testGetAllRoutes

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

Confirms RouteProvider::getAllRoutes() extracts information correctly from the database.

File

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

Class

RouteProviderTest
Confirm that the default route provider is working correctly.

Namespace

Drupal\KernelTests\Core\Routing

Code

public function testGetAllRoutes() : void {
    $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, $this->logger, 'test_routes');
    $dumper->addRoutes($this->fixtures
        ->SampleRouteCollection());
    $dumper->dump();
    $sample_routes = $this->fixtures
        ->staticSampleRouteCollection();
    $returned_routes = $provider->getAllRoutes();
    $this->assertInstanceOf(\Iterator::class, $returned_routes);
    $this->assertSameSize($sample_routes, $returned_routes);
    foreach ($returned_routes as $route_name => $route) {
        $this->assertArrayHasKey($route_name, $sample_routes);
        $this->assertEquals($route->getPath(), $sample_routes[$route_name]['path']);
    }
}

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