|
|
@@ -1066,6 +1066,12 @@ class RouterTest extends CakeTestCase {
|
|
|
$result = Router::parse('/posts/view/foo:bar/routing:fun/answer:42');
|
|
|
$expected = array('pass' => array(), 'named' => array('foo' => 'bar', 'routing' => 'fun', 'answer' => '42'), 'plugin' => null, 'controller' => 'posts', 'action' => 'view');
|
|
|
$this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ Router::reload();
|
|
|
+ Router::connect('/posts/view/*', array('controller' => 'posts', 'action' => 'view'), array('named' => array('foo', 'answer'), 'greedyNamed' => true));
|
|
|
+ $result = Router::parse('/posts/view/foo:bar/routing:fun/answer:42?id=123&tab=abc');
|
|
|
+ $expected = array('pass' => array(), 'named' => array('foo' => 'bar', 'routing' => 'fun', 'answer' => '42'), 'plugin' => null, 'controller' => 'posts', 'action' => 'view', '?' => array('id' => '123', 'tab' => 'abc'));
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1183,6 +1189,33 @@ class RouterTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Test parse and reverse symmetry
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @dataProvider parseReverseSymmetryData
|
|
|
+ */
|
|
|
+ public function testParseReverseSymmetry($url) {
|
|
|
+ $this->assertSame($url, Router::reverse(Router::parse($url) + array('url' => array())));
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Data for parse and reverse test
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function parseReverseSymmetryData() {
|
|
|
+ return array(
|
|
|
+ array('/'),
|
|
|
+ array('/controller/action'),
|
|
|
+ array('/controller/action/param'),
|
|
|
+ array('/controller/action?param1=value1¶m2=value2'),
|
|
|
+ array('/controller/action/param?param1=value1'),
|
|
|
+ array('/controller/action/named1:nv1'),
|
|
|
+ array('/controller/action/named1:nv1?param1=value1')
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* Test that Routing.prefixes are used when a Router instance is created
|
|
|
* or reset
|
|
|
*
|
|
|
@@ -1332,9 +1365,11 @@ class RouterTest extends CakeTestCase {
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
|
$result = Router::parse('/posts/view/1.rss?query=test');
|
|
|
+ $expected['?'] = array('query' => 'test');
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
|
$result = Router::parse('/posts/view/1.atom');
|
|
|
+ unset($expected['?']);
|
|
|
$expected['ext'] = 'atom';
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
|
@@ -1348,7 +1383,7 @@ class RouterTest extends CakeTestCase {
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
|
$result = Router::parse('/posts.atom?hello=goodbye');
|
|
|
- $expected = array('plugin' => null, 'controller' => 'posts.atom', 'action' => 'index', 'pass' => array(), 'named' => array());
|
|
|
+ $expected = array('plugin' => null, 'controller' => 'posts.atom', 'action' => 'index', 'pass' => array(), 'named' => array(), '?' => array('hello' => 'goodbye'));
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
|
Router::reload();
|