From b7b235c2a5b9285df372cf408d89fb2590348256 Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 12 Sep 2008 02:06:53 +0000 Subject: [PATCH] Small test-correcting fix for Dispatcher git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7593 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/dispatcher.php | 20 +++++++++++--------- cake/tests/cases/dispatcher.test.php | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 81b58a65a..833a470cc 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -143,35 +143,37 @@ class Dispatcher extends Object { 'className' => Inflector::camelize($this->params['controller']) . 'Controller', 'webroot' => $this->webroot, 'url' => $url, - 'base' => $this->base))); + 'base' => $this->base + ) + )); } $privateAction = (bool)(strpos($this->params['action'], '_', 0) === 0); - - if (empty($this->params['action'])) { - $this->params['action'] = 'index'; - } $prefixes = Router::prefixes(); if (!empty($prefixes)) { if (isset($this->params['prefix'])) { $this->params['action'] = $this->params['prefix'] . '_' . $this->params['action']; - } elseif (strpos($this->params['action'], '_') !== false) { + } elseif (strpos($this->params['action'], '_') !== false && !$privateAction) { list($prefix, $action) = explode('_', $this->params['action']); $privateAction = in_array($prefix, $prefixes); } } - Router::setRequestInfo(array($this->params, array('base' => $this->base, 'here' => $this->here, 'webroot' => $this->webroot))); + Router::setRequestInfo(array( + $this->params, array('base' => $this->base, 'here' => $this->here, 'webroot' => $this->webroot) + )); if ($privateAction) { return $this->cakeError('privateAction', array( array( - 'className' => Inflector::camelize($this->params['controller']."Controller"), + 'className' => Inflector::camelize($this->params['controller'] . "Controller"), 'action' => $this->params['action'], 'webroot' => $this->webroot, 'url' => $url, - 'base' => $this->base))); + 'base' => $this->base + ) + )); } $controller->base = $this->base; diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 555bad71c..e2fe60c02 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -1126,7 +1126,7 @@ class DispatcherTest extends CakeTestCase { $controller = $Dispatcher->dispatch($url, array('return' => 1)); $expected = 'privateAction'; - $this->assertEqual($expected, $controller); + $this->assertEqual($controller, $expected); } /** * testMissingAction method