function RouteProviderTest::testExactPathMatch

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

Confirms that we can find routes with the exact incoming path.

File

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

Class

RouteProviderTest
Confirm that the default route provider is working correctly.

Namespace

Drupal\KernelTests\Core\Routing

Code

public function testExactPathMatch() {
    $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
        ->sampleRouteCollection());
    $dumper->dump();
    $path = '/path/one';
    $request = Request::create($path, 'GET');
    $routes = $provider->getRouteCollectionForRequest($request);
    foreach ($routes as $route) {
        $this->assertEquals($path, $route->getPath(), 'Found path has correct pattern');
    }
}

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