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 39589dc5514..f48deea1a0a 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -1384,7 +1384,6 @@ function match($url) { $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 @@ function match($url) { 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 @@ function match($url) { 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 6de3a3e86c6..43b1f54b842 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1948,7 +1948,7 @@ function testRouterConnectDefaults() { } } -SimpleTest::ignore('RouterTest'); +// SimpleTest::ignore('RouterTest'); // SimpleTest::ignore('RouterRouteTestCase'); /** * Test case for RouterRoute