--- tests/Zend/Controller/Router/Route/ChainTest.php (revision 23651) +++ tests/Zend/Controller/Router/Route/ChainTest.php (working copy) @@ -667,6 +667,38 @@ } /** + * @group ZF-7368 + */ + public function testChainingStaticDynamicMatchToDefaults() + { + $foo = new Zend_Controller_Router_Route_Static('foo'); + $bar = new Zend_Controller_Router_Route(':bar', array('bar' => 0)); + $chain = $foo->chain($bar); + + $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/foo'); + $res = $chain->match($request); + + $this->assertType('array', $res, 'Route did not match'); + $this->assertEquals(0, $res['bar']); + } + + /** + * @group ZF-7368 + */ + public function testChainingStaticDynamicMatchToParams() + { + $foo = new Zend_Controller_Router_Route_Static('foo'); + $bar = new Zend_Controller_Router_Route(':bar', array('bar' => 1)); + $chain = $foo->chain($bar); + + $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/foo/2'); + $res = $chain->match($request); + + $this->assertType('array', $res, 'Route did not match'); + $this->assertEquals(2, $res['bar']); + } + + /** * @group ZF-7848 */ public function testChainingWithEmptyStaticRoutesMatchesCorrectly() @@ -715,6 +747,8 @@ ), $values); } + + /** * @group ZF-7848 */ Index: library/Zend/Controller/Router/Route.php =================================================================== --- library/Zend/Controller/Router/Route.php (revision 23651) +++ library/Zend/Controller/Router/Route.php (working copy) @@ -295,6 +295,10 @@ if (!array_key_exists($var, $return)) { return false; } + // Empty variable? Replace with the default value. + elseif ($return[$var] == '' || $return[$var] === null) { + $return[$var] = $this->_defaults[$var]; + } } $this->setMatchedPath(rtrim($matchedPath, $this->_urlDelimiter));