Skip to content

Commit

Permalink
Add tests for CakeRoute::match() and trailing * routes.
Browse files Browse the repository at this point in the history
Add tests for /pages/** routes, and fix coding standards errors.

Refs #3581
  • Loading branch information
markstory committed Jun 3, 2014
1 parent c622a9d commit 4362f7b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/Cake/Routing/Route/CakeRoute.php
Expand Up @@ -536,11 +536,10 @@ protected function _writeUrl($params) {
$out = str_replace($search, $replace, $out);
}

if (strpos($this->template, '**')) {
if (strpos($this->template, '**') !== false) {
$out = str_replace('**', $params['pass'], $out);
$out = str_replace('%2F', '/', $out);
}
elseif (strpos($this->template, '*')) {
} elseif (strpos($this->template, '*') !== false) {
$out = str_replace('*', $params['pass'], $out);
}
$out = str_replace('//', '/', $out);
Expand Down
17 changes: 17 additions & 0 deletions lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php
Expand Up @@ -873,6 +873,23 @@ public function testMatchSimilarParameters() {
$this->assertEquals($expected, $result);
}

/**
* Test match() with trailing ** style routes.
*
* @return void
*/
public function testMatchTrailing() {
$route = new CakeRoute('/pages/**', array('controller' => 'pages', 'action' => 'display'));
$id = 'test/ spaces/漢字/la†în';
$result = $route->match(array(
'controller' => 'pages',
'action' => 'display',
$id
));
$expected = '/pages/test/%20spaces/%E6%BC%A2%E5%AD%97/la%E2%80%A0%C3%AEn';
$this->assertEquals($expected, $result);
}

/**
* test restructuring args with pass key
*
Expand Down

0 comments on commit 4362f7b

Please sign in to comment.