Adding a test to ensure that $here contains the correct value when supplying additionalParams (like through a requestAction). Changing how Dispatcher::__extractParams converts url params into a string, so the result is the same as a string url.

Removing the call to _stop() as it halts the script when a requestAction hits a cached file.  Fixes #977
This commit is contained in:
mark_story 2010-08-04 23:44:48 -04:00
parent a04fe5f81d
commit c28ecff862
2 changed files with 13 additions and 5 deletions

View file

@ -111,7 +111,7 @@ class Dispatcher extends Object {
$this->here = $this->base . '/' . $url;
if ($this->asset($url) || $this->cached($url)) {
$this->_stop();
return;
}
$controller =& $this->__getController();
@ -227,8 +227,11 @@ class Dispatcher extends Object {
*/
function __extractParams($url, $additionalParams = array()) {
$defaults = array('pass' => array(), 'named' => array(), 'form' => array());
$this->params = array_merge($defaults, $url, $additionalParams);
return Router::url($url);
$params = array_merge($defaults, $url, $additionalParams);
$this->params = $params;
$params += array('base' => false, 'url' => array());
return ltrim(Router::reverse($params), '/');
}
/**

View file

@ -1382,16 +1382,21 @@ class DispatcherTest extends CakeTestCase {
*/
function testDispatchWithArray() {
$Dispatcher =& new TestDispatcher();
Configure::write('App.baseUrl','/index.php');
$url = 'pages/home/param:value/param2:value2';
$url = array('controller' => 'pages', 'action' => 'display');
$controller = $Dispatcher->dispatch($url, array('pass' => array('home'), 'named' => array('param' => 'value', 'param2' => 'value2'), 'return' => 1));
$controller = $Dispatcher->dispatch($url, array(
'pass' => array('home'),
'named' => array('param' => 'value', 'param2' => 'value2'),
'return' => 1
));
$expected = 'Pages';
$this->assertEqual($expected, $controller->name);
$expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2');
$this->assertIdentical($expected, $controller->passedArgs);
$this->assertEqual($Dispatcher->base . '/pages/display/home/param:value/param2:value2', $Dispatcher->here);
}
/**