function RouteProviderTest::testOutlinePathMatchTrailingSlash

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

Confirms that a trailing slash on the request does not result in a 404.

File

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

Class

RouteProviderTest
Confirm that the default route provider is working correctly.

Namespace

Drupal\KernelTests\Core\Routing

Code

public function testOutlinePathMatchTrailingSlash() {
    $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
        ->complexRouteCollection());
    $dumper->dump();
    $path = '/path/1/one/';
    $request = Request::create($path, 'GET');
    $routes = $provider->getRouteCollectionForRequest($request);
    // All of the matching paths have the correct pattern.
    foreach ($routes as $route) {
        $this->assertEqual($route->compile()
            ->getPatternOutline(), '/path/%/one', 'Found path has correct pattern');
    }
    $this->assertCount(2, $routes, 'The correct number of routes was found.');
    $this->assertNotNull($routes->get('route_a'), 'The first matching route was found.');
    $this->assertNotNull($routes->get('route_b'), 'The second matching route was not found.');
}

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