From 96809ab62a9d1793b9dda53cf0fc65ca64dee65e Mon Sep 17 00:00:00 2001 From: Evan Coury Date: Mon, 19 Apr 2010 17:40:09 -0700 Subject: [PATCH] fixed ZF-8222 and added unit tests for it --- library/Zend/Controller/Dispatcher/Standard.php | 8 +++- tests/Zend/Controller/Dispatcher/StandardTest.php | 24 ++++++++ .../_files/ManuallyIncludedControllers.php | 57 ++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletions(-) create mode 100644 tests/Zend/Controller/_files/ManuallyIncludedControllers.php diff --git a/library/Zend/Controller/Dispatcher/Standard.php b/library/Zend/Controller/Dispatcher/Standard.php index d005546..99dcde9 100644 --- a/library/Zend/Controller/Dispatcher/Standard.php +++ b/library/Zend/Controller/Dispatcher/Standard.php @@ -206,7 +206,13 @@ class Zend_Controller_Dispatcher_Standard extends Zend_Controller_Dispatcher_Abs return false; } - if (class_exists($className, false)) { + $finalClass = $className; + if (($this->_defaultModule != $this->_curModule) + || $this->getParam('prefixDefaultModule')) + { + $finalClass = $this->formatClassName($this->_curModule, $className); + } + if (class_exists($finalClass, false)) { return true; } diff --git a/tests/Zend/Controller/Dispatcher/StandardTest.php b/tests/Zend/Controller/Dispatcher/StandardTest.php index 134445f..7cac9b1 100644 --- a/tests/Zend/Controller/Dispatcher/StandardTest.php +++ b/tests/Zend/Controller/Dispatcher/StandardTest.php @@ -136,6 +136,30 @@ class Zend_Controller_Dispatcher_StandardTest extends PHPUnit_Framework_TestCase $this->assertFalse($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); } + /** + * @group ZF-8222 + */ + public function testIsDispatchableManuallyIncludedController() + { + require_once dirname(__FILE__) . '/../_files/ManuallyIncludedControllers.php'; + $request = new Zend_Controller_Request_Http(); + + + $this->_dispatcher->setParam('prefixDefaultModule', true); + + $request->setControllerName('included'); + $this->assertFalse($this->_dispatcher->isDispatchable($request)); + + $request->setControllerName('included-prefix'); + $this->assertTrue($this->_dispatcher->isDispatchable($request)); + + $this->_dispatcher->setParam('prefixDefaultModule', false); + + $request->setModuleName('admin'); + $request->setControllerName('included-admin'); + $this->assertTrue($this->_dispatcher->isDispatchable($request)); + } + public function testSetGetResponse() { $response = new Zend_Controller_Response_Cli(); diff --git a/tests/Zend/Controller/_files/ManuallyIncludedControllers.php b/tests/Zend/Controller/_files/ManuallyIncludedControllers.php new file mode 100644 index 0000000..42e01a5 --- /dev/null +++ b/tests/Zend/Controller/_files/ManuallyIncludedControllers.php @@ -0,0 +1,57 @@ +