Permalink
Browse files

Removing tests for features no longer supported. Path elements contai…

…ning only regular expressions are no longer supported. They did not effectively reverse route. And they provided an inconsistent behavior when combined with the full gamut of regular expressions and routing parameters.
  • Loading branch information...
1 parent 49c6cd3 commit 4cb055ff0a8adcb92bbe40e5146f39885e33a5c4 @markstory markstory committed Nov 27, 2009
Showing with 0 additions and 88 deletions.
  1. +0 −59 cake/libs/router.php
  2. +0 −29 cake/tests/cases/libs/router.test.php
View
59 cake/libs/router.php
@@ -1306,65 +1306,6 @@ function _writeRoute($route, $default, $params) {
$parsed = str_replace($search, $replacements, $parsed);
$this->_compiledRoute = '#^' . $parsed . '[/]*$#';
$this->keys = $names;
-
- /*
- $elements = explode('/', $route);
-
- foreach ($elements as $element) {
- if (empty($element)) {
- continue;
- }
- $q = null;
- $element = trim($element);
- $namedParam = strpos($element, ':') !== false;
-
- if ($namedParam && preg_match('/^:([^:]+)$/', $element, $r)) {
- if (isset($params[$r[1]])) {
- if ($r[1] != 'plugin' && array_key_exists($r[1], $default)) {
- $q = '?';
- }
- $parsed[] = '(?:/(' . $params[$r[1]] . ')' . $q . ')' . $q;
- } else {
- $parsed[] = '(?:/([^\/]+))?';
- }
- $names[] = $r[1];
- } elseif ($element === '*') {
- $parsed[] = '(?:/(.*))?';
- } else if ($namedParam && preg_match_all('/(?!\\\\):([a-z_0-9]+)/i', $element, $matches)) {
- $matchCount = count($matches[1]);
-
- foreach ($matches[1] as $i => $name) {
- $pos = strpos($element, ':' . $name);
- $before = substr($element, 0, $pos);
- $element = substr($element, $pos + strlen($name) + 1);
- $after = null;
-
- if ($i + 1 === $matchCount && $element) {
- $after = preg_quote($element);
- }
-
- if ($i === 0) {
- $before = '/' . $before;
- }
- $before = preg_quote($before, '#');
-
- if (isset($params[$name])) {
- if (isset($default[$name]) && $name != 'plugin') {
- $q = '?';
- }
- $parsed[] = '(?:' . $before . '(' . $params[$name] . ')' . $q . $after . ')' . $q;
- } else {
- $parsed[] = '(?:' . $before . '([^\/]+)' . $after . ')?';
- }
- $names[] = $name;
- }
- } else {
- $parsed[] = '/' . $element;
- }
- }
- $this->_compiledRoute = '#^' . join('', $parsed) . '[\/]*$#';
- $this->keys = $names;
- //*/
}
/**
View
29 cake/tests/cases/libs/router.test.php
@@ -1620,35 +1620,6 @@ function testRemoveBase() {
}
/**
- * testParamsUrlParsing method
- *
- * @access public
- * @return void
- */
- function testParamsUrlParsing() {
- Router::connect('/', array('controller' => 'posts', 'action' => 'index'));
- Router::connect('/view/:user/*', array('controller' => 'posts', 'action' => 'view'), array('user'));
- $result = Router::parse('/view/gwoo/');
- $expected = array('user' => 'gwoo', 'controller' => 'posts', 'action' => 'view', 'plugin' =>'', 'pass' => array(), 'named' => array());
- $this->assertEqual($result, $expected);
-
- Router::reload();
- Router::connect('/([0-9]+)-p-(.*)/', array('controller' => 'products', 'action' => 'show'));
- Router::connect('/(.*)-q-(.*)/', array('controller' => 'products', 'action' => 'show'));
- $result = Router::parse('/100-p-500/');
- $expected = array('pass' => array('100', '500'), 'named' => array(), 'controller' => 'products', 'action' => 'show', 'plugin' => null);
- $this->assertEqual($result, $expected);
-
- $result = Router::parse('/bob-q-500/');
- $expected = array('pass' => array('bob', '500'), 'named' => array(), 'controller' => 'products', 'action' => 'show', 'plugin' => null);
- $this->assertEqual($result, $expected);
-
- $result = Router::parse('/bob-p-500/');
- $expected = array('pass' => array(), 'named' => array(), 'controller' => 'bob-p-500', 'plugin' => null, 'action' => 'index');
- $this->assertEqual($result, $expected);
- }
-
-/**
* testPagesUrlParsing method
*
* @access public

0 comments on commit 4cb055f

Please sign in to comment.