Skip to content
Permalink
Browse files

Fix a bunch of failing tests.

  • Loading branch information...
markstory committed Apr 26, 2012
1 parent 883ead2 commit 9f1bc1e0a38da7203dd2e9c63ccc03301cebb47d
@@ -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;
}
@@ -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 . '/';
}
@@ -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.
*
@@ -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);

0 comments on commit 9f1bc1e

Please sign in to comment.
You can’t perform that action at this time.