function RouteProviderTest::testMixedCasePaths

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::testMixedCasePaths()
  2. 10 core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::testMixedCasePaths()
  3. 11.x 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 231

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.');
    }
}

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