From 6ef8203d54199bcb438e6e402af911b18c6b1522 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 13:32:05 -0500 Subject: [PATCH] Adding another case that makes false/null to not cause match failure. --- cake/libs/route/cake_route.php | 2 +- cake/tests/cases/libs/route/cake_route.test.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 8803a3201..5fa934347 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -280,7 +280,7 @@ class CakeRoute { continue; } // keys that don't exist are different. - if (!$keyExists) { + if (!$keyExists && !empty($value)) { $diff[$key] = $value; } diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index 37fd17d1c..a8c5404fa 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -289,6 +289,19 @@ class CakeRouteTestCase extends CakeTestCase { $this->assertEqual($result, $expected); } +/** + * test that falsey values do not interrupt a match. + * + * @return void + */ + function testMatchWithFalseyValues() { + $route = new CakeRoute('/:controller/:action/*', array('plugin' => null)); + $result = $route->match(array( + 'controller' => 'posts', 'action' => 'index', 'plugin' => null, 'admin' => false + )); + $this->assertEqual($result, '/posts/index/'); + } + /** * test match() with greedy routes, named parameters and passed args. *