Skip to content

Commit

Permalink
Adding a test to ensure that $here contains the correct value when su…
Browse files Browse the repository at this point in the history
…pplying 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
  • Loading branch information
markstory committed Aug 5, 2010
1 parent a04fe5f commit c28ecff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 6 additions & 3 deletions cake/dispatcher.php
Expand Up @@ -111,7 +111,7 @@ function dispatch($url = null, $additionalParams = array()) {
$this->here = $this->base . '/' . $url;

if ($this->asset($url) || $this->cached($url)) {
$this->_stop();
return;
}
$controller =& $this->__getController();

Expand Down Expand Up @@ -227,8 +227,11 @@ function _invoke(&$controller, $params) {
*/
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), '/');
}

/**
Expand Down
9 changes: 7 additions & 2 deletions cake/tests/cases/dispatcher.test.php
Expand Up @@ -1382,16 +1382,21 @@ function testDispatch() {
*/
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);
}

/**
Expand Down

0 comments on commit c28ecff

Please sign in to comment.