function RouteProviderTest::testDuplicateRoutePaths

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

Confirms that we find all routes with the same path.

@dataProvider providerDuplicateRoutePaths

File

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

Class

RouteProviderTest
Confirm that the default route provider is working correctly.

Namespace

Drupal\KernelTests\Core\Routing

Code

public function testDuplicateRoutePaths($path, $number, $expected_route_name = NULL) {
    $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
        ->duplicatePathsRouteCollection());
    $dumper->dump();
    $request = Request::create($path);
    $routes = $provider->getRouteCollectionForRequest($request);
    $this->assertEquals($number, count($routes), 'The correct number of routes was found.');
    if ($expected_route_name) {
        $route_name = key(current($routes));
        $this->assertEquals($expected_route_name, $route_name, 'The expected route name was found.');
    }
}

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