function MethodFilterTest::testMethodNotAllowedException

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/Routing/MethodFilterTest.php \Drupal\Tests\Core\Routing\MethodFilterTest::testMethodNotAllowedException()
  2. 9 core/tests/Drupal/Tests/Core/Routing/MethodFilterTest.php \Drupal\Tests\Core\Routing\MethodFilterTest::testMethodNotAllowedException()
  3. 8.9.x core/tests/Drupal/Tests/Core/Routing/MethodFilterTest.php \Drupal\Tests\Core\Routing\MethodFilterTest::testMethodNotAllowedException()
  4. main core/tests/Drupal/Tests/Core/Routing/MethodFilterTest.php \Drupal\Tests\Core\Routing\MethodFilterTest::testMethodNotAllowedException()

Tests method not allowed exception.

@legacy-covers ::filter

File

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

Class

MethodFilterTest
Tests Drupal\Core\Routing\MethodFilter.

Namespace

Drupal\Tests\Core\Routing

Code

public function testMethodNotAllowedException() : void {
  $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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.