|
|
@@ -118,7 +118,7 @@ class CakeRouteTest extends CakeTestCase {
|
|
|
$this->assertRegExp($result, '/posts/view/518098');
|
|
|
$this->assertNotRegExp($result, '/posts/edit/name-of-post');
|
|
|
$this->assertNotRegExp($result, '/posts/edit/4/other:param');
|
|
|
- $this->assertEquals(array('controller', 'action', 'id'), $route->keys);
|
|
|
+ $this->assertEquals(array('id', 'controller', 'action'), $route->keys);
|
|
|
|
|
|
$route = new CakeRoute(
|
|
|
'/:lang/:controller/:action/:id',
|
|
|
@@ -130,7 +130,7 @@ class CakeRouteTest extends CakeTestCase {
|
|
|
$this->assertRegExp($result, '/cze/articles/view/1');
|
|
|
$this->assertNotRegExp($result, '/language/articles/view/2');
|
|
|
$this->assertNotRegExp($result, '/eng/articles/view/name-of-article');
|
|
|
- $this->assertEquals(array('lang', 'controller', 'action', 'id'), $route->keys);
|
|
|
+ $this->assertEquals(array('lang', 'id', 'controller', 'action'), $route->keys);
|
|
|
|
|
|
foreach (array(':', '@', ';', '$', '-') as $delim) {
|
|
|
$route = new CakeRoute('/posts/:id' . $delim . ':title');
|
|
|
@@ -141,7 +141,7 @@ class CakeRouteTest extends CakeTestCase {
|
|
|
$this->assertNotRegExp($result, '/posts/11!nameofarticle');
|
|
|
$this->assertNotRegExp($result, '/posts/11');
|
|
|
|
|
|
- $this->assertEquals(array('id', 'title'), $route->keys);
|
|
|
+ $this->assertEquals(array('title', 'id'), $route->keys);
|
|
|
}
|
|
|
|
|
|
$route = new CakeRoute(
|
|
|
@@ -155,7 +155,7 @@ class CakeRouteTest extends CakeTestCase {
|
|
|
$this->assertNotRegExp($result, '/posts/hey_now:nameofarticle');
|
|
|
$this->assertNotRegExp($result, '/posts/:nameofarticle/2009');
|
|
|
$this->assertNotRegExp($result, '/posts/:nameofarticle/01');
|
|
|
- $this->assertEquals(array('id', 'title', 'year'), $route->keys);
|
|
|
+ $this->assertEquals(array('year', 'title', 'id'), $route->keys);
|
|
|
|
|
|
$route = new CakeRoute(
|
|
|
'/posts/:url_title-(uuid::id)',
|
|
|
@@ -204,7 +204,7 @@ class CakeRouteTest extends CakeTestCase {
|
|
|
|
|
|
$this->assertRegExp($result, '/some_extra/page/this_is_the_slug');
|
|
|
$this->assertRegExp($result, '/page/this_is_the_slug');
|
|
|
- $this->assertEquals(array('extra', 'slug'), $route->keys);
|
|
|
+ $this->assertEquals(array('slug', 'extra'), $route->keys);
|
|
|
$this->assertEquals(array('extra' => '[a-z1-9_]*', 'slug' => '[a-z1-9_]+', 'action' => 'view'), $route->options);
|
|
|
$expected = array(
|
|
|
'controller' => 'pages',
|
|
|
@@ -856,6 +856,24 @@ class CakeRouteTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Test matching of parameters where one parameter name starts with another parameter name
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testMatchSimilarParameters() {
|
|
|
+ $route = new CakeRoute('/:thisParam/:thisParamIsLonger');
|
|
|
+
|
|
|
+ $url = array(
|
|
|
+ 'thisParamIsLonger' => 'bar',
|
|
|
+ 'thisParam' => 'foo',
|
|
|
+ );
|
|
|
+
|
|
|
+ $result = $route->match($url);
|
|
|
+ $expected = '/foo/bar';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* test restructuring args with pass key
|
|
|
*
|
|
|
* @return void
|
|
|
@@ -941,4 +959,5 @@ class CakeRouteTest extends CakeTestCase {
|
|
|
$expected = array('section' => 'weblog', 'plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index', 'pass' => array(), 'named' => array());
|
|
|
$this->assertEquals($expected, $result);
|
|
|
}
|
|
|
+
|
|
|
}
|