Browse Source

[ZF-6654] Fixed matching of wildcard pattern in chainroute

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19734 44c647ce-9c0f-0410-b52a-842ac1e357ba
dasprid 16 years ago
parent
commit
e895b4dc3c

+ 2 - 0
library/Zend/Controller/Router/Route.php

@@ -240,6 +240,8 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
                             $this->_wildcardData[$var] = (isset($path[$i+1])) ? urldecode($path[$i+1]) : null;
                         }
                     }
+
+                    $matchedPath = implode($this->_urlDelimiter, $path);
                     break;
                 }
 

+ 30 - 0
tests/Zend/Controller/Router/Route/ChainTest.php

@@ -611,6 +611,36 @@ class Zend_Controller_Router_Route_ChainTest extends PHPUnit_Framework_TestCase
         $this->assertType('Zend_Controller_Router_Route_Chain', $router->getRoute('www-index'));
     }
 
+    public function testChainingWorksWithWildcardAndNoParameters()
+    {
+        $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('module' => 'simple', 'controller' => 'bar', 'action' => 'bar'));
+        $bar = new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'index', 'action' => 'index'));
+
+        $chain = $foo->chain($bar);
+
+        $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/foo/bar/');
+        $res = $chain->match($request);
+
+        $this->assertEquals('simple', $res['module']);
+        $this->assertEquals('foo', $res['controller']);
+        $this->assertEquals('bar', $res['action']);
+    }
+
+    public function testChainingWorksWithWildcardAndOneParameter()
+    {
+        $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('module' => 'simple', 'controller' => 'foo', 'action' => 'bar'));
+        $bar = new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'index', 'action' => 'index'));
+
+        $chain = $foo->chain($bar);
+
+        $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/foo/bar/id/12');
+        $res = $chain->match($request);
+
+        $this->assertEquals('simple', $res['module']);
+        $this->assertEquals('foo', $res['controller']);
+        $this->assertEquals('bar', $res['action']);
+    }
+    
     protected function _getRouter()
     {
         $router = new Zend_Controller_Router_Rewrite();