function MethodFilterTest::testMethodNotAllowedExceptionWithMultipleRoutes

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

@covers ::filter

File

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

Class

MethodFilterTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Routing%21MethodFilter.php/class/MethodFilter/11.x" title="Filters routes based on the HTTP method." class="local">\Drupal\Core\Routing\MethodFilter</a> @group Routing

Namespace

Drupal\Tests\Core\Routing

Code

public function testMethodNotAllowedExceptionWithMultipleRoutes() : void {
    $request = Request::create('/test', 'PATCH');
    $collection = new RouteCollection();
    $collection->add('test_route.get', new Route('/test', [], [], [], '', [], [
        'GET',
    ]));
    $collection->add('test_route2.get', new Route('/test', [], [], [], '', [], [
        'GET',
    ]));
    $collection->add('test_route3.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.