You are here

public function MethodFilterTest::testMethodNotAllowedException in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Routing/MethodFilterTest.php \Drupal\Tests\Core\Routing\MethodFilterTest::testMethodNotAllowedException()

@covers ::filter

File

core/tests/Drupal/Tests/Core/Routing/MethodFilterTest.php, line 54

Class

MethodFilterTest
@coversDefaultClass \Drupal\Core\Routing\MethodFilter @group Routing

Namespace

Drupal\Tests\Core\Routing

Code

public function testMethodNotAllowedException() {
  $request = Request::create('/test', 'PATCH');
  $collection = new RouteCollection();
  $collection
    ->add('test_route.get', new Route('/test', [], [], [], '', [], [
    'GET',
  ]));
  $this
    ->expectException(MethodNotAllowedException::class);
  $method_filter = new MethodFilter();
  $method_filter
    ->filter($collection, $request);
}