Skip to content

Commit

Permalink
Fix a bunch of failing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jul 4, 2012
1 parent 883ead2 commit 9f1bc1e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Routing/Route/Route.php
Expand Up @@ -392,7 +392,7 @@ public function match($url, $context = array()) {
}

// Defaults with different values are a fail.
if (array_intersect_key($url, $defaults) !== $defaults) {
if (array_intersect_key($url, $defaults) != $defaults) {
return false;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Cake/Routing/Router.php
Expand Up @@ -363,7 +363,9 @@ public static function mapResources($controller, $options = array()) {
foreach ((array)$controller as $name) {
list($plugin, $name) = pluginSplit($name);
$urlName = Inflector::underscore($name);
$plugin = Inflector::underscore($plugin);
if ($plugin) {
$plugin = Inflector::underscore($plugin);
}
if ($plugin && !$hasPrefix) {
$prefix = '/' . $plugin . '/';
}
Expand Down
24 changes: 24 additions & 0 deletions lib/Cake/Test/TestCase/Routing/Route/RouteTest.php
Expand Up @@ -475,6 +475,30 @@ public function testMatchExtractQueryStringArgs() {
$this->assertEquals('/posts/index/1?page=1&dir=desc&order=title', $result);
}

/**
* Test separartor.
*
* @return void
*/
public function testQueryStringGeneration() {
$route = new Route('/:controller/:action/*');

$restore = ini_get('arg_separator.output');
ini_set('arg_separator.output', '&');

$result = $route->match(array(
'controller' => 'posts',
'action' => 'index',
0,
'test' => 'var',
'var2' => 'test2',
'more' => 'test data'
));
$expected = '/posts/index/0?test=var&var2=test2&more=test+data';
$this->assertEquals($expected, $result);
ini_set('arg_separator.output', $restore);
}

/**
* test persistParams ability to persist parameters from $params and remove params.
*
Expand Down
13 changes: 11 additions & 2 deletions lib/Cake/Test/TestCase/Routing/RouterTest.php
Expand Up @@ -222,11 +222,20 @@ public function testMultipleResourceRoute() {
public function testGenerateUrlResourceRoute() {
Router::mapResources('Posts');

$result = Router::url(array('controller' => 'posts', 'action' => 'index', '[method]' => 'GET'));
$result = Router::url(array(
'controller' => 'posts',
'action' => 'index',
'[method]' => 'GET'
));
$expected = '/posts';
$this->assertEquals($expected, $result);

$result = Router::url(array('controller' => 'posts', 'action' => 'view', '[method]' => 'GET', 'id' => 10));
$result = Router::url(array(
'controller' => 'posts',
'action' => 'view',
'[method]' => 'GET',
'id' => 10
));
$expected = '/posts/10';
$this->assertEquals($expected, $result);

Expand Down

0 comments on commit 9f1bc1e

Please sign in to comment.