You are here

public function RouteProviderTest::testDuplicateRoutePaths in Drupal 9

Same name and namespace in other branches
  1. 8 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()

Confirms that we find all routes with the same path.

@dataProvider providerDuplicateRoutePaths

File

core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php, line 277
Contains \Drupal\KernelTests\Core\Routing\RouteProviderTest.

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
    ->assertCount($number, $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.');
  }
}