function MethodFilterTest::testCollectionOrder

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

Ensures that the incoming and outgoing collections have the same order.

@covers ::filter

File

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

Class

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

Namespace

Drupal\Tests\Core\Routing

Code

public function testCollectionOrder() : void {
    $request = Request::create('/test', 'GET');
    $collection = new RouteCollection();
    $collection->add('entity.taxonomy_term.canonical', new Route('/test'));
    $collection->add('views.view.taxonomy_term_page', new Route('/test', [], [], [], '', [], [
        'GET',
        'POST',
    ]));
    $method_filter = new MethodFilter();
    $result_collection = $method_filter->filter($collection, $request);
    $this->assertEquals([
        'entity.taxonomy_term.canonical',
        'views.view.taxonomy_term_page',
    ], array_keys($result_collection->all()));
}

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