mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
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:
parent
a04fe5f81d
commit
c28ecff862
2 changed files with 13 additions and 5 deletions
|
@ -111,7 +111,7 @@ class Dispatcher extends Object {
|
||||||
$this->here = $this->base . '/' . $url;
|
$this->here = $this->base . '/' . $url;
|
||||||
|
|
||||||
if ($this->asset($url) || $this->cached($url)) {
|
if ($this->asset($url) || $this->cached($url)) {
|
||||||
$this->_stop();
|
return;
|
||||||
}
|
}
|
||||||
$controller =& $this->__getController();
|
$controller =& $this->__getController();
|
||||||
|
|
||||||
|
@ -227,8 +227,11 @@ class Dispatcher extends Object {
|
||||||
*/
|
*/
|
||||||
function __extractParams($url, $additionalParams = array()) {
|
function __extractParams($url, $additionalParams = array()) {
|
||||||
$defaults = array('pass' => array(), 'named' => array(), 'form' => array());
|
$defaults = array('pass' => array(), 'named' => array(), 'form' => array());
|
||||||
$this->params = array_merge($defaults, $url, $additionalParams);
|
$params = array_merge($defaults, $url, $additionalParams);
|
||||||
return Router::url($url);
|
$this->params = $params;
|
||||||
|
|
||||||
|
$params += array('base' => false, 'url' => array());
|
||||||
|
return ltrim(Router::reverse($params), '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1382,16 +1382,21 @@ class DispatcherTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testDispatchWithArray() {
|
function testDispatchWithArray() {
|
||||||
$Dispatcher =& new TestDispatcher();
|
$Dispatcher =& new TestDispatcher();
|
||||||
Configure::write('App.baseUrl','/index.php');
|
|
||||||
$url = 'pages/home/param:value/param2:value2';
|
$url = 'pages/home/param:value/param2:value2';
|
||||||
|
|
||||||
$url = array('controller' => 'pages', 'action' => 'display');
|
$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';
|
$expected = 'Pages';
|
||||||
$this->assertEqual($expected, $controller->name);
|
$this->assertEqual($expected, $controller->name);
|
||||||
|
|
||||||
$expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2');
|
$expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2');
|
||||||
$this->assertIdentical($expected, $controller->passedArgs);
|
$this->assertIdentical($expected, $controller->passedArgs);
|
||||||
|
|
||||||
|
$this->assertEqual($Dispatcher->base . '/pages/display/home/param:value/param2:value2', $Dispatcher->here);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue