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
This commit is contained in:
nate 2008-09-12 02:06:53 +00:00
parent 970ef7dc56
commit b7b235c2a5
2 changed files with 12 additions and 10 deletions

View file

@ -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;

View file

@ -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