You are here

public function RouteProviderTest::testMixedCasePaths in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::testMixedCasePaths()
  2. 9 core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::testMixedCasePaths()

Confirms that we find routes using a case-insensitive path match.

@dataProvider providerMixedCaseRoutePaths

File

core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php, line 233
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 testMixedCasePaths($path, $expected_route_name, $method = 'GET') {
  $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
    ->mixedCaseRouteCollection());
  $dumper
    ->dump();
  $request = Request::create($path, $method);
  $routes = $provider
    ->getRouteCollectionForRequest($request);
  if ($expected_route_name) {
    $this
      ->assertCount(1, $routes, 'The correct number of routes was found.');
    $this
      ->assertNotNull($routes
      ->get($expected_route_name), 'The first matching route was found.');
  }
  else {
    $this
      ->assertCount(0, $routes, 'No routes matched.');
  }
}