Adding another case that makes false/null to not cause match failure.

This commit is contained in:
mark_story 2010-12-18 13:32:05 -05:00
parent 456a14cf37
commit 6ef8203d54
2 changed files with 14 additions and 1 deletions

View file

@ -280,7 +280,7 @@ class CakeRoute {
continue; continue;
} }
// keys that don't exist are different. // keys that don't exist are different.
if (!$keyExists) { if (!$keyExists && !empty($value)) {
$diff[$key] = $value; $diff[$key] = $value;
} }

View file

@ -289,6 +289,19 @@ class CakeRouteTestCase extends CakeTestCase {
$this->assertEqual($result, $expected); $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. * test match() with greedy routes, named parameters and passed args.
* *