diff --git a/cake/console/cake.php b/cake/console/cake.php index cf21c24f4..7864a82bc 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -508,13 +508,15 @@ class ShellDispatcher { */ function parseParams($params) { $this->__parseParams($params); - $defaults = array('app' => 'app', 'root' => dirname(dirname(dirname(__FILE__))), 'working' => null, 'webroot' => 'webroot'); - $params = array_merge($defaults, array_intersect_key($this->params, $defaults)); - - $isWin = array_filter(array_map('strpos', $params, array('\\'))); - + $isWin = false; + foreach ($defaults as $default => $value) { + if (strpos($params[$default], '\\') !== false) { + $isWin = true; + break; + } + } $params = str_replace('\\', '/', $params); if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0]{0} !== '.')) { @@ -526,7 +528,7 @@ class ShellDispatcher { } } - if ($params['app'][0] == '/' || preg_match('/([a-zA-Z])(:)/i', $params['app'], $matches)) { + if ($params['app'][0] == '/' || preg_match('/([a-z])(:)/i', $params['app'], $matches)) { $params['root'] = dirname($params['app']); } elseif (strpos($params['app'], '/')) { $params['root'] .= '/' . dirname($params['app']); diff --git a/cake/console/libs/schema.php b/cake/console/libs/schema.php index d5bfb3ff7..033c2a01c 100644 --- a/cake/console/libs/schema.php +++ b/cake/console/libs/schema.php @@ -208,7 +208,7 @@ class SchemaShell extends Shell { } } $db =& ConnectionManager::getDataSource($this->Schema->connection); - $contents = "#". $Schema->name ." sql generated on: " . date('Y-m-d H:i:s') . " : ". time()."\n\n"; + $contents = "#" . $Schema->name . " sql generated on: " . date('Y-m-d H:i:s') . " : " . time() . "\n\n"; $contents .= $db->dropSchema($Schema) . "\n\n". $db->createSchema($Schema); if ($write) { if (strpos($write, '.sql') === false) { diff --git a/cake/console/libs/shell.php b/cake/console/libs/shell.php index 183be2fe3..503a63111 100644 --- a/cake/console/libs/shell.php +++ b/cake/console/libs/shell.php @@ -320,7 +320,7 @@ class Shell extends Object { } if (!isset($this->{$taskName})) { - $this->err("Task '".$taskName."' could not be loaded"); + $this->err("Task '" . $taskName . "' could not be loaded"); $this->_stop(); } } diff --git a/cake/console/libs/tasks/project.php b/cake/console/libs/tasks/project.php index be7963b43..e14b5af78 100644 --- a/cake/console/libs/tasks/project.php +++ b/cake/console/libs/tasks/project.php @@ -155,7 +155,7 @@ class ProjectTask extends Shell { $this->out(sprintf(__("Created: %s in %s", true), $app, $path)); $this->hr(); } else { - $this->err(" '".$app."' could not be created properly"); + $this->err(" '" . $app . "' could not be created properly"); return false; } @@ -224,7 +224,7 @@ class ProjectTask extends Shell { $File =& new File($path . 'webroot' . DS . 'index.php'); $contents = $File->read(); if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_CORE_INCLUDE_PATH\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) { - $result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '".CAKE_CORE_INCLUDE_PATH."');", $contents); + $result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '" . CAKE_CORE_INCLUDE_PATH . "');", $contents); if (!$File->write($result)) { return false; } @@ -235,7 +235,7 @@ class ProjectTask extends Shell { $File =& new File($path . 'webroot' . DS . 'test.php'); $contents = $File->read(); if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_CORE_INCLUDE_PATH\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) { - $result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '".CAKE_CORE_INCLUDE_PATH."');", $contents); + $result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '" . CAKE_CORE_INCLUDE_PATH . "');", $contents); if (!$File->write($result)) { return false; } diff --git a/cake/console/libs/templates/default/views/form.ctp b/cake/console/libs/templates/default/views/form.ctp index 6a451dc91..264221c3d 100644 --- a/cake/console/libs/templates/default/views/form.ctp +++ b/cake/console/libs/templates/default/views/form.ctp @@ -26,7 +26,7 @@
create('{$modelClass}');?>\n";?>
- ";?> + ";?> $data) { foreach ($data as $alias => $details) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { - echo "\t\t
  • link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?>
  • \n"; - echo "\t\t
  • link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>
  • \n"; + echo "\t\t
  • link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?>
  • \n"; + echo "\t\t
  • link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>
  • \n"; $done[] = $details['controller']; } } diff --git a/cake/console/libs/templates/default/views/home.ctp b/cake/console/libs/templates/default/views/home.ctp index 82eb03b87..f97a8a4ef 100644 --- a/cake/console/libs/templates/default/views/home.ctp +++ b/cake/console/libs/templates/default/views/home.ctp @@ -1,5 +1,5 @@ Sweet, \"".Inflector::humanize($app)."\" got Baked by CakePHP!\n"; +$output = "

    Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!

    \n"; $output .=" 0): diff --git a/cake/console/libs/templates/default/views/index.ctp b/cake/console/libs/templates/default/views/index.ctp index a3f467cbb..e68fea588 100644 --- a/cake/console/libs/templates/default/views/index.ctp +++ b/cake/console/libs/templates/default/views/index.ctp @@ -89,8 +89,8 @@ echo "\n"; foreach ($associations as $type => $data) { foreach ($data as $alias => $details) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { - echo "\t\t
  • link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?>
  • \n"; - echo "\t\t
  • link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>
  • \n"; + echo "\t\t
  • link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?>
  • \n"; + echo "\t\t
  • link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>
  • \n"; $done[] = $details['controller']; } } diff --git a/cake/console/libs/templates/default/views/view.ctp b/cake/console/libs/templates/default/views/view.ctp index 8f12ede99..e79f06d81 100644 --- a/cake/console/libs/templates/default/views/view.ctp +++ b/cake/console/libs/templates/default/views/view.ctp @@ -33,14 +33,14 @@ foreach ($fields as $field) { foreach ($associations['belongsTo'] as $alias => $details) { if ($field === $details['foreignKey']) { $isKey = true; - echo "\t\t>\n"; + echo "\t\t>\n"; echo "\t\t>\n\t\t\tlink(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t \n\t\t\n"; break; } } } if ($isKey !== true) { - echo "\t\t>\n"; + echo "\t\t>\n"; echo "\t\t>\n\t\t\t\n\t\t\t \n\t\t\n"; } } @@ -59,8 +59,8 @@ foreach ($fields as $field) { foreach ($associations as $type => $data) { foreach ($data as $alias => $details) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { - echo "\t\t
  • link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?>
  • \n"; - echo "\t\t
  • link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>
  • \n"; + echo "\t\t
  • link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?>
  • \n"; + echo "\t\t
  • link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>
  • \n"; $done[] = $details['controller']; } } @@ -72,12 +72,12 @@ foreach ($fields as $field) { if (!empty($associations['hasOne'])) : foreach ($associations['hasOne'] as $alias => $details): ?> @@ -111,7 +111,7 @@ foreach ($relations as $alias => $details): \n"; + echo "\t\t\n"; } ?> ";?> @@ -144,7 +144,7 @@ echo "\t\n"; \n\n";?>
      -
    • link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?>
    • +
    • link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?>
    diff --git a/cake/libs/controller/components/cookie.php b/cake/libs/controller/components/cookie.php index c52dd2220..3067da9d9 100644 --- a/cake/libs/controller/components/cookie.php +++ b/cake/libs/controller/components/cookie.php @@ -219,10 +219,10 @@ class CookieComponent extends Object { if (count($name) > 1) { $this->__values[$name[0]][$name[1]] = $value; - $this->__write("[".$name[0]."][".$name[1]."]", $value); + $this->__write("[" . $name[0] . "][" . $name[1] . "]", $value); } else { $this->__values[$name[0]] = $value; - $this->__write("[".$name[0]."]", $value); + $this->__write("[" . $name[0] . "]", $value); } } else { foreach ($key as $names => $value) { @@ -230,10 +230,10 @@ class CookieComponent extends Object { if (count($name) > 1) { $this->__values[$name[0]][$name[1]] = $value; - $this->__write("[".$name[0]."][".$name[1]."]", $value); + $this->__write("[" . $name[0] . "][" . $name[1] . "]", $value); } else { $this->__values[$name[0]] = $value; - $this->__write("[".$name[0]."]", $value); + $this->__write("[" . $name[0] . "]", $value); } } } @@ -296,17 +296,17 @@ class CookieComponent extends Object { $name = $this->__cookieVarNames($key); if (count($name) > 1) { if (isset($this->__values[$name[0]])) { - $this->__delete("[".$name[0]."][".$name[1]."]"); + $this->__delete("[" . $name[0] . "][" . $name[1] . "]"); unset($this->__values[$name[0]][$name[1]]); } } else { if (isset($this->__values[$name[0]])) { if (is_array($this->__values[$name[0]])) { foreach ($this->__values[$name[0]] as $key => $value) { - $this->__delete("[".$name[0]."][".$key."]"); + $this->__delete("[" . $name[0] . "][" . $key . "]"); } } - $this->__delete("[".$name[0]."]"); + $this->__delete("[" . $name[0] . "]"); unset($this->__values[$name[0]]); } } diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index abe856dee..58e5bc152 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -212,10 +212,10 @@ class HttpSocket extends CakeSocket { } if (isset($this->request['auth']['user']) && isset($this->request['auth']['pass'])) { - $this->request['header']['Authorization'] = $this->request['auth']['method'] ." ". base64_encode($this->request['auth']['user'] .":".$this->request['auth']['pass']); + $this->request['header']['Authorization'] = $this->request['auth']['method'] . " " . base64_encode($this->request['auth']['user'] . ":" . $this->request['auth']['pass']); } if (isset($this->request['uri']['user']) && isset($this->request['uri']['pass'])) { - $this->request['header']['Authorization'] = $this->request['auth']['method'] ." ". base64_encode($this->request['uri']['user'] .":".$this->request['uri']['pass']); + $this->request['header']['Authorization'] = $this->request['auth']['method'] . " " . base64_encode($this->request['uri']['user'] . ":" . $this->request['uri']['pass']); } if (is_array($this->request['body'])) { @@ -836,7 +836,7 @@ class HttpSocket extends CakeSocket { return false; } - preg_match_all("/(.+):(.+)(?:(?lineBreak."|\$)/Uis", $header, $matches, PREG_SET_ORDER); + preg_match_all("/(.+):(.+)(?:(?lineBreak . "|\$)/Uis", $header, $matches, PREG_SET_ORDER); $header = array(); foreach ($matches as $match) { diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index deed6c838..0718895ba 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -352,7 +352,7 @@ class CakeSchema extends Object { $col = "\t\t'indexes' => array("; $props = array(); foreach ((array)$value as $key => $index) { - $props[] = "'{$key}' => array(".join(', ', $this->__values($index)).")"; + $props[] = "'{$key}' => array(" . join(', ', $this->__values($index)) . ")"; } $col .= join(', ', $props); } @@ -462,7 +462,7 @@ class CakeSchema extends Object { if (is_array($values)) { foreach ($values as $key => $val) { if (is_array($val)) { - $vals[] = "'{$key}' => array('".join("', '", $val)."')"; + $vals[] = "'{$key}' => array('" . join("', '", $val) . "')"; } else if (!is_numeric($key)) { $val = var_export($val, true); $vals[] = "'{$key}' => {$val}"; diff --git a/cake/libs/model/datasources/dbo/dbo_mysqli.php b/cake/libs/model/datasources/dbo/dbo_mysqli.php index 2115dee85..ec5f05fb3 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysqli.php +++ b/cake/libs/model/datasources/dbo/dbo_mysqli.php @@ -112,9 +112,8 @@ class DboMysqli extends DboMysqlBase { function _execute($sql) { if (preg_match('/^\s*call/i', $sql)) { return $this->_executeProcedure($sql); - } else { - return mysqli_query($this->connection, $sql); } + return mysqli_query($this->connection, $sql); } /** @@ -149,15 +148,15 @@ class DboMysqli extends DboMysqlBase { if (!$result) { return array(); - } else { - $tables = array(); - - while ($line = mysqli_fetch_array($result)) { - $tables[] = $line[0]; - } - parent::listSources($tables); - return $tables; } + + $tables = array(); + + while ($line = mysqli_fetch_array($result)) { + $tables[] = $line[0]; + } + parent::listSources($tables); + return $tables; } /** @@ -212,18 +211,19 @@ class DboMysqli extends DboMysqlBase { if ($parent != null) { return $parent; } - - if ($data === null) { + if ($data === null || (is_array($data) && empty($data))) { return 'NULL'; } - if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') { - return "''"; + return "''"; + } + if (empty($column)) { + $column = $this->introspectType($data); } switch ($column) { case 'boolean': - $data = $this->boolean((bool)$data); + return $this->boolean((bool)$data); break; case 'integer' : case 'float' : @@ -293,7 +293,6 @@ class DboMysqli extends DboMysqlBase { if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0]['insertID'])) { return $id[0]['insertID']; } - return null; } @@ -354,11 +353,11 @@ class DboMysqli extends DboMysqlBase { function length($real) { $col = str_replace(array(')', 'unsigned'), '', $real); $limit = null; - + if (strpos($col, '(') !== false) { list($col, $limit) = explode('(', $col); } - + if ($limit != null) { return intval($limit); } @@ -408,9 +407,8 @@ class DboMysqli extends DboMysqlBase { $i++; } return $resultRow; - } else { - return false; } + return false; } /** diff --git a/cake/libs/router.php b/cake/libs/router.php index 2246d6300..9f0ae7b63 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -334,9 +334,9 @@ class Router extends Object { /** * Builds a route regular expression * - * @param string $route An empty string, or a route string "/" - * @param array $default NULL or an array describing the default route - * @param array $params An array matching the named elements in the route to regular expressions which that element should match. + * @param string $route An empty string, or a route string "/" + * @param array $default NULL or an array describing the default route + * @param array $params An array matching the named elements in the route to regular expressions which that element should match. * @return array * @see routes * @access public @@ -560,10 +560,7 @@ class Router extends Object { function compile($i) { $route = $this->routes[$i]; - if (!list($pattern, $names) = $this->writeRoute($route[0], $route[1], $route[2])) { - unset($this->routes[$i]); - return array(); - } + list($pattern, $names) = $this->writeRoute($route[0], $route[1], $route[2]); $this->routes[$i] = array( $route[0], $pattern, $names, array_merge(array('plugin' => null, 'controller' => null), (array)$route[1]), @@ -1317,9 +1314,9 @@ class Router extends Object { return $param; } - $return = preg_replace('/^(?:[\\t ]*(?:-!)+)/', '', $param); - return $return; + return preg_replace('/^(?:[\\t ]*(?:-!)+)/', '', $param); } + foreach ($param as $key => $value) { if (is_string($value)) { $return[$key] = preg_replace('/^(?:[\\t ]*(?:-!)+)/', '', $value); @@ -1394,7 +1391,9 @@ class Router extends Object { continue; } $param = $_this->stripEscape($param); - if ((!isset($options['named']) || !empty($options['named'])) && strpos($param, $_this->named['separator']) !== false) { + + $separatorIsPresent = strpos($param, $_this->named['separator']) !== false; + if ((!isset($options['named']) || !empty($options['named'])) && $separatorIsPresent) { list($key, $val) = explode($_this->named['separator'], $param, 2); $hasRule = isset($rules[$key]); $passIt = (!$hasRule && !$greedy) || ($hasRule && !Router::matchNamed($key, $val, $rules[$key], $context)); diff --git a/cake/libs/view/errors/missing_action.ctp b/cake/libs/view/errors/missing_action.ctp index 53bb01b15..787e8e089 100644 --- a/cake/libs/view/errors/missing_action.ctp +++ b/cake/libs/view/errors/missing_action.ctp @@ -26,11 +26,11 @@

    : - ".$action."", "".$controller."");?> + " . $action . "", "" . $controller . "");?>

    : - ".$controller."::", "".$action."()", APP_DIR.DS."controllers".DS.Inflector::underscore($controller).".php");?> + " . $controller . "::", "" . $action . "()", APP_DIR . DS . "controllers" . DS . Inflector::underscore($controller) . ".php");?>

     <?php
    @@ -48,5 +48,5 @@ class  extends AppController {
     

    : - +

    \ No newline at end of file diff --git a/cake/libs/view/errors/missing_component_class.ctp b/cake/libs/view/errors/missing_component_class.ctp index eec14a1fc..e83b4f75b 100644 --- a/cake/libs/view/errors/missing_component_class.ctp +++ b/cake/libs/view/errors/missing_component_class.ctp @@ -26,11 +26,11 @@

    : - ". $component ."Component", "". $controller ."Controller");?> + " . $component . "Component", "" . $controller . "Controller");?>

    : - ". $component ."Component", APP_DIR.DS."controllers".DS."components".DS.$file);?> + " . $component . "Component", APP_DIR . DS . "controllers" . DS . "components" . DS . $file);?>

     <?php
    @@ -41,5 +41,5 @@ class Component extends Object {

    : - +

    \ No newline at end of file diff --git a/cake/libs/view/errors/missing_component_file.ctp b/cake/libs/view/errors/missing_component_file.ctp index 5816985e8..ac8e4fce4 100644 --- a/cake/libs/view/errors/missing_component_file.ctp +++ b/cake/libs/view/errors/missing_component_file.ctp @@ -30,7 +30,7 @@

    : - ". $component ."Component", APP_DIR.DS."controllers".DS."components".DS.$file);?> + " . $component . "Component", APP_DIR . DS . "controllers" . DS . "components" . DS . $file);?>

     <?php
    @@ -41,5 +41,5 @@ class Component extends Object {

    : - +

    \ No newline at end of file diff --git a/cake/libs/view/errors/missing_controller.ctp b/cake/libs/view/errors/missing_controller.ctp index 9cff61dc6..bb837a833 100644 --- a/cake/libs/view/errors/missing_controller.ctp +++ b/cake/libs/view/errors/missing_controller.ctp @@ -26,11 +26,11 @@

    : - ".$controller."");?> + " . $controller . "");?>

    : - ".$controller."", APP_DIR.DS."controllers".DS.Inflector::underscore($controller).".php");?> + " . $controller . "", APP_DIR . DS . "controllers" . DS . Inflector::underscore($controller) . ".php");?>

     <?php
    @@ -42,5 +42,5 @@ class  extends AppController {
     

    : - +

    \ No newline at end of file diff --git a/cake/libs/view/errors/missing_helper_class.ctp b/cake/libs/view/errors/missing_helper_class.ctp index d26b760b2..17cb1b2df 100644 --- a/cake/libs/view/errors/missing_helper_class.ctp +++ b/cake/libs/view/errors/missing_helper_class.ctp @@ -30,7 +30,7 @@

    : - +

     <?php
    @@ -41,5 +41,5 @@ class  extends AppHelper {
     

    : - +

    \ No newline at end of file diff --git a/cake/libs/view/errors/missing_helper_file.ctp b/cake/libs/view/errors/missing_helper_file.ctp index d443927d2..34d6d5dc7 100644 --- a/cake/libs/view/errors/missing_helper_file.ctp +++ b/cake/libs/view/errors/missing_helper_file.ctp @@ -1,6 +1,5 @@

    : - +

    : - +

     <?php
    @@ -41,5 +40,5 @@ class  extends AppHelper {
     

    : - -

    \ No newline at end of file + +

    diff --git a/cake/libs/view/errors/missing_layout.ctp b/cake/libs/view/errors/missing_layout.ctp index 245187cd1..d6660624b 100644 --- a/cake/libs/view/errors/missing_layout.ctp +++ b/cake/libs/view/errors/missing_layout.ctp @@ -26,13 +26,13 @@

    : - ". $file ."");?> + " . $file . "");?>

    : - ". $file ."");?> + " . $file . "");?>

    : - +

    \ No newline at end of file diff --git a/cake/libs/view/errors/missing_model.ctp b/cake/libs/view/errors/missing_model.ctp index aad2e2139..76fd10498 100644 --- a/cake/libs/view/errors/missing_model.ctp +++ b/cake/libs/view/errors/missing_model.ctp @@ -30,7 +30,7 @@

    : - ". $model . "", APP_DIR.DS."models".DS.Inflector::underscore($model).".php");?> + " . $model . "", APP_DIR . DS . "models" . DS . Inflector::underscore($model) . ".php");?>

     <?php
    @@ -43,5 +43,5 @@ class  extends AppModel {
     

    : - +

    \ No newline at end of file diff --git a/cake/libs/view/errors/missing_scaffolddb.ctp b/cake/libs/view/errors/missing_scaffolddb.ctp index 56635a528..1f568dfdf 100644 --- a/cake/libs/view/errors/missing_scaffolddb.ctp +++ b/cake/libs/view/errors/missing_scaffolddb.ctp @@ -30,9 +30,9 @@

    : - +

    : - +

    \ No newline at end of file diff --git a/cake/libs/view/errors/missing_table.ctp b/cake/libs/view/errors/missing_table.ctp index f0c8d6757..88e3666d0 100644 --- a/cake/libs/view/errors/missing_table.ctp +++ b/cake/libs/view/errors/missing_table.ctp @@ -26,9 +26,9 @@

    : - ". $table ."", "". $model ."");?> + " . $table . "", "" . $model . "");?>

    : - +

    \ No newline at end of file diff --git a/cake/libs/view/errors/missing_view.ctp b/cake/libs/view/errors/missing_view.ctp index cab8ab87f..676f69253 100644 --- a/cake/libs/view/errors/missing_view.ctp +++ b/cake/libs/view/errors/missing_view.ctp @@ -26,7 +26,7 @@

    : - ". $controller."Controller::", "". $action ."()");?> + " . $controller . "Controller::", "". $action . "()");?>

    : @@ -34,5 +34,5 @@

    : - +

    \ No newline at end of file diff --git a/cake/libs/view/errors/private_action.ctp b/cake/libs/view/errors/private_action.ctp index 7dbf7ccc6..93d857fa0 100644 --- a/cake/libs/view/errors/private_action.ctp +++ b/cake/libs/view/errors/private_action.ctp @@ -26,9 +26,9 @@

    : - ". $controller ."::", "". $action ."()");?> + " . $controller . "::", "" . $action . "()");?>

    : - +

    \ No newline at end of file diff --git a/cake/libs/view/errors/scaffold_error.ctp b/cake/libs/view/errors/scaffold_error.ctp index dee0501e2..146aaf438 100644 --- a/cake/libs/view/errors/scaffold_error.ctp +++ b/cake/libs/view/errors/scaffold_error.ctp @@ -30,7 +30,7 @@

    : - +

     <?php
    diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php
    index c1a92996c..cb9a48e31 100644
    --- a/cake/libs/view/helpers/paginator.php
    +++ b/cake/libs/view/helpers/paginator.php
    @@ -514,15 +514,12 @@ class PaginatorHelper extends AppHelper {
     				$end = $params['page'] + ($modulus  - $params['page']) + 1;
     			}
     
    -			if ($first) {
    -				if ($start > (int)$first) {
    -					if ($start == $first + 1) {
    -						$out .= $this->first($first, array('tag' => $tag, 'after' => $separator, 'separator' => $separator));
    -					} else {
    -						$out .= $this->first($first, array('tag' => $tag, 'separator' => $separator));
    -					}
    -				} elseif ($start == 2) {
    -					$out .= $this->Html->tag($tag, $this->link(1, array('page' => 1), $options)) . $separator;
    +			if ($first && $start > 1) {
    +				$offset = ($start <= (int)$first) ? $start - 1 : $first;
    +				if ($offset < $start - 1) {
    +					$out .= $this->first($offset, array('tag' => $tag, 'separator' => $separator));
    +				} else {
    +					$out .= $this->first($offset, array('tag' => $tag, 'after' => $separator, 'separator' => $separator));
     				}
     			}
     
    @@ -550,15 +547,12 @@ class PaginatorHelper extends AppHelper {
     
     			$out .= $after;
     
    -			if ($last) {
    -				if ($end <= $params['pageCount'] - (int)$last) {
    -					if ($end + 1 == $params['pageCount']) {
    -						$out .= $this->last($last, array('tag' => $tag, 'before' => $separator, 'separator' => $separator));
    -					} else {
    -						$out .= $this->last($last, array('tag' => $tag, 'separator' => $separator));
    -					}
    -				} elseif ($end == $params['pageCount'] - 1) {
    -					$out .= $separator . $this->Html->tag($tag, $this->link($params['pageCount'], array('page' => $params['pageCount']), $options));
    +			if ($last && $end < $params['pageCount']) {
    +				$offset = ($params['pageCount'] < $end + (int)$last) ? $params['pageCount'] - $end : $last;
    +				if ($offset <= $last && $params['pageCount'] - $end > $offset) {
    +					$out .= $this->last($offset, array('tag' => $tag, 'separator' => $separator));
    +				} else {
    +					$out .= $this->last($offset, array('tag' => $tag, 'before' => $separator, 'separator' => $separator));
     				}
     			}
     
    diff --git a/cake/libs/view/scaffolds/edit.ctp b/cake/libs/view/scaffolds/edit.ctp
    index faa4ec440..2ff4171bd 100644
    --- a/cake/libs/view/scaffolds/edit.ctp
    +++ b/cake/libs/view/scaffolds/edit.ctp
    @@ -41,8 +41,8 @@
     		foreach ($associations as $_type => $_data) {
     			foreach ($_data as $_alias => $_details) {
     				if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
    -					echo "\t\t
  • ".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index'))."
  • \n"; - echo "\t\t
  • ".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add'))."
  • \n"; + echo "\t\t
  • " . $html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "
  • \n"; + echo "\t\t
  • " . $html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add')) . "
  • \n"; $done[] = $_details['controller']; } } diff --git a/cake/libs/view/scaffolds/index.ctp b/cake/libs/view/scaffolds/index.ctp index 5f2220ee8..004efccf1 100644 --- a/cake/libs/view/scaffolds/index.ctp +++ b/cake/libs/view/scaffolds/index.ctp @@ -87,8 +87,8 @@ echo "\n"; foreach ($associations as $_type => $_data) { foreach ($_data as $_alias => $_details) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { - echo "\t\t
  • ".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index'))."
  • \n"; - echo "\t\t
  • ".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'))."
  • \n"; + echo "\t\t
  • " . $html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "
  • \n"; + echo "\t\t
  • " . $html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "
  • \n"; $done[] = $_details['controller']; } } diff --git a/cake/libs/view/scaffolds/view.ctp b/cake/libs/view/scaffolds/view.ctp index ef17dbc5c..3b3de10dd 100644 --- a/cake/libs/view/scaffolds/view.ctp +++ b/cake/libs/view/scaffolds/view.ctp @@ -38,14 +38,14 @@ foreach ($scaffoldFields as $_field) { foreach ($associations['belongsTo'] as $_alias => $_details) { if ($_field === $_details['foreignKey']) { $isKey = true; - echo "\t\t".Inflector::humanize($_alias)."\n"; + echo "\t\t" . Inflector::humanize($_alias) . "\n"; echo "\t\t\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t \n"; break; } } } if ($isKey !== true) { - echo "\t\t".Inflector::humanize($_field)."\n"; + echo "\t\t" . Inflector::humanize($_field) . "\n"; echo "\t\t\n\t\t\t{${$singularVar}[$modelClass][$_field]}\n \t\t\n"; } } @@ -64,8 +64,8 @@ foreach ($scaffoldFields as $_field) { foreach ($associations as $_type => $_data) { foreach ($_data as $_alias => $_details) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { - echo "\t\t
  • ".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index'))."
  • \n"; - echo "\t\t
  • ".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'))."
  • \n"; + echo "\t\t
  • " . $html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "
  • \n"; + echo "\t\t
  • " . $html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "
  • \n"; $done[] = $_details['controller']; } } @@ -88,8 +88,8 @@ foreach ($associations['hasOne'] as $_alias => $_details): ?> if ($i++ % 2 == 0) { $class = ' class="altrow"'; } - echo "\t\t".Inflector::humanize($_field)."\n"; - echo "\t\t\n\t" .${$singularVar}[$_alias][$_field] ."\n \n"; + echo "\t\t" . Inflector::humanize($_field) . "\n"; + echo "\t\t\n\t" . ${$singularVar}[$_alias][$_field] . "\n \n"; } ?> @@ -123,7 +123,7 @@ $otherSingularVar = Inflector::variable($_alias); ".Inflector::humanize($_field)."\n"; + echo "\t\t" . Inflector::humanize($_field) . "\n"; } ?> Actions @@ -138,7 +138,7 @@ $otherSingularVar = Inflector::variable($_alias); echo "\t\t\n"; foreach ($otherFields as $_field) { - echo "\t\t\t".${$otherSingularVar}[$_field]."\n"; + echo "\t\t\t" . ${$otherSingularVar}[$_field] . "\n"; } echo "\t\t\t\n"; diff --git a/cake/tests/cases/console/cake.test.php b/cake/tests/cases/console/cake.test.php index 7880acfdc..04900aa9f 100644 --- a/cake/tests/cases/console/cake.test.php +++ b/cake/tests/cases/console/cake.test.php @@ -451,6 +451,25 @@ class ShellDispatcherTest extends CakeTestCase { $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); + + + $params = array( + 'cake.php', + '-working', + 'D:\www', + 'bake', + 'my_app', + ); + $expected = array( + 'working' => 'D:\www', + 'app' => 'www', + 'root' => 'D:', + 'webroot' => 'webroot' + ); + + $Dispatcher->params = $Dispatcher->args = array(); + $Dispatcher->parseParams($params); + $this->assertEqual($expected, $Dispatcher->params); } /** diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 4dcaabb3c..6389823d4 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -539,12 +539,12 @@ class HttpSocketTest extends CakeTestCase { $this->Socket->setReturnValue('read', false); $this->Socket->_mock->_call_counts['read'] = 0; $number = mt_rand(0, 9999999); - $serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

    Hello, your lucky number is ".$number."

    "; + $serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

    Hello, your lucky number is " . $number . "

    "; $this->Socket->setReturnValueAt(0, 'read', $serverResponse); $this->Socket->expect('write', array("GET / HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n\r\n")); $this->Socket->expectCallCount('read', 2); $response = $this->Socket->request($request); - $this->assertIdentical($response, "

    Hello, your lucky number is ".$number."

    "); + $this->assertIdentical($response, "

    Hello, your lucky number is " . $number . "

    "); $this->Socket->reset(); $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

    This is a cookie test!

    "; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 54b6fa3c3..7780a4448 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1705,5 +1705,74 @@ class RouterTest extends CakeTestCase { $this->assertEqual(Router::stripPlugin($url), $url); $this->assertEqual(Router::stripPlugin($url, null), $url); } +/** + * testCurentRoute + * + * This test needs some improvement and actual requestAction() usage + * + * @return void + * @access public + */ + function testCurentRoute() { + $url = array('controller' => 'pages', 'action' => 'display', 'government'); + Router::connect('/government', $url); + Router::parse('/government'); + $route = Router::currentRoute(); + $this->assertEqual(array_merge($url, array('plugin' => false)), $route[3]); + } +/** + * testRequestRoute + * + * @return void + * @access public + */ + function testRequestRoute() { + $url = array('controller' => 'products', 'action' => 'display', 5); + Router::connect('/government', $url); + Router::parse('/government'); + $route = Router::requestRoute(); + $this->assertEqual(array_merge($url, array('plugin' => false)), $route[3]); + + // test that the first route is matched + $newUrl = array('controller' => 'products', 'action' => 'display', 6); + Router::connect('/government', $url); + Router::parse('/government'); + $route = Router::requestRoute(); + $this->assertEqual(array_merge($url, array('plugin' => false)), $route[3]); + + // test that an unmatched route does not change the current route + $newUrl = array('controller' => 'products', 'action' => 'display', 6); + Router::connect('/actor', $url); + Router::parse('/government'); + $route = Router::requestRoute(); + $this->assertEqual(array_merge($url, array('plugin' => false)), $route[3]); + } +/** + * testGetParams + * + * @return void + * @access public + */ + function testGetParams() { + $paths = array('base' => '/', 'here' => '/products/display/5', 'webroot' => '/webroot'); + $params = array('param1' => '1', 'param2' => '2'); + Router::setRequestInfo(array($params, $paths)); + $expected = array( + 'plugin' => false, 'controller' => false, 'action' => false, + 'param1' => '1', 'param2' => '2' + ); + $this->assertEqual(Router::getparams(), $expected); + $this->assertEqual(Router::getparam('controller'), false); + $this->assertEqual(Router::getparam('param1'), '1'); + $this->assertEqual(Router::getparam('param2'), '2'); + + Router::reload(); + + $params = array('controller' => 'pages', 'action' => 'display'); + Router::setRequestInfo(array($params, $paths)); + $expected = array('plugin' => false, 'controller' => 'pages', 'action' => 'display'); + $this->assertEqual(Router::getparams(), $expected); + $this->assertEqual(Router::getparams(true), $expected); + } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/sanitize.test.php b/cake/tests/cases/libs/sanitize.test.php index 16dc92e18..32d15a68e 100644 --- a/cake/tests/cases/libs/sanitize.test.php +++ b/cake/tests/cases/libs/sanitize.test.php @@ -311,8 +311,8 @@ class SanitizeTest extends CakeTestCase { $result = Sanitize::stripScripts($string); $this->assertEqual($result, $expected); - $string = ''."\n".''."\n".''."\n".''; - $expected = "\n".''."\n".''."\n".''; + $string = '' . "\n" . '' . "\n" . '' . "\n" . ''; + $expected = "\n" . '' . "\n" . ''."\n".''; $result = Sanitize::stripScripts($string); $this->assertEqual($result, $expected); diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 7b7c93523..329328ae8 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -765,29 +765,116 @@ class PaginatorHelperTest extends CakeTestCase { 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(); - $expected = '4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12'; - $this->assertEqual($result, $expected); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', + ' | ', + array('span' => array('class' => 'current')), '8', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span', + ); + $this->assertTags($result, $expected); $result = $this->Paginator->numbers(array('tag' => 'li')); - $expected = '
  • 4
  • |
  • 5
  • |
  • 6
  • |
  • 7
  • |
  • 8
  • |
  • 9
  • |
  • 10
  • |
  • 11
  • |
  • 12
  • '; - $this->assertEqual($result, $expected); + $expected = array( + array('li' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/li', + ' | ', + array('li' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/li', + ' | ', + array('li' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/li', + ' | ', + array('li' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/li', + ' | ', + array('li' => array('class' => 'current')), '8', '/li', + ' | ', + array('li' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/li', + ' | ', + array('li' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/li', + ' | ', + array('li' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/li', + ' | ', + array('li' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/li', + ); + $this->assertTags($result, $expected); $result = $this->Paginator->numbers(array('tag' => 'li', 'separator' => false)); - $expected = '
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • '; - $this->assertEqual($result, $expected); + $expected = array( + array('li' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/li', + array('li' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/li', + array('li' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/li', + array('li' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/li', + array('li' => array('class' => 'current')), '8', '/li', + array('li' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/li', + array('li' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/li', + array('li' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/li', + array('li' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/li', + ); + $this->assertTags($result, $expected); $result = $this->Paginator->numbers(true); - $expected = 'first | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | last'; - $this->assertEqual($result, $expected); - + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:1')), 'first', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', + ' | ', + array('span' => array('class' => 'current')), '8', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:15')), 'last', '/a', '/span', + ); + $this->assertTags($result, $expected); + $this->Paginator->params['paging'] = array('Client' => array( 'page' => 1, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(); - $expected = '1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9'; - $this->assertEqual($result, $expected); + $expected = array( + array('span' => array('class' => 'current')), '1', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', + ); + $this->assertTags($result, $expected); + $this->Paginator->params['paging'] = array('Client' => array( 'page' => 14, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, @@ -795,8 +882,26 @@ class PaginatorHelperTest extends CakeTestCase { 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(); - $expected = '7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15'; - $this->assertEqual($result, $expected); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span', + ' | ', + array('span' => array('class' => 'current')), '14', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:15')), '15', '/a', '/span', + ); + $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 2, 'current' => 3, 'count' => 27, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 9, @@ -805,12 +910,48 @@ class PaginatorHelperTest extends CakeTestCase { ); $result = $this->Paginator->numbers(array('first' => 1)); - $expected = '1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9'; - $this->assertEqual($result, $expected); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', + ' | ', + array('span' => array('class' => 'current')), '2', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', + ); + $this->assertTags($result, $expected); $result = $this->Paginator->numbers(array('last' => 1)); - $expected = '1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9'; - $this->assertEqual($result, $expected); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', + ' | ', + array('span' => array('class' => 'current')), '2', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', + ); + $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, @@ -819,8 +960,29 @@ class PaginatorHelperTest extends CakeTestCase { ); $result = $this->Paginator->numbers(array('first' => 1)); - $expected = '1...7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15'; - $this->assertEqual($result, $expected); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', + '...', + array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:14')), '14', '/a', '/span', + ' | ', + array('span' => array('class' => 'current')), '15', '/span', + + ); + $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 10, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, @@ -829,8 +991,30 @@ class PaginatorHelperTest extends CakeTestCase { ); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1)); - $expected = '1...6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15'; - $this->assertEqual($result, $expected); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', + '...', + array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', + ' | ', + array('span' => array('class' => 'current')), '10', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:14')), '14', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:15')), '15', '/a', '/span', + ); + $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 6, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42, @@ -839,8 +1023,30 @@ class PaginatorHelperTest extends CakeTestCase { ); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1)); - $expected = '1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10...42'; - $this->assertEqual($result, $expected); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', + ' | ', + array('span' => array('class' => 'current')), '6', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span', + '...', + array('span' => array()), array('a' => array('href' => '/index/page:42')), '42', '/a', '/span', + ); + $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 37, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42, @@ -849,8 +1055,30 @@ class PaginatorHelperTest extends CakeTestCase { ); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1)); - $expected = '1...33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42'; - $this->assertEqual($result, $expected); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', + '...', + array('span' => array()), array('a' => array('href' => '/index/page:33')), '33', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:34')), '34', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:35')), '35', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:36')), '36', '/a', '/span', + ' | ', + array('span' => array('class' => 'current')), '37', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:38')), '38', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:39')), '39', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:40')), '40', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:41')), '41', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:42')), '42', '/a', '/span', + ); + $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array( 'Client' => array( @@ -876,8 +1104,14 @@ class PaginatorHelperTest extends CakeTestCase { ); $options = array('modulus' => 10); $result = $this->Paginator->numbers($options); - $expected = '1 | 2 | 3'; - $this->assertEqual($result, $expected); + $expected = array( + array('span' => array('class' => 'current')), '1', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', + ); + $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array('Client' => array( 'page' => 2, 'current' => 10, 'count' => 31, 'prevPage' => true, 'nextPage' => true, 'pageCount' => 4, @@ -885,8 +1119,17 @@ class PaginatorHelperTest extends CakeTestCase { 'options' => array('page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $result = $this->Paginator->numbers(); - $expected = '1 | 2 | 3 | 4'; - $this->assertEqual($result, $expected); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:1/sort:Client.name/direction:DESC')), '1', '/a', '/span', + ' | ', + array('span' => array('class' => 'current')), '2', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:3/sort:Client.name/direction:DESC')), '3', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/index/page:4/sort:Client.name/direction:DESC')), '4', '/a', '/span', + ); + $this->assertTags($result, $expected); + $this->Paginator->params['paging'] = array('Client' => array( 'page' => 4895, 'current' => 10, 'count' => 48962, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 4897, @@ -910,11 +1153,7 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Paginator->params['paging'] = array('Client' => array( - 'page' => 3, 'current' => 10, 'count' => 48962, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 4897, - 'defaults' => array('limit' => 10), - 'options' => array('page' => 4894, 'limit' => 10, 'order' => 'Client.name DESC', 'conditions' => array())) - ); + $this->Paginator->params['paging']['Client']['page'] = 3; $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2)); $expected = array( @@ -947,6 +1186,125 @@ class PaginatorHelperTest extends CakeTestCase { array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', ); $this->assertTags($result, $expected); + + $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 5, 'last' => 5, 'separator' => ' - ')); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', + ' - ', + array('span' => array('class' => 'current')), '3', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', + '...', + array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', + ); + $this->assertTags($result, $expected); + + $this->Paginator->params['paging']['Client']['page'] = 4893; + $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - ')); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', + '...', + array('span' => array()), array('a' => array('href' => '/index/page:4891')), '4891', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4892')), '4892', '/a', '/span', + ' - ', + array('span' => array('class' => 'current')), '4893', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', + ); + $this->assertTags($result, $expected); + + $this->Paginator->params['paging']['Client']['page'] = 58; + $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - ')); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span', + '...', + array('span' => array()), array('a' => array('href' => '/index/page:56')), '56', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:57')), '57', '/a', '/span', + ' - ', + array('span' => array('class' => 'current')), '58', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:59')), '59', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:60')), '60', '/a', '/span', + '...', + array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', + ); + $this->assertTags($result, $expected); + + $this->Paginator->params['paging']['Client']['page'] = 5; + $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - ')); + $expected = array( + array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', + ' - ', + array('span' => array('class' => 'current')), '5', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', + '...', + array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span', + ' - ', + array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', + ); + $this->assertTags($result, $expected); } /** diff --git a/cake/tests/lib/cake_reporter.php b/cake/tests/lib/cake_reporter.php index 18ab5f762..0dd954898 100644 --- a/cake/tests/lib/cake_reporter.php +++ b/cake/tests/lib/cake_reporter.php @@ -97,7 +97,6 @@ class CakeHtmlReporter extends SimpleReporter { echo "" . $this->getFailCount() . " fails and "; echo "" . $this->getExceptionCount() . " exceptions."; echo "\n"; - echo "\n\n"; } /**