function RouteProviderTest::testOutlinePathNoMatch

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

Confirms that an exception is thrown when no matching path is found.

File

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

Class

RouteProviderTest
Confirm that the default route provider is working correctly.

Namespace

Drupal\KernelTests\Core\Routing

Code

public function testOutlinePathNoMatch() {
    $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 = '/no/such/path';
    $request = Request::create($path, 'GET');
    $routes = $provider->getRoutesByPattern($path);
    $this->assertEmpty($routes, 'No path found with this pattern.');
    $collection = $provider->getRouteCollectionForRequest($request);
    $this->assertEmpty($collection, 'Empty route collection found with this pattern.');
}

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