Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Routing / MethodFilterTest.php
index 8a7554dec903099e0a80bbc70f9e5973edc140b3..2e411b2b85458bb726a4be70dfd6adae21100245 100644 (file)
@@ -15,34 +15,6 @@ use Symfony\Component\Routing\RouteCollection;
  */
 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
    */
@@ -125,4 +97,22 @@ class MethodFilterTest extends UnitTestCase {
     $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()));
+  }
+
 }