*/
class MethodFilterTest extends UnitTestCase {
- /**
- * @covers ::applies
- * @dataProvider providerApplies
- */
- public function testApplies(array $route_methods, $expected_applies) {
- $route = new Route('/test', [], [], [], '', [], $route_methods);
- $method_filter = new MethodFilter();
-
- $this->assertSame($expected_applies, $method_filter->applies($route));
- }
-
- /**
- * Data provider for testApplies().
- *
- * @return array
- */
- public function providerApplies() {
- return [
- 'only GET' => [['GET'], TRUE],
- 'only PATCH' => [['PATCH'], TRUE],
- 'only POST' => [['POST'], TRUE],
- 'only DELETE' => [['DELETE'], TRUE],
- 'only HEAD' => [['HEAD'], TRUE],
- 'all' => [['GET', 'PATCH', 'POST', 'DELETE', 'HEAD'], TRUE],
- 'none' => [[], FALSE],
- ];
- }
-
/**
* @covers ::filter
*/
$this->assertEquals($expected_collection, $result_collection);
}
+ /**
+ * Ensures that the incoming and outgoing collections have the same order.
+ *
+ * @covers ::filter
+ */
+ public function testCollectionOrder() {
+ $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()));
+ }
+
}