From e41c408378fcbd7b0cc66ec0b7b2da9b9085bf1d Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 29 Nov 2009 23:46:02 -0500 Subject: [PATCH] Adding parameter pattern matching back into RouterRoute::match(), fixes failing tests in RouterRoute test case. --- cake/libs/router.php | 16 +++++++++------- cake/tests/cases/libs/router.test.php | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 39589dc55..f48deea1a 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -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 '-----------
'; if (!strpos($this->template, '*') && (!empty($pass) || !empty($named))) { return false; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 6de3a3e86..43b1f54b8 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1948,7 +1948,7 @@ class RouterTest extends CakeTestCase { } } -SimpleTest::ignore('RouterTest'); +// SimpleTest::ignore('RouterTest'); // SimpleTest::ignore('RouterRouteTestCase'); /** * Test case for RouterRoute