public function HttpMethodMatcherTest::testNoRouteFound

Confirms that the HttpMethod matcher throws an exception for no-route.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Routing/HttpMethodMatcherTest.php, line 87
Definition of Drupal\system\Tests\Routing\HttpMethodMMatcherTest.

Class

HttpMethodMatcherTest
Basic tests for the HttpMethodMatcher class.

Namespace

Drupal\system\Tests\Routing

Code

public function testNoRouteFound() {
  $matcher = new HttpMethodMatcher();

  // Remove the sample route that would match any method.
  $routes = $this->fixtures
    ->sampleRouteCollection();
  $routes
    ->remove('route_d');
  $matcher
    ->setCollection($routes);
  try {
    $routes = $matcher
      ->matchRequestPartial(Request::create('path/one', 'DELETE'));
    $this
      ->fail(t('No exception was thrown.'));
  } catch (Exception $e) {
    $this
      ->assertTrue($e instanceof MethodNotAllowedException, 'The correct exception was thrown.');
  }
}