function RouteProviderTest::testOutlinePathNoMatch

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

File

drupal/core/modules/system/lib/Drupal/system/Tests/Routing/RouteProviderTest.php, line 312
Contains Drupal\system\Tests\Routing\RouteProviderTest.

Class

RouteProviderTest
Basic tests for the RouteProvider.

Namespace

Drupal\system\Tests\Routing

Code

function testOutlinePathNoMatch() {
  $connection = Database::getConnection();
  $provider = new RouteProvider($connection, 'test_routes');
  $this->fixtures
    ->createTables($connection);
  $dumper = new MatcherDumper($connection, 'test_routes');
  $dumper
    ->addRoutes($this->fixtures
    ->complexRouteCollection());
  $dumper
    ->dump();
  $path = '/no/such/path';
  $request = Request::create($path, 'GET');
  try {
    $routes = $provider
      ->getRouteCollectionForRequest($request);
    $this
      ->fail(t('No exception was thrown.'));
  } catch (\Exception $e) {
    $this
      ->assertTrue($e instanceof ResourceNotFoundException, 'The correct exception was thrown.');
  }
}