public function ChainMatcherTest::testRequestNotFound

Confirms that the expected exception is thrown.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Routing/ChainMatcherTest.php, line 60
Definition of Drupal\system\Tests\Routing\ChainMatcherTest.

Class

ChainMatcherTest
Basic tests for the ChainMatcher.

Namespace

Drupal\system\Tests\Routing

Code

public function testRequestNotFound() {
  $chain = new ChainMatcher();
  $resource_not_found = new MockMatcher(function (Request $request) {
    throw new ResourceNotFoundException();
  });
  try {
    $chain
      ->add($resource_not_found);
    $chain
      ->matchRequest(Request::create('my/path'));
  } catch (ResourceNotFoundException $e) {
    $this
      ->pass('Correct exception thrown.');
  } catch (Exception $e) {
    $this
      ->fail('Incorrect exception thrown: ' . get_class($e));
  }
}