mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding additional tests for CakeRoute::persistParams(). Ensures that url params can overwrite persisted values.
Tests added.
This commit is contained in:
parent
b8946db4b0
commit
ecc38f0aed
2 changed files with 9 additions and 4 deletions
|
@ -1361,7 +1361,7 @@ class CakeRoute {
|
|||
*/
|
||||
function persistParams($url, $params) {
|
||||
foreach ($this->options['persist'] as $persistKey) {
|
||||
if (array_key_exists($persistKey, $params)) {
|
||||
if (array_key_exists($persistKey, $params) && !isset($url[$persistKey])) {
|
||||
$url[$persistKey] = $params[$persistKey];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2266,8 +2266,14 @@ class CakeRouteTestCase extends CakeTestCase {
|
|||
$url = array('controller' => 'posts', 'action' => 'index');
|
||||
$params = array('lang' => 'en', 'color' => 'blue');
|
||||
$result = $route->persistParams($url, $params);
|
||||
$this->assertEqual($result['lang'], $params['lang']);
|
||||
$this->assertEqual($result['color'], $params['color']);
|
||||
$this->assertEqual($result['lang'], 'en');
|
||||
$this->assertEqual($result['color'], 'blue');
|
||||
|
||||
$url = array('controller' => 'posts', 'action' => 'index', 'color' => 'red');
|
||||
$params = array('lang' => 'en', 'color' => 'blue');
|
||||
$result = $route->persistParams($url, $params);
|
||||
$this->assertEqual($result['lang'], 'en');
|
||||
$this->assertEqual($result['color'], 'red');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2286,5 +2292,4 @@ class CakeRouteTestCase extends CakeTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
Loading…
Add table
Reference in a new issue