|
|
@@ -32,6 +32,9 @@ require_once 'Zend/Config.php';
|
|
|
/** Zend_Controller_Router_Rewrite */
|
|
|
require_once 'Zend/Controller/Router/Rewrite.php';
|
|
|
|
|
|
+/** Zend_Controller_Dispatcher_Standard */
|
|
|
+require_once 'Zend/Controller/Dispatcher/Standard.php';
|
|
|
+
|
|
|
/** Zend_Controller_Router_Route_Chain */
|
|
|
require_once 'Zend/Controller/Router/Route/Chain.php';
|
|
|
|
|
|
@@ -116,6 +119,31 @@ class Zend_Controller_Router_Route_ChainTest extends PHPUnit_Framework_TestCase
|
|
|
$this->assertEquals(2, $res['bar']);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @group ZF-8812
|
|
|
+ */
|
|
|
+ public function testChainingMatchToDefaultValues()
|
|
|
+ {
|
|
|
+ $foo = new Zend_Controller_Router_Route(
|
|
|
+ ':foo',
|
|
|
+ array('foo' => 'bar'),
|
|
|
+ array('foo' => '[a-z]{3}')
|
|
|
+ );
|
|
|
+
|
|
|
+ $bar = new Zend_Controller_Router_Route_Module(array(
|
|
|
+ 'module' => 0,
|
|
|
+ 'controller' => 1,
|
|
|
+ 'action' => 2
|
|
|
+ ));
|
|
|
+
|
|
|
+ $chain = $foo->chain($bar);
|
|
|
+
|
|
|
+ $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/');
|
|
|
+ $res = $chain->match($request);
|
|
|
+
|
|
|
+ $this->assertTrue(is_array($res), 'Route did not match to default values.');
|
|
|
+ }
|
|
|
+
|
|
|
public function testChainingShortcutMatch()
|
|
|
{
|
|
|
$foo = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('foo' => 1));
|
|
|
@@ -426,8 +454,8 @@ class Zend_Controller_Router_Route_ChainTest extends PHPUnit_Framework_TestCase
|
|
|
$router = new Zend_Controller_Router_Rewrite();
|
|
|
$front = Zend_Controller_Front::getInstance();
|
|
|
$front->resetInstance();
|
|
|
- $front->setDispatcher(new Zend_Controller_Router_RewriteTest_Dispatcher());
|
|
|
- $front->setRequest(new Zend_Controller_Router_RewriteTest_Request());
|
|
|
+ $front->setDispatcher(new Zend_Controller_Router_ChainTest_Dispatcher());
|
|
|
+ $front->setRequest(new Zend_Controller_Router_ChainTest_Request());
|
|
|
$router->setFrontController($front);
|
|
|
|
|
|
$router->addConfig(new Zend_Config($routes));
|
|
|
@@ -683,6 +711,22 @@ class Zend_Controller_Router_ChainTest_Request extends Zend_Controller_Request_H
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Zend_Controller_Router_ChainTest_Dispatcher - dispatcher object for router testing
|
|
|
+ */
|
|
|
+class Zend_Controller_Router_ChainTest_Dispatcher extends Zend_Controller_Dispatcher_Standard
|
|
|
+{
|
|
|
+ public function getDefaultControllerName()
|
|
|
+ {
|
|
|
+ return 'defctrl';
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getDefaultAction()
|
|
|
+ {
|
|
|
+ return 'defact';
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
if (PHPUnit_MAIN_METHOD == "Zend_Controller_Router_Route_ChainTest::main") {
|
|
|
Zend_Controller_Router_Route_ChainTest::main();
|
|
|
}
|