Permalink
Browse files

Adding a test to ensure that $here contains the correct value when su…

…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...
1 parent a04fe5f commit c28ecff862475caf27dc6816fcdb5131f814d359 @markstory markstory committed Aug 5, 2010
Showing with 13 additions and 5 deletions.
  1. +6 −3 cake/dispatcher.php
  2. +7 −2 cake/tests/cases/dispatcher.test.php
View
@@ -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();
@@ -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), '/');
}
/**
@@ -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);
}
/**

0 comments on commit c28ecff

Please sign in to comment.