You are here

public function MethodFilterTest::testFilteredMethods 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::testFilteredMethods()
  2. 10 core/tests/Drupal/Tests/Core/Routing/MethodFilterTest.php \Drupal\Tests\Core\Routing\MethodFilterTest::testFilteredMethods()

@covers ::filter

File

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

Class

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

Namespace

Drupal\Tests\Core\Routing

Code

public function testFilteredMethods() {
  $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', [], [], [], '', [], [
    'PATCH',
  ]));
  $collection
    ->add('test_route3.get', new Route('/test', [], [], [], '', [], [
    'POST',
  ]));
  $expected_collection = new RouteCollection();
  $expected_collection
    ->add('test_route2.get', new Route('/test', [], [], [], '', [], [
    'PATCH',
  ]));
  $method_filter = new MethodFilter();
  $result_collection = $method_filter
    ->filter($collection, $request);
  $this
    ->assertEquals($expected_collection, $result_collection);
}