More tests passing in RouterTest now.

This commit is contained in:
mark_story 2009-11-30 10:15:39 -05:00
parent 11dd7898c4
commit 393038816c
2 changed files with 5 additions and 5 deletions

View file

@ -751,6 +751,7 @@ class Router {
unset($url[$prefix]); unset($url[$prefix]);
} }
} }
if (array_key_exists('plugin', $url)) { if (array_key_exists('plugin', $url)) {
$params['plugin'] = $url['plugin']; $params['plugin'] = $url['plugin'];
} }
@ -774,6 +775,7 @@ class Router {
if (isset($route->params['persist'], $params)) { if (isset($route->params['persist'], $params)) {
$url = $route->persistParams($url, array_merge($params, $backupUrl)); $url = $route->persistParams($url, array_merge($params, $backupUrl));
} }
if ($match = $route->match($url)) { if ($match = $route->match($url)) {
$output = trim($match, '/'); $output = trim($match, '/');
$url = array(); $url = array();
@ -1355,7 +1357,6 @@ class RouterRoute {
$this->compile(); $this->compile();
} }
$defaults = $this->defaults; $defaults = $this->defaults;
$url += $defaults;
if (isset($defaults['prefix'])) { if (isset($defaults['prefix'])) {
$prefix = $defaults['prefix']; $prefix = $defaults['prefix'];
@ -1370,7 +1371,7 @@ class RouterRoute {
$diff = Set::diff($url, $defaults); $diff = Set::diff($url, $defaults);
//if a not a greedy route, no extra params are allowed. //if a not a greedy route, no extra params are allowed.
if (!$this->_greedy && array_keys($diff) != $this->keys) { if (!$this->_greedy && array_diff_key($diff, $keyNames) != array()) {
return false; return false;
} }
@ -1413,7 +1414,6 @@ class RouterRoute {
} }
} }
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix'))); return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));
//*/ //*/
/* /*
$defaults = $this->defaults; $defaults = $this->defaults;
@ -1446,7 +1446,7 @@ class RouterRoute {
} }
list($named, $params) = Router::getNamedElements($params); list($named, $params) = Router::getNamedElements($params);
if (!strpos($this->template, '*') && (!empty($pass) || !empty($named))) { if (!$this->_greedy && (!empty($pass) || !empty($named))) {
return false; return false;
} }
$routeParams = $this->keys; $routeParams = $this->keys;

View file

@ -966,7 +966,7 @@ class RouterTest extends CakeTestCase {
array('controller' => 'posts', 'action' => 'index'), array('controller' => 'posts', 'action' => 'index'),
array('persist' => array('lang') array('persist' => array('lang')
)); ));
Router::connect('/:lang/:color/posts/edit/*', array('controller' => 'posts', 'action' => 'index')); Router::connect('/:lang/:color/posts/edit/*', array('controller' => 'posts', 'action' => 'edit'));
Router::connect('/about', array('controller' => 'pages', 'action' => 'view', 'about')); Router::connect('/about', array('controller' => 'pages', 'action' => 'view', 'about'));
Router::parse('/en/red/posts/view/5'); Router::parse('/en/red/posts/view/5');