Explorar o código

fix ZF-8914: numeric key names do not work with assemble()

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22416 44c647ce-9c0f-0410-b52a-842ac1e357ba
rob %!s(int64=15) %!d(string=hai) anos
pai
achega
0d9d43f59c

+ 2 - 1
library/Zend/Controller/Router/Rewrite.php

@@ -458,7 +458,8 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
             }
         }
 
-        $params = array_merge($this->_globalParams, $userParams);
+        // Use UNION (+) in order to preserve numeric keys 
+        $params = $userParams + $this->_globalParams;
 
         $route = $this->getRoute($name);
         $url   = $route->assemble($params, $reset, $encode);

+ 31 - 0
tests/Zend/Controller/Router/RewriteTest.php

@@ -732,6 +732,37 @@ class Zend_Controller_Router_RewriteTest extends PHPUnit_Framework_TestCase
 
         $this->assertEquals('/articles/777', $url);
     }
+    
+
+    /**
+     * Test that it is possible to generate a URL with a numerical key
+     *
+     * @since  2010-06-11
+     * @group  ZF-8914
+     * @covers Zend_Controller_Router_Rewrite::assemble
+     */
+    public function testCanGenerateNumericKeyUri()
+    {
+        $this->_router->addRoute(
+            'default', 
+            new Zend_Controller_Router_Route(
+                ':controller/:action/*',
+                array('controller' => 'index', 'action' => 'index')
+            )
+       );
+
+       $params = array(
+            'controller' => 'index',
+            'action'     => 'index',
+            '2'          => 'foo',
+            'page'       => 'bar',
+        );
+
+        $this->assertEquals(
+            '/index/index/2/foo/page/bar',
+            $this->_router->assemble($params)
+        );
+    }
 }