Adding parameter pattern matching back into RouterRoute::match(), fixes failing tests in RouterRoute test case.

This commit is contained in:
mark_story 2009-11-29 23:46:02 -05:00
parent 5999264f10
commit e41c408378
2 changed files with 10 additions and 8 deletions

View file

@ -1384,7 +1384,6 @@ class RouterRoute {
$passedArgsAndParams = array_diff_key($diff, $this->defaults, $keyNames);
list($named, $params) = Router::getNamedElements($passedArgsAndParams, $url['controller'], $url['action']);
//remove any pass params, they have numeric indexes
$pass = array();
$i = 0;
@ -1393,8 +1392,16 @@ class RouterRoute {
unset($url[$i]);
$i++;
}
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));
//check patterns for routed params
if (!empty($this->params)) {
foreach ($this->params as $key => $pattern) {
if (array_key_exists($key, $url) && !preg_match('#' . $pattern . '#', $url[$key])) {
return false;
}
}
}
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));
//*/
/*
@ -1426,12 +1433,7 @@ class RouterRoute {
unset($params[$key]);
}
}
debug($params);
list($named, $params) = Router::getNamedElements($params);
debug($named);
debug($params);
debug($this);
echo '-----------<br>';
if (!strpos($this->template, '*') && (!empty($pass) || !empty($named))) {
return false;

View file

@ -1948,7 +1948,7 @@ class RouterTest extends CakeTestCase {
}
}
SimpleTest::ignore('RouterTest');
// SimpleTest::ignore('RouterTest');
// SimpleTest::ignore('RouterRouteTestCase');
/**
* Test case for RouterRoute