Modifying Dispatcher tests to modify private variables (which is bad, but there is no way to change which plugins Router uses to create patterns). This allows the removal of two calls to _restructureParams.

This commit is contained in:
Mark Story 2010-04-03 22:24:31 -04:00
parent 95802176bb
commit 2814ddc2d5
2 changed files with 6 additions and 11 deletions

View file

@ -403,16 +403,7 @@ class Dispatcher extends Object {
$controller = false;
$ctrlClass = $this->__loadController($params);
if (!$ctrlClass) {
if (!isset($params['plugin'])) {
$params = $this->_restructureParams($params);
} else {
$params = $this->_restructureParams($params, true);
}
$ctrlClass = $this->__loadController($params);
if (!$ctrlClass) {
$this->params = $original;
return $controller;
}
return $controller;
}
$name = $ctrlClass;
$ctrlClass .= 'Controller';

View file

@ -1584,9 +1584,13 @@ class DispatcherTest extends CakeTestCase {
function testAutomaticPluginDispatchWithShortAccess() {
$_POST = array();
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
$plugins = App::objects('plugin');
$plugins[] = 'MyPlugin';
$app = App::getInstance();
$app->__objects['plugin'] = $plugins;
Router::reload();
Router::connect('/my_plugin/:controller/:action/*', array('plugin' => 'my_plugin'));
$Dispatcher =& new TestDispatcher();
$Dispatcher->base = false;