Adding tests for array named params from router test to cakeroute test.

This commit is contained in:
mark_story 2011-03-03 06:22:59 -05:00
parent cf26a8e430
commit 636188efeb

View file

@ -491,15 +491,72 @@ class CakeRouteTestCase extends CakeTestCase {
);
$this->assertEquals($expected, $result);
$result = $route->parse('/posts/edit/a-string/page:1');
$result = $route->parse('/posts/edit/a-string/page:1/sort:value');
$expected = array(
'controller' => 'posts',
'action' => 'edit',
'pass' => array('a-string'),
'named' => array(
'page' => 1
'page' => 1,
'sort' => 'value'
)
);
$this->assertEquals($expected, $result);
}
/**
* test that parsing array format named parameters works
*
* @return void
*/
function testArrayNamedParameters() {
$route = new CakeRoute('/:controller/:action/*');
$result = $route->parse('/tests/action/var[]:val1/var[]:val2');
$expected = array(
'controller' => 'tests',
'action' => 'action',
'named' => array(
'var' => array(
'val1',
'val2'
)
),
'pass' => array(),
);
$this->assertEqual($result, $expected);
$result = $route->parse('/tests/action/theanswer[is]:42/var[]:val2/var[]:val3');
$expected = array(
'controller' => 'tests',
'action' => 'action',
'named' => array(
'theanswer' => array(
'is' => 42
),
'var' => array(
'val2',
'val3'
)
),
'pass' => array(),
);
$this->assertEqual($result, $expected);
$result = $route->parse('/tests/action/theanswer[is][not]:42/theanswer[]:5/theanswer[is]:6');
$expected = array(
'controller' => 'tests',
'action' => 'action',
'named' => array(
'theanswer' => array(
5,
'is' => array(
6,
'not' => 42
)
),
),
'pass' => array(),
);
$this->assertEqual($result, $expected);
}
}