function PathMatcherTest::testOutlinePathNoMatch

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

File

drupal/core/modules/system/lib/Drupal/system/Tests/Routing/PathMatcherTest.php, line 278
Definition of Drupal\system\Tests\Routing\PartialMatcherTest.

Class

PathMatcherTest
Basic tests for the UrlMatcherDumper.

Namespace

Drupal\system\Tests\Routing

Code

function testOutlinePathNoMatch() {
  $connection = Database::getConnection();
  $matcher = new PathMatcher($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 = $matcher
      ->matchRequestPartial($request);
    $this
      ->fail(t('No exception was thrown.'));
  } catch (Exception $e) {
    $this
      ->assertTrue($e instanceof ResourceNotFoundException, 'The correct exception was thrown.');
  }
}