Browse Source

Expand test coverage and simplify code.

Mark Story 3 years ago
parent
commit
bf38ae4404
2 changed files with 13 additions and 7 deletions
  1. 1 7
      src/Routing/RouteCollection.php
  2. 12 0
      tests/TestCase/Routing/RouteCollectionTest.php

+ 1 - 7
src/Routing/RouteCollection.php

@@ -150,7 +150,7 @@ class RouteCollection
                 // Extension parsing was enabled after the route was added to
                 // the collection and it can no longer be treated as a static route.
                 if ($route->getExtensions()) {
-                    continue;
+                    // continue;
                 }
 
                 $r = $route->parse($url, $method);
@@ -214,12 +214,6 @@ class RouteCollection
 
         if (isset($this->staticPaths[$urlPath])) {
             foreach ($this->staticPaths[$urlPath] as $route) {
-                // Extension parsing was enabled after the route was added to
-                // the collection and it can no longer be treated as a static route.
-                if ($route->getExtensions()) {
-                    continue;
-                }
-
                 $r = $route->parseRequest($request);
                 if ($r === null) {
                     continue;

+ 12 - 0
tests/TestCase/Routing/RouteCollectionTest.php

@@ -499,6 +499,18 @@ class RouteCollectionTest extends TestCase
         $builder = new RouteBuilder($this->collection, '/');
         $builder->connect('/foo', ['controller' => 'Articles'])->setExtensions(['json']);
 
+        $request = new ServerRequest(['url' => '/foo']);
+        $result = $this->collection->parseRequest($request);
+        unset($result['_route']);
+        $expected = [
+            'controller' => 'Articles',
+            'action' => 'index',
+            'pass' => [],
+            'plugin' => null,
+            '_matchedRoute' => '/foo',
+        ];
+        $this->assertEquals($expected, $result);
+
         $request = new ServerRequest(['url' => '/foo.json']);
         $result = $this->collection->parseRequest($request);
         unset($result['_route']);