Merge branch '1.3' into 1.3-console

This commit is contained in:
mark_story 2009-08-01 17:22:39 -04:00
commit f658f17b7e
53 changed files with 1417 additions and 371 deletions

View file

@ -184,6 +184,11 @@
*/ */
Configure::write('Acl.classname', 'DbAcl'); Configure::write('Acl.classname', 'DbAcl');
Configure::write('Acl.database', 'default'); Configure::write('Acl.database', 'default');
/**
* If you are on PHP 5.3 uncomment this line and correct your server timezone
* to fix the date & time related errors.
*/
//date_default_timezone_set('UTC');
/** /**
* *
* Cache Engine Configuration * Cache Engine Configuration

View file

@ -24,7 +24,14 @@
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/ */
error_reporting(E_ALL); /**
* PHP 5.3 raises many notices in bootstrap.
*/
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', 8192);
}
error_reporting(E_ALL & ~E_DEPRECATED);
set_time_limit(0); set_time_limit(0);
ini_set('memory_limit','128M'); ini_set('memory_limit','128M');
ini_set('display_errors', 1); ini_set('display_errors', 1);

View file

@ -22,6 +22,11 @@
if (!defined('PHP5')) { if (!defined('PHP5')) {
define('PHP5', (PHP_VERSION >= 5)); define('PHP5', (PHP_VERSION >= 5));
} }
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', 8192);
}
error_reporting(E_ALL & ~E_DEPRECATED);
require CORE_PATH . 'cake' . DS . 'basics.php'; require CORE_PATH . 'cake' . DS . 'basics.php';
$TIME_START = getMicrotime(); $TIME_START = getMicrotime();
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php'; require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';

View file

@ -135,15 +135,21 @@ class ShellDispatcher {
/** /**
* Constructor * Constructor
* *
* @param array $args the argv. * The execution of the script is stopped after dispatching the request with
* a status code of either 0 or 1 according to the result of the dispatch.
*
* @param array $args the argv
* @return void
* @access public
*/ */
function __construct($args = array()) { function __construct($args = array()) {
set_time_limit(0); set_time_limit(0);
$this->__initConstants(); $this->__initConstants();
$this->parseParams($args); $this->parseParams($args);
$this->_initEnvironment(); $this->_initEnvironment();
$this->__buildPaths(); $this->__buildPaths();
$this->_stop($this->dispatch()); $this->_stop($this->dispatch() === false ? 1 : 0);
} }
/** /**
@ -305,118 +311,134 @@ class ShellDispatcher {
/** /**
* Dispatches a CLI request * Dispatches a CLI request
* *
* @return boolean
* @access public * @access public
*/ */
function dispatch() { function dispatch() {
if (isset($this->args[0])) { $arg = $this->shiftArgs();
$plugin = null;
$shell = $this->args[0];
if (strpos($shell, '.') !== false) {
list($plugin, $shell) = explode('.', $this->args[0]);
}
$this->shell = $shell; if (!$arg) {
$this->shiftArgs();
$this->shellName = Inflector::camelize($this->shell);
$this->shellClass = $this->shellName . 'Shell';
if ($this->shell === 'help') {
$this->help();
} else {
$loaded = false;
foreach ($this->shellPaths as $path) {
$this->shellPath = $path . $this->shell . '.php';
$isPlugin = ($plugin && strpos($path, DS . $plugin . DS . 'vendors' . DS . 'shells' . DS) !== false);
if (($isPlugin && file_exists($this->shellPath)) || (!$plugin && file_exists($this->shellPath))) {
$loaded = true;
break;
}
}
if ($loaded) {
if (!class_exists('Shell')) {
require CONSOLE_LIBS . 'shell.php';
}
require $this->shellPath;
if (class_exists($this->shellClass)) {
$command = null;
if (isset($this->args[0])) {
$command = $this->args[0];
}
$this->shellCommand = Inflector::variable($command);
$shell = new $this->shellClass($this);
if (strtolower(get_parent_class($shell)) == 'shell') {
$shell->initialize();
$shell->loadTasks();
foreach ($shell->taskNames as $task) {
if (strtolower(get_parent_class($shell)) == 'shell') {
$shell->{$task}->initialize();
$shell->{$task}->loadTasks();
}
}
$task = Inflector::camelize($command);
if (in_array($task, $shell->taskNames)) {
$this->shiftArgs();
$shell->{$task}->startup();
if (isset($this->args[0]) && $this->args[0] == 'help') {
if (method_exists($shell->{$task}, 'help')) {
$shell->{$task}->help();
$this->_stop();
} else {
$this->help();
}
}
return $shell->{$task}->execute();
}
}
$classMethods = get_class_methods($shell);
$privateMethod = $missingCommand = false;
if ((in_array($command, $classMethods) || in_array(strtolower($command), $classMethods)) && strpos($command, '_', 0) === 0) {
$privateMethod = true;
}
if (!in_array($command, $classMethods) && !in_array(strtolower($command), $classMethods)) {
$missingCommand = true;
}
$protectedCommands = array(
'initialize','in','out','err','hr',
'createfile', 'isdir','copydir','object','tostring',
'requestaction','log','cakeerror', 'shelldispatcher',
'__initconstants','__initenvironment','__construct',
'dispatch','__bootstrap','getinput','stdout','stderr','parseparams','shiftargs'
);
if (in_array(strtolower($command), $protectedCommands)) {
$missingCommand = true;
}
if ($missingCommand && method_exists($shell, 'main')) {
$shell->startup();
return $shell->main();
} elseif (!$privateMethod && method_exists($shell, $command)) {
$this->shiftArgs();
$shell->startup();
return $shell->{$command}();
} else {
$this->stderr("Unknown {$this->shellName} command '$command'.\nFor usage, try 'cake {$this->shell} help'.\n\n");
}
} else {
$this->stderr('Class '.$this->shellClass.' could not be loaded');
}
} else {
$this->help();
}
}
} else {
$this->help(); $this->help();
return false;
} }
if ($arg == 'help') {
$this->help();
return true;
}
if (strpos($arg, '.') !== false) {
list($plugin, $shell) = explode('.', $arg);
} else {
$plugin = null;
$shell = $arg;
}
$this->shell = $shell;
$this->shellName = Inflector::camelize($shell);
$this->shellClass = $this->shellName . 'Shell';
$arg = null;
if (isset($this->args[0])) {
$arg = $this->args[0];
$this->shellCommand = Inflector::variable($arg);
}
$Shell = $this->_getShell($plugin);
if (!$Shell) {
$title = sprintf(__('Error: Class %s could not be loaded.', true), $this->shellClass);
$this->stderr($title . "\n");
return false;
}
$methods = array();
if (is_a($Shell, 'Shell')) {
$Shell->initialize();
$Shell->loadTasks();
foreach ($Shell->taskNames as $task) {
if (is_a($Shell->{$task}, 'Shell')) {
$Shell->{$task}->initialize();
$Shell->{$task}->loadTasks();
}
}
$task = Inflector::camelize($arg);
if (in_array($task, $Shell->taskNames)) {
$this->shiftArgs();
$Shell->{$task}->startup();
if (isset($this->args[0]) && $this->args[0] == 'help') {
if (method_exists($Shell->{$task}, 'help')) {
$Shell->{$task}->help();
} else {
$this->help();
}
return true;
}
return $Shell->{$task}->execute();
}
$methods = array_diff(get_class_methods('Shell'), array('help'));
}
$methods = array_diff(get_class_methods($Shell), $methods);
$added = in_array(strtolower($arg), array_map('strtolower', $methods));
$private = $arg[0] == '_' && method_exists($Shell, $arg);
if (!$private) {
if ($added) {
$this->shiftArgs();
$Shell->startup();
return $Shell->{$arg}();
}
if (method_exists($Shell, 'main')) {
$Shell->startup();
return $Shell->main();
}
}
$title = sprintf(__('Error: Unknown %1$s command %2$s.', true), $this->shellName, $arg);
$message = sprintf(__('For usage try `cake %s help`', true), $this->shell);
$this->stderr($title . "\n" . $message . "\n");
return false;
}
/**
* Get shell to use, either plugin shell or application shell
*
* All paths in the shellPaths property are searched.
* shell, shellPath and shellClass properties are taken into account.
*
* @param string $plugin Optionally the name of a plugin
* @return mixed False if no shell could be found or an object on success
* @access protected
*/
function _getShell($plugin = null) {
foreach ($this->shellPaths as $path) {
$this->shellPath = $path . $this->shell . '.php';
$pluginShellPath = DS . $plugin . DS . 'vendors' . DS . 'shells' . DS;
if ((strpos($path, $pluginShellPath) !== false || !$plugin) && file_exists($this->shellPath)) {
$loaded = true;
break;
}
}
if (!isset($loaded)) {
return false;
}
if (!class_exists('Shell')) {
require CONSOLE_LIBS . 'shell.php';
}
if (!class_exists($this->shellClass)) {
require $this->shellPath;
}
if (!class_exists($this->shellClass)) {
return false;
}
$Shell = new $this->shellClass($this);
return $Shell;
} }
/** /**
@ -475,7 +497,7 @@ class ShellDispatcher {
* @access public * @access public
*/ */
function stderr($string) { function stderr($string) {
fwrite($this->stderr, 'Error: '. $string); fwrite($this->stderr, $string);
} }
/** /**
@ -486,13 +508,15 @@ class ShellDispatcher {
*/ */
function parseParams($params) { function parseParams($params) {
$this->__parseParams($params); $this->__parseParams($params);
$defaults = array('app' => 'app', 'root' => dirname(dirname(dirname(__FILE__))), 'working' => null, 'webroot' => 'webroot'); $defaults = array('app' => 'app', 'root' => dirname(dirname(dirname(__FILE__))), 'working' => null, 'webroot' => 'webroot');
$params = array_merge($defaults, array_intersect_key($this->params, $defaults)); $params = array_merge($defaults, array_intersect_key($this->params, $defaults));
$isWin = false;
$isWin = array_filter(array_map('strpos', $params, array('\\'))); foreach ($defaults as $default => $value) {
if (strpos($params[$default], '\\') !== false) {
$isWin = true;
break;
}
}
$params = str_replace('\\', '/', $params); $params = str_replace('\\', '/', $params);
if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0]{0} !== '.')) { if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0]{0} !== '.')) {
@ -504,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']); $params['root'] = dirname($params['app']);
} elseif (strpos($params['app'], '/')) { } elseif (strpos($params['app'], '/')) {
$params['root'] .= '/' . dirname($params['app']); $params['root'] .= '/' . dirname($params['app']);
@ -521,7 +545,7 @@ class ShellDispatcher {
} }
/** /**
* Helper for recursively paraing params * Helper for recursively parsing params
* *
* @return array params * @return array params
* @access private * @access private
@ -555,16 +579,11 @@ class ShellDispatcher {
/** /**
* Removes first argument and shifts other arguments up * Removes first argument and shifts other arguments up
* *
* @return boolean False if there are no arguments * @return mixed Null if there are no arguments otherwise the shifted argument
* @access public * @access public
*/ */
function shiftArgs() { function shiftArgs() {
if (empty($this->args)) { return array_shift($this->args);
return false;
}
unset($this->args[0]);
$this->args = array_values($this->args);
return true;
} }
/** /**
@ -603,6 +622,7 @@ class ShellDispatcher {
} else { } else {
sort($shells); sort($shells);
foreach ($shells as $shell) { foreach ($shells as $shell) {
if ($shell !== 'shell.php') { if ($shell !== 'shell.php') {
$this->stdout("\t " . str_replace('.php', '', $shell)); $this->stdout("\t " . str_replace('.php', '', $shell));
} }
@ -612,7 +632,6 @@ class ShellDispatcher {
} }
$this->stdout("\nTo run a command, type 'cake shell_name [args]'"); $this->stdout("\nTo run a command, type 'cake shell_name [args]'");
$this->stdout("To get help on a specific command, type 'cake shell_name help'"); $this->stdout("To get help on a specific command, type 'cake shell_name help'");
$this->_stop();
} }
/** /**

View file

@ -157,7 +157,7 @@ class BakeShell extends Shell {
$object = new $model(); $object = new $model();
$modelExists = true; $modelExists = true;
} else { } else {
App::import('Model'); App::import('Model', 'Model', false);
$object = new Model(array('name' => $name, 'ds' => $this->connection)); $object = new Model(array('name' => $name, 'ds' => $this->connection));
} }

View file

@ -27,7 +27,7 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
App::import('File'); App::import('File');
App::import('Model', 'CakeSchema'); App::import('Model', 'CakeSchema', false);
/** /**
* Schema is a command-line database management utility for automating programmer chores. * Schema is a command-line database management utility for automating programmer chores.
@ -208,7 +208,7 @@ class SchemaShell extends Shell {
} }
} }
$db =& ConnectionManager::getDataSource($this->Schema->connection); $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); $contents .= $db->dropSchema($Schema) . "\n\n". $db->createSchema($Schema);
if ($write) { if ($write) {
if (strpos($write, '.sql') === false) { if (strpos($write, '.sql') === false) {

View file

@ -320,7 +320,7 @@ class Shell extends Object {
} }
if (!isset($this->{$taskName})) { if (!isset($this->{$taskName})) {
$this->err("Task '".$taskName."' could not be loaded"); $this->err("Task '" . $taskName . "' could not be loaded");
$this->_stop(); $this->_stop();
} }
} }
@ -363,69 +363,78 @@ class Shell extends Object {
} }
/** /**
* Outputs to the stdout filehandle. * Outputs a single or multiple messages to stdout.
* *
* @param string $string String to output. * @param mixed $message A string or a an array of strings to output
* @param boolean $newline If true, the outputs gets an added newline. * @param mixed $after Appended to message, if true a newline is used
* @access public * @access public
*/ */
function out($string, $newline = true) { function out($message, $after = true) {
if (is_array($string)) { if (is_array($message)) {
$str = ''; $message = implode($this->nl(), $message);
foreach ($string as $message) {
$str .= $message ."\n";
}
$string = $str;
} }
return $this->Dispatch->stdout($string, $newline); $this->Dispatch->stdout($message . $this->nl($after), false);
} }
/** /**
* Outputs to the stderr filehandle. * Outputs a single or multiple error messages to stderr.
* *
* @param string $string Error text to output. * @param mixed $message A string or a an array of strings to output
* @param mixed $after Appended to message, if true a newline is used
* @access public * @access public
*/ */
function err($string) { function err($message, $after = true) {
if (is_array($string)) { if (is_array($message)) {
$str = ''; $message = implode($this->nl(), $message);
foreach ($string as $message) {
$str .= $message ."\n";
}
$string = $str;
} }
return $this->Dispatch->stderr($string."\n"); $this->Dispatch->stderr($message . $this->nl($after));
}
/**
* Returns a single or multiple linefeeds sequences.
*
* @param mixed $format If true returns a linefeed sequence, if false null,
* if a string is given that is returned,
* if an integer is given it is used as a multiplier to return multiple linefeed sequences
* @access public
* @return string
*/
function nl($format = true) {
if (is_string($format)) {
return $format . "\n";
}
if (is_int($format)) {
return str_repeat("\n", $format);
}
return $format ? "\n" : null;
} }
/** /**
* Outputs a series of minus characters to the standard output, acts as a visual separator. * Outputs a series of minus characters to the standard output, acts as a visual separator.
* *
* @param boolean $newline If true, the outputs gets an added newline. * @param mixed $surround If true, the outputs gets surrounded by newlines.
* @access public * @access public
*/ */
function hr($newline = false) { function hr($surround = false) {
if ($newline) { $this->out(null, $surround);
$this->out("\n");
}
$this->out('---------------------------------------------------------------'); $this->out('---------------------------------------------------------------');
if ($newline) { $this->out(null, $surround);
$this->out("\n");
}
} }
/** /**
* Displays a formatted error message and exits the application * Displays a formatted error message
* and exits the application with status code 1
* *
* @param string $title Title of the error message * @param string $title Title of the error
* @param string $msg Error message * @param string $message An optional error message
* @access public * @access public
*/ */
function error($title, $msg) { function error($title, $message = null) {
$out = "$title\n"; $this->err(sprintf(__('Error: %s', true), $title));
$out .= "$msg\n";
$out .= "\n"; if (!empty($message)) {
$this->err($out); $this->err($message);
$this->_stop(); }
$this->_stop(1);
} }
/** /**

View file

@ -74,7 +74,7 @@ class FixtureTask extends Shell {
parent::__construct($dispatch); parent::__construct($dispatch);
$this->path = $this->params['working'] . DS . 'tests' . DS . 'fixtures' . DS; $this->path = $this->params['working'] . DS . 'tests' . DS . 'fixtures' . DS;
if (!class_exists('CakeSchema')) { if (!class_exists('CakeSchema')) {
App::import('Model', 'CakeSchema'); App::import('Model', 'CakeSchema', false);
} }
} }
@ -384,7 +384,7 @@ class FixtureTask extends Shell {
while (!$condition) { while (!$condition) {
$condition = $this->in($prompt, null, 'WHERE 1=1 LIMIT 10'); $condition = $this->in($prompt, null, 'WHERE 1=1 LIMIT 10');
} }
App::import('Core', 'Model'); App::import('Model', 'Model', false);
$modelObject =& new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection)); $modelObject =& new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
$records = $modelObject->find('all', array( $records = $modelObject->find('all', array(
'conditions' => $condition, 'conditions' => $condition,

View file

@ -20,7 +20,7 @@
* @since CakePHP(tm) v 1.2 * @since CakePHP(tm) v 1.2
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
App::import('Model', 'ConnectionManager'); App::import('Model', 'Model', false);
/** /**
* Task class for creating and updating model files. * Task class for creating and updating model files.
@ -82,7 +82,6 @@ class ModelTask extends Shell {
* @return void * @return void
**/ **/
function startup() { function startup() {
App::import('Core', 'Model');
parent::startup(); parent::startup();
} }

View file

@ -155,7 +155,7 @@ class ProjectTask extends Shell {
$this->out(sprintf(__("Created: %s in %s", true), $app, $path)); $this->out(sprintf(__("Created: %s in %s", true), $app, $path));
$this->hr(); $this->hr();
} else { } else {
$this->err(" '".$app."' could not be created properly"); $this->err(" '" . $app . "' could not be created properly");
return false; return false;
} }
@ -224,7 +224,7 @@ class ProjectTask extends Shell {
$File =& new File($path . 'webroot' . DS . 'index.php'); $File =& new File($path . 'webroot' . DS . 'index.php');
$contents = $File->read(); $contents = $File->read();
if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_CORE_INCLUDE_PATH\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) { 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)) { if (!$File->write($result)) {
return false; return false;
} }
@ -235,7 +235,7 @@ class ProjectTask extends Shell {
$File =& new File($path . 'webroot' . DS . 'test.php'); $File =& new File($path . 'webroot' . DS . 'test.php');
$contents = $File->read(); $contents = $File->read();
if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_CORE_INCLUDE_PATH\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) { 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)) { if (!$File->write($result)) {
return false; return false;
} }

View file

@ -20,7 +20,7 @@
* @since CakePHP(tm) v 1.2 * @since CakePHP(tm) v 1.2
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
App::import('Core', 'Controller'); App::import('Controller', 'Controller', false);
/** /**
* Task class for creating and updating view files. * Task class for creating and updating view files.

View file

@ -26,7 +26,7 @@
<div class="<?php echo $pluralVar;?> form"> <div class="<?php echo $pluralVar;?> form">
<?php echo "<?php echo \$form->create('{$modelClass}');?>\n";?> <?php echo "<?php echo \$form->create('{$modelClass}');?>\n";?>
<fieldset> <fieldset>
<legend><?php echo "<?php __('".Inflector::humanize($action)." {$singularHumanName}');?>";?></legend> <legend><?php echo "<?php __('" . Inflector::humanize($action) . " {$singularHumanName}');?>";?></legend>
<?php <?php
echo "\t<?php\n"; echo "\t<?php\n";
foreach ($fields as $field) { foreach ($fields as $field) {
@ -59,8 +59,8 @@
foreach ($associations as $type => $data) { foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) { foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n"; echo "\t\t<li><?php echo \$html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n"; echo "\t\t<li><?php echo \$html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller']; $done[] = $details['controller'];
} }
} }

View file

@ -1,5 +1,5 @@
<?php <?php
$output = "<h2>Sweet, \"".Inflector::humanize($app)."\" got Baked by CakePHP!</h2>\n"; $output = "<h2>Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!</h2>\n";
$output .=" $output .="
<?php <?php
if (Configure::read() > 0): if (Configure::read() > 0):

View file

@ -89,8 +89,8 @@ echo "<?php endforeach; ?>\n";
foreach ($associations as $type => $data) { foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) { foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n"; echo "\t\t<li><?php echo \$html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n"; echo "\t\t<li><?php echo \$html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller']; $done[] = $details['controller'];
} }
} }

View file

@ -33,14 +33,14 @@ foreach ($fields as $field) {
foreach ($associations['belongsTo'] as $alias => $details) { foreach ($associations['belongsTo'] as $alias => $details) {
if ($field === $details['foreignKey']) { if ($field === $details['foreignKey']) {
$isKey = true; $isKey = true;
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize(Inflector::underscore($alias))."'); ?></dt>\n"; echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('" . Inflector::humanize(Inflector::underscore($alias)) . "'); ?></dt>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n"; echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
break; break;
} }
} }
} }
if ($isKey !== true) { if ($isKey !== true) {
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize($field)."'); ?></dt>\n"; echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('" . Inflector::humanize($field) . "'); ?></dt>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \${$singularVar}['{$modelClass}']['{$field}']; ?>\n\t\t\t&nbsp;\n\t\t</dd>\n"; echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \${$singularVar}['{$modelClass}']['{$field}']; ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
} }
} }
@ -59,8 +59,8 @@ foreach ($fields as $field) {
foreach ($associations as $type => $data) { foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) { foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n"; echo "\t\t<li><?php echo \$html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n"; echo "\t\t<li><?php echo \$html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller']; $done[] = $details['controller'];
} }
} }
@ -72,12 +72,12 @@ foreach ($fields as $field) {
if (!empty($associations['hasOne'])) : if (!empty($associations['hasOne'])) :
foreach ($associations['hasOne'] as $alias => $details): ?> foreach ($associations['hasOne'] as $alias => $details): ?>
<div class="related"> <div class="related">
<h3><?php echo "<?php __('Related ".Inflector::humanize($details['controller'])."');?>";?></h3> <h3><?php echo "<?php __('Related " . Inflector::humanize($details['controller']) . "');?>";?></h3>
<?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?> <?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
<dl><?php echo "\t<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?> <dl><?php echo "\t<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?>
<?php <?php
foreach ($details['fields'] as $field) { foreach ($details['fields'] as $field) {
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize($field)."');?></dt>\n"; echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('" . Inflector::humanize($field) . "');?></dt>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t<?php echo \${$singularVar}['{$alias}']['{$field}'];?>\n&nbsp;</dd>\n"; echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t<?php echo \${$singularVar}['{$alias}']['{$field}'];?>\n&nbsp;</dd>\n";
} }
?> ?>
@ -85,7 +85,7 @@ if (!empty($associations['hasOne'])) :
<?php echo "<?php endif; ?>\n";?> <?php echo "<?php endif; ?>\n";?>
<div class="actions"> <div class="actions">
<ul> <ul>
<li><?php echo "<?php echo \$html->link(__('Edit ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?> <li><?php echo "<?php echo \$html->link(__('Edit " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?>
</ul> </ul>
</div> </div>
</div> </div>
@ -111,7 +111,7 @@ foreach ($relations as $alias => $details):
<tr> <tr>
<?php <?php
foreach ($details['fields'] as $field) { foreach ($details['fields'] as $field) {
echo "\t\t<th><?php __('".Inflector::humanize($field)."'); ?></th>\n"; echo "\t\t<th><?php __('" . Inflector::humanize($field) . "'); ?></th>\n";
} }
?> ?>
<th class="actions"><?php echo "<?php __('Actions');?>";?></th> <th class="actions"><?php echo "<?php __('Actions');?>";?></th>
@ -144,7 +144,7 @@ echo "\t<?php endforeach; ?>\n";
<?php echo "<?php endif; ?>\n\n";?> <?php echo "<?php endif; ?>\n\n";?>
<div class="actions"> <div class="actions">
<ul> <ul>
<li><?php echo "<?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li> <li><?php echo "<?php echo \$html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li>
</ul> </ul>
</div> </div>
</div> </div>

View file

@ -26,7 +26,7 @@
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
App::import('Core', 'Helper'); App::import('Helper', 'Helper', false);
/** /**
* This is a placeholder class. * This is a placeholder class.

View file

@ -190,6 +190,11 @@
Configure::write('Acl.classname', 'DbAcl'); Configure::write('Acl.classname', 'DbAcl');
Configure::write('Acl.database', 'default'); Configure::write('Acl.database', 'default');
/**
* If you are on PHP 5.3 uncomment this line and correct your server timezone
* to fix the date & time related errors.
*/
//date_default_timezone_set('UTC');
/** /**
* *
* Cache Engine Configuration * Cache Engine Configuration

View file

@ -25,7 +25,14 @@
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/ */
error_reporting(E_ALL); /**
* PHP 5.3 raises many notices in bootstrap.
*/
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', 8192);
}
error_reporting(E_ALL & ~E_DEPRECATED);
set_time_limit(0); set_time_limit(0);
ini_set('memory_limit','128M'); ini_set('memory_limit','128M');
ini_set('display_errors', 1); ini_set('display_errors', 1);

View file

@ -226,7 +226,7 @@ class Dispatcher extends Object {
if (!isset($methods[strtolower($params['action'])])) { if (!isset($methods[strtolower($params['action'])])) {
if ($controller->scaffold !== false) { if ($controller->scaffold !== false) {
App::import('Core', 'Scaffold'); App::import('Controller', 'Scaffold', false);
return new Scaffold($controller, $params); return new Scaffold($controller, $params);
} }
return $this->cakeError('missingAction', array(array( return $this->cakeError('missingAction', array(array(

View file

@ -107,7 +107,7 @@ class Configure extends Object {
if (isset($config['debug'])) { if (isset($config['debug'])) {
if ($_this->debug) { if ($_this->debug) {
error_reporting(E_ALL); error_reporting(E_ALL & ~E_DEPRECATED);
if (function_exists('ini_set')) { if (function_exists('ini_set')) {
ini_set('display_errors', 1); ini_set('display_errors', 1);
@ -844,7 +844,7 @@ class App extends Object {
} }
} }
if (!App::import($tempType, $plugin . $class)) { if (!App::import($tempType, $plugin . $class, $parent)) {
return false; return false;
} }
} }
@ -866,7 +866,7 @@ class App extends Object {
if ($name != null && !class_exists($name . $ext['class'])) { if ($name != null && !class_exists($name . $ext['class'])) {
if ($load = $_this->__mapped($name . $ext['class'], $type, $plugin)) { if ($load = $_this->__mapped($name . $ext['class'], $type, $plugin)) {
if ($_this->__load($load)) { if ($_this->__load($load)) {
$_this->__overload($type, $name . $ext['class']); $_this->__overload($type, $name . $ext['class'], $parent);
if ($_this->return) { if ($_this->return) {
$value = include $load; $value = include $load;
@ -908,7 +908,7 @@ class App extends Object {
if ($directory !== null) { if ($directory !== null) {
$_this->__cache = true; $_this->__cache = true;
$_this->__map($directory . $file, $name . $ext['class'], $type, $plugin); $_this->__map($directory . $file, $name . $ext['class'], $type, $plugin);
$_this->__overload($type, $name . $ext['class']); $_this->__overload($type, $name . $ext['class'], $parent);
if ($_this->return) { if ($_this->return) {
$value = include $directory . $file; $value = include $directory . $file;
@ -1058,8 +1058,8 @@ class App extends Object {
* @param string $name Class name to overload * @param string $name Class name to overload
* @access private * @access private
*/ */
function __overload($type, $name) { function __overload($type, $name, $parent) {
if (($type === 'Model' || $type === 'Helper') && strtolower($name) != 'schema') { if (($type === 'Model' || $type === 'Helper') && $parent !== false) {
Overloadable::overload($name); Overloadable::overload($name);
} }
} }
@ -1088,10 +1088,10 @@ class App extends Object {
switch ($load) { switch ($load) {
case 'model': case 'model':
if (!class_exists('Model')) { if (!class_exists('Model')) {
App::import('Model', 'Model', false, App::core('models')); require LIBS . 'model' . DS . 'model.php';
} }
if (!class_exists('AppModel')) { if (!class_exists('AppModel')) {
App::import($type, 'AppModel', false, App::path('models')); App::import($type, 'AppModel', false);
} }
if ($plugin) { if ($plugin) {
if (!class_exists($plugin . 'AppModel')) { if (!class_exists($plugin . 'AppModel')) {

View file

@ -219,10 +219,10 @@ class CookieComponent extends Object {
if (count($name) > 1) { if (count($name) > 1) {
$this->__values[$name[0]][$name[1]] = $value; $this->__values[$name[0]][$name[1]] = $value;
$this->__write("[".$name[0]."][".$name[1]."]", $value); $this->__write("[" . $name[0] . "][" . $name[1] . "]", $value);
} else { } else {
$this->__values[$name[0]] = $value; $this->__values[$name[0]] = $value;
$this->__write("[".$name[0]."]", $value); $this->__write("[" . $name[0] . "]", $value);
} }
} else { } else {
foreach ($key as $names => $value) { foreach ($key as $names => $value) {
@ -230,10 +230,10 @@ class CookieComponent extends Object {
if (count($name) > 1) { if (count($name) > 1) {
$this->__values[$name[0]][$name[1]] = $value; $this->__values[$name[0]][$name[1]] = $value;
$this->__write("[".$name[0]."][".$name[1]."]", $value); $this->__write("[" . $name[0] . "][" . $name[1] . "]", $value);
} else { } else {
$this->__values[$name[0]] = $value; $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); $name = $this->__cookieVarNames($key);
if (count($name) > 1) { if (count($name) > 1) {
if (isset($this->__values[$name[0]])) { 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]]); unset($this->__values[$name[0]][$name[1]]);
} }
} else { } else {
if (isset($this->__values[$name[0]])) { if (isset($this->__values[$name[0]])) {
if (is_array($this->__values[$name[0]])) { if (is_array($this->__values[$name[0]])) {
foreach ($this->__values[$name[0]] as $key => $value) { 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]]); unset($this->__values[$name[0]]);
} }
} }

View file

@ -254,7 +254,7 @@ class Debugger extends Object {
* @access public * @access public
*/ */
function handleError($code, $description, $file = null, $line = null, $context = null) { function handleError($code, $description, $file = null, $line = null, $context = null) {
if (error_reporting() == 0 || $code === 2048) { if (error_reporting() == 0 || $code === 2048 || $code === 8192) {
return; return;
} }

View file

@ -212,10 +212,10 @@ class HttpSocket extends CakeSocket {
} }
if (isset($this->request['auth']['user']) && isset($this->request['auth']['pass'])) { 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'])) { 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'])) { if (is_array($this->request['body'])) {
@ -836,7 +836,7 @@ class HttpSocket extends CakeSocket {
return false; return false;
} }
preg_match_all("/(.+):(.+)(?:(?<![\t ])".$this->lineBreak."|\$)/Uis", $header, $matches, PREG_SET_ORDER); preg_match_all("/(.+):(.+)(?:(?<![\t ])" . $this->lineBreak . "|\$)/Uis", $header, $matches, PREG_SET_ORDER);
$header = array(); $header = array();
foreach ($matches as $match) { foreach ($matches as $match) {

View file

@ -449,10 +449,11 @@ class Inflector extends Object {
'/Ü/' => 'Ue', '/Ü/' => 'Ue',
'/Ö/' => 'Oe', '/Ö/' => 'Oe',
'/ß/' => 'ss', '/ß/' => 'ss',
'/[^\w\s]/' => ' ', '/[^\s\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/mu' => ' ',
'/\\s+/' => $replacement, '/\\s+/' => $replacement,
sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '', sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
); );
$map = array_merge($default, $map); $map = array_merge($default, $map);
return preg_replace(array_keys($map), array_values($map), $string); return preg_replace(array_keys($map), array_values($map), $string);
} }

View file

@ -352,7 +352,7 @@ class CakeSchema extends Object {
$col = "\t\t'indexes' => array("; $col = "\t\t'indexes' => array(";
$props = array(); $props = array();
foreach ((array)$value as $key => $index) { foreach ((array)$value as $key => $index) {
$props[] = "'{$key}' => array(".join(', ', $this->__values($index)).")"; $props[] = "'{$key}' => array(" . join(', ', $this->__values($index)) . ")";
} }
$col .= join(', ', $props); $col .= join(', ', $props);
} }
@ -462,7 +462,7 @@ class CakeSchema extends Object {
if (is_array($values)) { if (is_array($values)) {
foreach ($values as $key => $val) { foreach ($values as $key => $val) {
if (is_array($val)) { if (is_array($val)) {
$vals[] = "'{$key}' => array('".join("', '", $val)."')"; $vals[] = "'{$key}' => array('" . join("', '", $val) . "')";
} else if (!is_numeric($key)) { } else if (!is_numeric($key)) {
$val = var_export($val, true); $val = var_export($val, true);
$vals[] = "'{$key}' => {$val}"; $vals[] = "'{$key}' => {$val}";

View file

@ -112,9 +112,8 @@ class DboMysqli extends DboMysqlBase {
function _execute($sql) { function _execute($sql) {
if (preg_match('/^\s*call/i', $sql)) { if (preg_match('/^\s*call/i', $sql)) {
return $this->_executeProcedure($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) { if (!$result) {
return array(); 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) { if ($parent != null) {
return $parent; return $parent;
} }
if ($data === null || (is_array($data) && empty($data))) {
if ($data === null) {
return 'NULL'; return 'NULL';
} }
if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') { if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') {
return "''"; return "''";
}
if (empty($column)) {
$column = $this->introspectType($data);
} }
switch ($column) { switch ($column) {
case 'boolean': case 'boolean':
$data = $this->boolean((bool)$data); return $this->boolean((bool)$data);
break; break;
case 'integer' : case 'integer' :
case 'float' : case 'float' :
@ -293,7 +293,6 @@ class DboMysqli extends DboMysqlBase {
if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0]['insertID'])) { if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0]['insertID'])) {
return $id[0]['insertID']; return $id[0]['insertID'];
} }
return null; return null;
} }
@ -354,11 +353,11 @@ class DboMysqli extends DboMysqlBase {
function length($real) { function length($real) {
$col = str_replace(array(')', 'unsigned'), '', $real); $col = str_replace(array(')', 'unsigned'), '', $real);
$limit = null; $limit = null;
if (strpos($col, '(') !== false) { if (strpos($col, '(') !== false) {
list($col, $limit) = explode('(', $col); list($col, $limit) = explode('(', $col);
} }
if ($limit != null) { if ($limit != null) {
return intval($limit); return intval($limit);
} }
@ -408,9 +407,8 @@ class DboMysqli extends DboMysqlBase {
$i++; $i++;
} }
return $resultRow; return $resultRow;
} else {
return false;
} }
return false;
} }
/** /**

View file

@ -334,9 +334,9 @@ class Router extends Object {
/** /**
* Builds a route regular expression * Builds a route regular expression
* *
* @param string $route An empty string, or a route string "/" * @param string $route An empty string, or a route string "/"
* @param array $default NULL or an array describing the default route * @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 array $params An array matching the named elements in the route to regular expressions which that element should match.
* @return array * @return array
* @see routes * @see routes
* @access public * @access public
@ -560,10 +560,7 @@ class Router extends Object {
function compile($i) { function compile($i) {
$route = $this->routes[$i]; $route = $this->routes[$i];
if (!list($pattern, $names) = $this->writeRoute($route[0], $route[1], $route[2])) { list($pattern, $names) = $this->writeRoute($route[0], $route[1], $route[2]);
unset($this->routes[$i]);
return array();
}
$this->routes[$i] = array( $this->routes[$i] = array(
$route[0], $pattern, $names, $route[0], $pattern, $names,
array_merge(array('plugin' => null, 'controller' => null), (array)$route[1]), array_merge(array('plugin' => null, 'controller' => null), (array)$route[1]),
@ -1317,9 +1314,9 @@ class Router extends Object {
return $param; return $param;
} }
$return = preg_replace('/^(?:[\\t ]*(?:-!)+)/', '', $param); return preg_replace('/^(?:[\\t ]*(?:-!)+)/', '', $param);
return $return;
} }
foreach ($param as $key => $value) { foreach ($param as $key => $value) {
if (is_string($value)) { if (is_string($value)) {
$return[$key] = preg_replace('/^(?:[\\t ]*(?:-!)+)/', '', $value); $return[$key] = preg_replace('/^(?:[\\t ]*(?:-!)+)/', '', $value);
@ -1394,7 +1391,9 @@ class Router extends Object {
continue; continue;
} }
$param = $_this->stripEscape($param); $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); list($key, $val) = explode($_this->named['separator'], $param, 2);
$hasRule = isset($rules[$key]); $hasRule = isset($rules[$key]);
$passIt = (!$hasRule && !$greedy) || ($hasRule && !Router::matchNamed($key, $val, $rules[$key], $context)); $passIt = (!$hasRule && !$greedy) || ($hasRule && !Router::matchNamed($key, $val, $rules[$key], $context));

View file

@ -26,11 +26,11 @@
<h2><?php echo sprintf(__('Missing Method in %s', true), $controller);?></h2> <h2><?php echo sprintf(__('Missing Method in %s', true), $controller);?></h2>
<p class="error"> <p class="error">
<strong><?php __('Error') ?>: </strong> <strong><?php __('Error') ?>: </strong>
<?php echo sprintf(__('The action %1$s is not defined in controller %2$s', true), "<em>".$action."</em>", "<em>".$controller."</em>");?> <?php echo sprintf(__('The action %1$s is not defined in controller %2$s', true), "<em>" . $action . "</em>", "<em>" . $controller . "</em>");?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php __('Error') ?>: </strong> <strong><?php __('Error') ?>: </strong>
<?php echo sprintf(__('Create %1$s%2$s in file: %3$s.', true), "<em>".$controller."::</em>", "<em>".$action."()</em>", APP_DIR.DS."controllers".DS.Inflector::underscore($controller).".php");?> <?php echo sprintf(__('Create %1$s%2$s in file: %3$s.', true), "<em>" . $controller . "::</em>", "<em>" . $action . "()</em>", APP_DIR . DS . "controllers" . DS . Inflector::underscore($controller) . ".php");?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -48,5 +48,5 @@ class <?php echo $controller;?> extends AppController {
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php __('Notice') ?>: </strong> <strong><?php __('Notice') ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s.', true), APP_DIR.DS."views".DS."errors".DS."missing_action.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s.', true), APP_DIR . DS . "views" . DS . "errors" . DS . "missing_action.ctp");?>
</p> </p>

View file

@ -26,11 +26,11 @@
<h2><?php __('Missing Component Class'); ?></h2> <h2><?php __('Missing Component Class'); ?></h2>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('Component class %1$s in %2$s was not found.', true), "<em>". $component ."Component</em>", "<em>". $controller ."Controller</em>");?> <?php echo sprintf(__('Component class %1$s in %2$s was not found.', true), "<em>" . $component . "Component</em>", "<em>" . $controller . "Controller</em>");?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('Create the class %s in file: %s', true), "<em>". $component ."Component</em>", APP_DIR.DS."controllers".DS."components".DS.$file);?> <?php echo sprintf(__('Create the class %s in file: %s', true), "<em>" . $component . "Component</em>", APP_DIR . DS . "controllers" . DS . "components" . DS . $file);?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -41,5 +41,5 @@ class <?php echo $component;?>Component extends Object {<br />
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php __('Notice'); ?>: </strong> <strong><?php __('Notice'); ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR.DS."views".DS."errors".DS."missing_component_class.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "missing_component_class.ctp");?>
</p> </p>

View file

@ -30,7 +30,7 @@
</p> </p>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('Create the class %s in file: %s', true), "<em>". $component ."Component</em>", APP_DIR.DS."controllers".DS."components".DS.$file);?> <?php echo sprintf(__('Create the class %s in file: %s', true), "<em>" . $component . "Component</em>", APP_DIR . DS . "controllers" . DS . "components" . DS . $file);?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -41,5 +41,5 @@ class <?php echo $component;?>Component extends Object {<br />
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php __('Notice'); ?>: </strong> <strong><?php __('Notice'); ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR.DS."views".DS."errors".DS."missing_component_file.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "missing_component_file.ctp");?>
</p> </p>

View file

@ -26,11 +26,11 @@
<h2><?php __('Missing Controller'); ?></h2> <h2><?php __('Missing Controller'); ?></h2>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('%s could not be found.', true), "<em>".$controller."</em>");?> <?php echo sprintf(__('%s could not be found.', true), "<em>" . $controller . "</em>");?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('Create the class %s below in file: %s', true), "<em>".$controller."</em>", APP_DIR.DS."controllers".DS.Inflector::underscore($controller).".php");?> <?php echo sprintf(__('Create the class %s below in file: %s', true), "<em>" . $controller . "</em>", APP_DIR . DS . "controllers" . DS . Inflector::underscore($controller) . ".php");?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -42,5 +42,5 @@ class <?php echo $controller;?> extends AppController {
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php __('Notice'); ?>: </strong> <strong><?php __('Notice'); ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR.DS."views".DS."errors".DS."missing_controller.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "missing_controller.ctp");?>
</p> </p>

View file

@ -30,7 +30,7 @@
</p> </p>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('Create the class below in file: %s', true), APP_DIR.DS."views".DS."helpers".DS.$file);?> <?php echo sprintf(__('Create the class below in file: %s', true), APP_DIR . DS . "views" . DS . "helpers" . DS . $file);?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -41,5 +41,5 @@ class <?php echo $helperClass;?> extends AppHelper {
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php __('Notice'); ?>: </strong> <strong><?php __('Notice'); ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR.DS."views".DS."errors".DS."missing_helper_class.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "missing_helper_class.ctp");?>
</p> </p>

View file

@ -1,6 +1,5 @@
<?php <?php
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
@ -26,11 +25,11 @@
<h2><?php __('Missing Helper File'); ?></h2> <h2><?php __('Missing Helper File'); ?></h2>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__("The helper file %s can not be found or does not exist.", true), APP_DIR.DS."views".DS."helpers".DS.$file);?> <?php echo sprintf(__("The helper file %s can not be found or does not exist.", true), APP_DIR . DS . "views" . DS . "helpers" . DS . $file);?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('Create the class below in file: %s', true), APP_DIR.DS."views".DS."helpers".DS.$file);?> <?php echo sprintf(__('Create the class below in file: %s', true), APP_DIR . DS . "views" . DS . "helpers" . DS . $file);?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -41,5 +40,5 @@ class <?php echo $helperClass;?> extends AppHelper {
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php __('Notice'); ?>: </strong> <strong><?php __('Notice'); ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR.DS."views".DS."errors".DS."missing_helper_file.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "missing_helper_file.ctp");?>
</p> </p>

View file

@ -26,13 +26,13 @@
<h2><?php __('Missing Layout'); ?></h2> <h2><?php __('Missing Layout'); ?></h2>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__("The layout file %s can not be found or does not exist.", true), "<em>". $file ."</em>");?> <?php echo sprintf(__("The layout file %s can not be found or does not exist.", true), "<em>" . $file . "</em>");?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('Confirm you have created the file: %s', true), "<em>". $file ."</em>");?> <?php echo sprintf(__('Confirm you have created the file: %s', true), "<em>" . $file . "</em>");?>
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php __('Notice'); ?>: </strong> <strong><?php __('Notice'); ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR.DS."views".DS."errors".DS."missing_layout.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "missing_layout.ctp");?>
</p> </p>

View file

@ -30,7 +30,7 @@
</p> </p>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('Create the class %s in file: %s', true), "<em>". $model . "</em>", APP_DIR.DS."models".DS.Inflector::underscore($model).".php");?> <?php echo sprintf(__('Create the class %s in file: %s', true), "<em>" . $model . "</em>", APP_DIR . DS . "models" . DS . Inflector::underscore($model) . ".php");?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -43,5 +43,5 @@ class <?php echo $model;?> extends AppModel {
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php __('Notice'); ?>: </strong> <strong><?php __('Notice'); ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR.DS."views".DS."errors".DS."missing_model.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "missing_model.ctp");?>
</p> </p>

View file

@ -30,9 +30,9 @@
</p> </p>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('Confirm you have created the file: %s', true), APP_DIR.DS."config".DS."database.php");?> <?php echo sprintf(__('Confirm you have created the file: %s', true), APP_DIR . DS . "config" . DS . "database.php");?>
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php __('Notice'); ?>: </strong> <strong><?php __('Notice'); ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR.DS."views".DS."errors".DS."missing_scaffolddb.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "missing_scaffolddb.ctp");?>
</p> </p>

View file

@ -26,9 +26,9 @@
<h2><?php __('Missing Database Table'); ?></h2> <h2><?php __('Missing Database Table'); ?></h2>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('Database table %1$s for model %2$s was not found.', true),"<em>". $table ."</em>", "<em>". $model ."</em>");?> <?php echo sprintf(__('Database table %1$s for model %2$s was not found.', true),"<em>" . $table . "</em>", "<em>" . $model . "</em>");?>
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php __('Notice'); ?>: </strong> <strong><?php __('Notice'); ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR.DS."views".DS."errors".DS."missing_table.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "missing_table.ctp");?>
</p> </p>

View file

@ -26,7 +26,7 @@
<h2><?php __('Missing View'); ?></h2> <h2><?php __('Missing View'); ?></h2>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('The view for %1$s%2$s was not found.', true), "<em>". $controller."Controller::</em>", "<em>". $action ."()</em>");?> <?php echo sprintf(__('The view for %1$s%2$s was not found.', true), "<em>" . $controller . "Controller::</em>", "<em>". $action . "()</em>");?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
@ -34,5 +34,5 @@
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php __('Notice'); ?>: </strong> <strong><?php __('Notice'); ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR.DS."views".DS."errors".DS."missing_view.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "missing_view.ctp");?>
</p> </p>

View file

@ -26,9 +26,9 @@
<h2><?php echo sprintf(__('Private Method in %s', true), $controller);?></h2> <h2><?php echo sprintf(__('Private Method in %s', true), $controller);?></h2>
<p class="error"> <p class="error">
<strong><?php __('Error'); ?>: </strong> <strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__("%s%s cannot be accessed directly.", true), "<em>". $controller ."::</em>", "<em>". $action ."()</em>");?> <?php echo sprintf(__("%s%s cannot be accessed directly.", true), "<em>" . $controller . "::</em>", "<em>" . $action . "()</em>");?>
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php __('Notice'); ?>: </strong> <strong><?php __('Notice'); ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR.DS."views".DS."errors".DS."private_action.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "private_action.ctp");?>
</p> </p>

View file

@ -30,7 +30,7 @@
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php __('Notice'); ?>: </strong> <strong><?php __('Notice'); ?>: </strong>
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR.DS."views".DS."errors".DS."scaffold_error.ctp");?> <?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "scaffold_error.ctp");?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php

View file

@ -514,15 +514,12 @@ class PaginatorHelper extends AppHelper {
$end = $params['page'] + ($modulus - $params['page']) + 1; $end = $params['page'] + ($modulus - $params['page']) + 1;
} }
if ($first) { if ($first && $start > 1) {
if ($start > (int)$first) { $offset = ($start <= (int)$first) ? $start - 1 : $first;
if ($start == $first + 1) { if ($offset < $start - 1) {
$out .= $this->first($first, array('tag' => $tag, 'after' => $separator, 'separator' => $separator)); $out .= $this->first($offset, array('tag' => $tag, 'separator' => $separator));
} else { } else {
$out .= $this->first($first, array('tag' => $tag, 'separator' => $separator)); $out .= $this->first($offset, array('tag' => $tag, 'after' => $separator, 'separator' => $separator));
}
} elseif ($start == 2) {
$out .= $this->Html->tag($tag, $this->link(1, array('page' => 1), $options)) . $separator;
} }
} }
@ -550,15 +547,12 @@ class PaginatorHelper extends AppHelper {
$out .= $after; $out .= $after;
if ($last) { if ($last && $end < $params['pageCount']) {
if ($end <= $params['pageCount'] - (int)$last) { $offset = ($params['pageCount'] < $end + (int)$last) ? $params['pageCount'] - $end : $last;
if ($end + 1 == $params['pageCount']) { if ($offset <= $last && $params['pageCount'] - $end > $offset) {
$out .= $this->last($last, array('tag' => $tag, 'before' => $separator, 'separator' => $separator)); $out .= $this->last($offset, array('tag' => $tag, 'separator' => $separator));
} else { } else {
$out .= $this->last($last, array('tag' => $tag, 'separator' => $separator)); $out .= $this->last($offset, array('tag' => $tag, 'before' => $separator, 'separator' => $separator));
}
} elseif ($end == $params['pageCount'] - 1) {
$out .= $separator . $this->Html->tag($tag, $this->link($params['pageCount'], array('page' => $params['pageCount']), $options));
} }
} }

View file

@ -41,8 +41,8 @@
foreach ($associations as $_type => $_data) { foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) { foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index'))."</li>\n"; echo "\t\t<li>" . $html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add'))."</li>\n"; echo "\t\t<li>" . $html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add')) . "</li>\n";
$done[] = $_details['controller']; $done[] = $_details['controller'];
} }
} }

View file

@ -87,8 +87,8 @@ echo "\n";
foreach ($associations as $_type => $_data) { foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) { foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index'))."</li>\n"; echo "\t\t<li>" . $html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'))."</li>\n"; echo "\t\t<li>" . $html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n";
$done[] = $_details['controller']; $done[] = $_details['controller'];
} }
} }

View file

@ -38,14 +38,14 @@ foreach ($scaffoldFields as $_field) {
foreach ($associations['belongsTo'] as $_alias => $_details) { foreach ($associations['belongsTo'] as $_alias => $_details) {
if ($_field === $_details['foreignKey']) { if ($_field === $_details['foreignKey']) {
$isKey = true; $isKey = true;
echo "\t\t<dt{$class}>".Inflector::humanize($_alias)."</dt>\n"; echo "\t\t<dt{$class}>" . Inflector::humanize($_alias) . "</dt>\n";
echo "\t\t<dd{$class}>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t&nbsp;</dd>\n"; echo "\t\t<dd{$class}>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t&nbsp;</dd>\n";
break; break;
} }
} }
} }
if ($isKey !== true) { if ($isKey !== true) {
echo "\t\t<dt{$class}>".Inflector::humanize($_field)."</dt>\n"; echo "\t\t<dt{$class}>" . Inflector::humanize($_field) . "</dt>\n";
echo "\t\t<dd{$class}>\n\t\t\t{${$singularVar}[$modelClass][$_field]}\n&nbsp;\t\t</dd>\n"; echo "\t\t<dd{$class}>\n\t\t\t{${$singularVar}[$modelClass][$_field]}\n&nbsp;\t\t</dd>\n";
} }
} }
@ -64,8 +64,8 @@ foreach ($scaffoldFields as $_field) {
foreach ($associations as $_type => $_data) { foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) { foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index'))."</li>\n"; echo "\t\t<li>" . $html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'))."</li>\n"; echo "\t\t<li>" . $html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n";
$done[] = $_details['controller']; $done[] = $_details['controller'];
} }
} }
@ -88,8 +88,8 @@ foreach ($associations['hasOne'] as $_alias => $_details): ?>
if ($i++ % 2 == 0) { if ($i++ % 2 == 0) {
$class = ' class="altrow"'; $class = ' class="altrow"';
} }
echo "\t\t<dt{$class}>".Inflector::humanize($_field)."</dt>\n"; echo "\t\t<dt{$class}>" . Inflector::humanize($_field) . "</dt>\n";
echo "\t\t<dd{$class}>\n\t" .${$singularVar}[$_alias][$_field] ."\n&nbsp;</dd>\n"; echo "\t\t<dd{$class}>\n\t" . ${$singularVar}[$_alias][$_field] . "\n&nbsp;</dd>\n";
} }
?> ?>
</dl> </dl>
@ -123,7 +123,7 @@ $otherSingularVar = Inflector::variable($_alias);
<?php <?php
$otherFields = array_keys(${$singularVar}[$_alias][0]); $otherFields = array_keys(${$singularVar}[$_alias][0]);
foreach ($otherFields as $_field) { foreach ($otherFields as $_field) {
echo "\t\t<th>".Inflector::humanize($_field)."</th>\n"; echo "\t\t<th>" . Inflector::humanize($_field) . "</th>\n";
} }
?> ?>
<th class="actions">Actions</th> <th class="actions">Actions</th>
@ -138,7 +138,7 @@ $otherSingularVar = Inflector::variable($_alias);
echo "\t\t<tr{$class}>\n"; echo "\t\t<tr{$class}>\n";
foreach ($otherFields as $_field) { foreach ($otherFields as $_field) {
echo "\t\t\t<td>".${$otherSingularVar}[$_field]."</td>\n"; echo "\t\t\t<td>" . ${$otherSingularVar}[$_field] . "</td>\n";
} }
echo "\t\t\t<td class=\"actions\">\n"; echo "\t\t\t<td class=\"actions\">\n";

View file

@ -36,6 +36,8 @@ if (!class_exists('ShellDispatcher')) {
ob_end_clean(); ob_end_clean();
} }
require_once CONSOLE_LIBS . 'shell.php';
/** /**
* TestShellDispatcher class * TestShellDispatcher class
* *
@ -76,6 +78,13 @@ class TestShellDispatcher extends ShellDispatcher {
*/ */
var $stopped = null; var $stopped = null;
/**
* TestShell
*
* @var mixed
* @access public
*/
var $TestShell;
/** /**
* _initEnvironment method * _initEnvironment method
* *
@ -127,6 +136,30 @@ class TestShellDispatcher extends ShellDispatcher {
*/ */
function _stop($status = 0) { function _stop($status = 0) {
$this->stopped = 'Stopped with status: ' . $status; $this->stopped = 'Stopped with status: ' . $status;
return $status;
}
/**
* getShell
*
* @param mixed $plugin
* @access public
* @return mixed
*/
function getShell($plugin = null) {
return $this->_getShell($plugin);
}
/**
* _getShell
*
* @param mixed $plugin
* @access protected
* @return mixed
*/
function _getShell($plugin = null) {
if (isset($this->TestShell)) {
return $this->TestShell;
}
return parent::_getShell($plugin);
} }
} }
@ -136,7 +169,7 @@ class TestShellDispatcher extends ShellDispatcher {
* @package cake * @package cake
* @subpackage cake.tests.cases.libs * @subpackage cake.tests.cases.libs
*/ */
class ShellDispatcherTest extends UnitTestCase { class ShellDispatcherTest extends CakeTestCase {
/** /**
* setUp method * setUp method
@ -418,6 +451,25 @@ class ShellDispatcherTest extends UnitTestCase {
$Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->params = $Dispatcher->args = array();
$Dispatcher->parseParams($params); $Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->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);
} }
/** /**
@ -444,20 +496,418 @@ class ShellDispatcherTest extends UnitTestCase {
} }
/** /**
* testDispatch method * Verify loading of (plugin-) shells
* *
* @access public * @access public
* @return void * @return void
*/ */
function testDispatch() { function testGetShell() {
$Dispatcher =& new TestShellDispatcher(array('sample')); $this->skipIf(class_exists('SampleShell'), '%s SampleShell Class already loaded');
$this->assertPattern('/This is the main method called from SampleShell/', $Dispatcher->stdout); $this->skipIf(class_exists('ExampleShell'), '%s ExampleShell Class already loaded');
$Dispatcher =& new TestShellDispatcher(array('test_plugin_two.example')); $Dispatcher =& new TestShellDispatcher();
$this->assertPattern('/This is the main method called from TestPluginTwo.ExampleShell/', $Dispatcher->stdout);
$Dispatcher =& new TestShellDispatcher(array('test_plugin_two.welcome', 'say_hello')); $Dispatcher->shell = 'sample';
$this->assertPattern('/This is the say_hello method called from TestPluginTwo.WelcomeShell/', $Dispatcher->stdout); $Dispatcher->shellName = 'Sample';
$Dispatcher->shellClass = 'SampleShell';
$result = $Dispatcher->getShell();
$this->assertIsA($result, 'SampleShell');
$Dispatcher =& new TestShellDispatcher();
$Dispatcher->shell = 'example';
$Dispatcher->shellName = 'Example';
$Dispatcher->shellClass = 'ExampleShell';
$result = $Dispatcher->getShell('test_plugin');
$this->assertIsA($result, 'ExampleShell');
}
/**
* Verify correct dispatch of Shell subclasses with a main method
*
* @access public
* @return void
*/
function testDispatchShellWithMain() {
Mock::generate('Shell', 'MockWithMainShell', array('main', '_secret'));
$Dispatcher =& new TestShellDispatcher();
$Shell = new MockWithMainShell();
$Shell->setReturnValue('main', true);
$Shell->expectOnce('initialize');
$Shell->expectOnce('loadTasks');
$Shell->expectOnce('startup');
$Shell->expectOnce('main');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array());
$Shell = new MockWithMainShell();
$Shell->setReturnValue('main', true);
$Shell->expectOnce('startup');
$Shell->expectOnce('main');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main', 'initdb');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array('initdb'));
$Shell = new MockWithMainShell();
$Shell->setReturnValue('main', true);
$Shell->expectOnce('startup');
$Shell->expectOnce('help');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main', 'help');
$result = $Dispatcher->dispatch();
$this->assertNull($result);
$this->assertEqual($Dispatcher->args, array());
$Shell = new MockWithMainShell();
$Shell->setReturnValue('main', true);
$Shell->expectNever('hr');
$Shell->expectOnce('startup');
$Shell->expectOnce('main');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main', 'hr');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array('hr'));
$Shell = new MockWithMainShell();
$Shell->setReturnValue('main', true);
$Shell->expectOnce('startup');
$Shell->expectOnce('main');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main', 'dispatch');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array('dispatch'));
$Shell = new MockWithMainShell();
$Shell->setReturnValue('main', true);
$Shell->expectOnce('startup');
$Shell->expectOnce('main');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main', 'idontexist');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array('idontexist'));
$Shell = new MockWithMainShell();
$Shell->expectNever('startup');
$Shell->expectNever('main');
$Shell->expectNever('_secret');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main', '_secret');
$result = $Dispatcher->dispatch();
$this->assertFalse($result);
}
/**
* Verify correct dispatch of Shell subclasses without a main method
*
* @access public
* @return void
*/
function testDispatchShellWithoutMain() {
Mock::generate('Shell', 'MockWithoutMainShell', array('initDb', '_secret'));
$Dispatcher =& new TestShellDispatcher();
$Shell = new MockWithoutMainShell();
$Shell->setReturnValue('initDb', true);
$Shell->expectOnce('initialize');
$Shell->expectOnce('loadTasks');
$Shell->expectNever('startup');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_without_main');
$result = $Dispatcher->dispatch();
$this->assertFalse($result);
$this->assertEqual($Dispatcher->args, array());
$Shell = new MockWithoutMainShell();
$Shell->setReturnValue('initDb', true);
$Shell->expectOnce('startup');
$Shell->expectOnce('initDb');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_without_main', 'initdb');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array());
$Shell = new MockWithoutMainShell();
$Shell->setReturnValue('initDb', true);
$Shell->expectNever('startup');
$Shell->expectNever('hr');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_without_main', 'hr');
$result = $Dispatcher->dispatch();
$this->assertFalse($result);
$this->assertEqual($Dispatcher->args, array('hr'));
$Shell = new MockWithoutMainShell();
$Shell->setReturnValue('initDb', true);
$Shell->expectNever('startup');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_without_main', 'dispatch');
$result = $Dispatcher->dispatch();
$this->assertFalse($result);
$Shell = new MockWithoutMainShell();
$Shell->expectNever('startup');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_without_main', 'idontexist');
$result = $Dispatcher->dispatch();
$this->assertFalse($result);
$Shell = new MockWithoutMainShell();
$Shell->expectNever('startup');
$Shell->expectNever('_secret');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_without_main', '_secret');
$result = $Dispatcher->dispatch();
$this->assertFalse($result);
}
/**
* Verify correct dispatch of custom classes with a main method
*
* @access public
* @return void
*/
function testDispatchNotAShellWithMain() {
Mock::generate('Object', 'MockWithMainNotAShell',
array('main', 'initialize', 'loadTasks', 'startup', '_secret'));
$Dispatcher =& new TestShellDispatcher();
$Shell = new MockWithMainNotAShell();
$Shell->setReturnValue('main', true);
$Shell->expectNever('initialize');
$Shell->expectNever('loadTasks');
$Shell->expectOnce('startup');
$Shell->expectOnce('main');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main_not_a');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array());
$Shell = new MockWithMainNotAShell();
$Shell->setReturnValue('main', true);
$Shell->expectOnce('startup');
$Shell->expectOnce('main');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main_not_a', 'initdb');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array('initdb'));
$Shell = new MockWithMainNotAShell();
$Shell->setReturnValue('main', true);
$Shell->expectOnce('startup');
$Shell->expectOnce('main');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main_not_a', 'hr');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array('hr'));
$Shell = new MockWithMainNotAShell();
$Shell->setReturnValue('main', true);
$Shell->expectOnce('startup');
$Shell->expectOnce('main');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main_not_a', 'dispatch');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array('dispatch'));
$Shell = new MockWithMainNotAShell();
$Shell->setReturnValue('main', true);
$Shell->expectOnce('startup');
$Shell->expectOnce('main');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main_not_a', 'idontexist');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array('idontexist'));
$Shell = new MockWithMainNotAShell();
$Shell->expectNever('startup');
$Shell->expectNever('main');
$Shell->expectNever('_secret');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_with_main_not_a', '_secret');
$result = $Dispatcher->dispatch();
$this->assertFalse($result);
}
/**
* Verify correct dispatch of custom classes without a main method
*
* @access public
* @return void
*/
function testDispatchNotAShellWithoutMain() {
Mock::generate('Object', 'MockWithoutMainNotAShell',
array('initDb', 'initialize', 'loadTasks', 'startup', '_secret'));
$Dispatcher =& new TestShellDispatcher();
$Shell = new MockWithoutMainNotAShell();
$Shell->setReturnValue('initDb', true);
$Shell->expectNever('initialize');
$Shell->expectNever('loadTasks');
$Shell->expectNever('startup');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_without_main_not_a');
$result = $Dispatcher->dispatch();
$this->assertFalse($result);
$Shell = new MockWithoutMainNotAShell();
$Shell->setReturnValue('initDb', true);
$Shell->expectOnce('startup');
$Shell->expectOnce('initDb');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_without_main_not_a', 'initdb');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array());
$Shell = new MockWithoutMainNotAShell();
$Shell->setReturnValue('initDb', true);
$Shell->expectNever('startup');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_without_main_not_a', 'hr');
$result = $Dispatcher->dispatch();
$this->assertFalse($result);
$Shell = new MockWithoutMainNotAShell();
$Shell->setReturnValue('initDb', true);
$Shell->expectNever('startup');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_without_main_not_a', 'dispatch');
$result = $Dispatcher->dispatch();
$this->assertFalse($result);
$Shell = new MockWithoutMainNotAShell();
$Shell->expectNever('startup');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_without_main_not_a', 'idontexist');
$result = $Dispatcher->dispatch();
$this->assertFalse($result);
$Shell = new MockWithoutMainNotAShell();
$Shell->expectNever('startup');
$Shell->expectNever('_secret');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_without_main_not_a', '_secret');
$result = $Dispatcher->dispatch();
$this->assertFalse($result);
}
/**
* Verify that a task is called instead of the shell if the first arg equals
* the name of the task
*
* @access public
* @return void
*/
function testDispatchTask() {
Mock::generate('Shell', 'MockWeekShell', array('main'));
Mock::generate('Shell', 'MockOnSundayTask', array('execute'));
$Dispatcher =& new TestShellDispatcher();
$Shell = new MockWeekShell();
$Shell->expectOnce('initialize');
$Shell->expectOnce('loadTasks');
$Shell->expectNever('startup');
$Shell->expectNever('main');
$Task = new MockOnSundayTask();
$Task->setReturnValue('execute', true);
$Task->expectOnce('initialize');
$Task->expectOnce('loadTasks');
$Task->expectOnce('startup');
$Task->expectOnce('execute');
$Shell->MockOnSunday =& $Task;
$Shell->taskNames = array('MockOnSunday');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_week', 'mock_on_sunday');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array());
$Shell = new MockWeekShell();
$Task = new MockOnSundayTask();
$Task->expectNever('execute');
$Task->expectOnce('help');
$Shell->MockOnSunday =& $Task;
$Shell->taskNames = array('MockOnSunday');
$Dispatcher->TestShell =& $Shell;
$Dispatcher->args = array('mock_week', 'mock_on_sunday', 'help');
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
}
/**
* Verify shifting of arguments
*
* @access public
* @return void
*/
function testShiftArgs() {
$Dispatcher =& new TestShellDispatcher();
$Dispatcher->args = array('a', 'b', 'c');
$this->assertEqual($Dispatcher->shiftArgs(), 'a');
$this->assertIdentical($Dispatcher->args, array('b', 'c'));
$Dispatcher->args = array('a' => 'b', 'c', 'd');
$this->assertEqual($Dispatcher->shiftArgs(), 'b');
$this->assertIdentical($Dispatcher->args, array('c', 'd'));
$Dispatcher->args = array('a', 'b' => 'c', 'd');
$this->assertEqual($Dispatcher->shiftArgs(), 'a');
$this->assertIdentical($Dispatcher->args, array('b' => 'c', 'd'));
$Dispatcher->args = array(0 => 'a', 2 => 'b', 30 => 'c');
$this->assertEqual($Dispatcher->shiftArgs(), 'a');
$this->assertIdentical($Dispatcher->args, array(0 => 'b', 1 => 'c'));
$Dispatcher->args = array();
$this->assertNull($Dispatcher->shiftArgs());
$this->assertIdentical($Dispatcher->args, array());
} }
/** /**
@ -502,7 +952,7 @@ class ShellDispatcherTest extends UnitTestCase {
$expected = "/ CORE(\\\|\/)tests(\\\|\/)test_app(\\\|\/)vendors(\\\|\/)shells:"; $expected = "/ CORE(\\\|\/)tests(\\\|\/)test_app(\\\|\/)vendors(\\\|\/)shells:";
$expected .= "\n\t sample"; $expected .= "\n\t sample";
$expected .= "\n/"; $expected .= "\n/";
$this->assertPattern($expected, $Dispatcher->stdout); $this->assertPattern($expected, $Dispatcher->stdout);
} }
} }
?> ?>

View file

@ -52,6 +52,23 @@ Mock::generatePartial(
* @subpackage cake.tests.cases.console.libs * @subpackage cake.tests.cases.console.libs
*/ */
class TestShell extends Shell { class TestShell extends Shell {
/**
* stopped property
*
* @var integer
* @access public
*/
var $stopped;
/**
* stop method
*
* @param integer $status
* @access protected
* @return void
*/
function _stop($status = 0) {
$this->stopped = $status;
}
} }
/** /**
@ -157,20 +174,6 @@ class ShellTest extends CakeTestCase {
App::build(); App::build();
} }
/**
* testOut method
*
* @return void
* @access public
*/
function testOut() {
$this->Shell->Dispatch->expectAt(0, 'stdout', array('Just a test', true));
$this->Shell->out('Just a test');
$this->Shell->Dispatch->expectAt(1, 'stdout', array("Just\na\ntest\n", true));
$this->Shell->out(array('Just', 'a', 'test'));
}
/** /**
* testIn method * testIn method
* *
@ -209,6 +212,94 @@ class ShellTest extends CakeTestCase {
$this->assertEqual($result, 'n'); $this->assertEqual($result, 'n');
} }
/**
* testOut method
*
* @return void
* @access public
*/
function testOut() {
$this->Shell->Dispatch->expectAt(0, 'stdout', array("Just a test\n", false));
$this->Shell->out('Just a test');
$this->Shell->Dispatch->expectAt(1, 'stdout', array("Just\na\ntest\n", false));
$this->Shell->out(array('Just', 'a', 'test'));
$this->Shell->Dispatch->expectAt(2, 'stdout', array("Just\na\ntest\n\n", false));
$this->Shell->out(array('Just', 'a', 'test'), 2);
}
/**
* testErr method
*
* @return void
* @access public
*/
function testErr() {
$this->Shell->Dispatch->expectAt(0, 'stderr', array("Just a test\n"));
$this->Shell->err('Just a test');
$this->Shell->Dispatch->expectAt(1, 'stderr', array("Just\na\ntest\n"));
$this->Shell->err(array('Just', 'a', 'test'));
$this->Shell->Dispatch->expectAt(2, 'stderr', array("Just\na\ntest\n\n"));
$this->Shell->err(array('Just', 'a', 'test'), 2);
}
/**
* testNl
*
* @access public
* @return void
*/
function testNl() {
$this->assertEqual($this->Shell->nl(), "\n");
$this->assertEqual($this->Shell->nl(true), "\n");
$this->assertEqual($this->Shell->nl(false), "");
$this->assertEqual($this->Shell->nl(2), "\n\n");
$this->assertEqual($this->Shell->nl(1), "\n");
$this->assertEqual($this->Shell->nl("custom"), "custom\n");
}
/**
* testHr
*
* @access public
* @return void
*/
function testHr() {
$bar = '---------------------------------------------------------------';
$this->Shell->Dispatch->expectAt(0, 'stdout', array('', false));
$this->Shell->Dispatch->expectAt(1, 'stdout', array($bar . "\n", false));
$this->Shell->Dispatch->expectAt(2, 'stdout', array('', false));
$this->Shell->hr();
$this->Shell->Dispatch->expectAt(3, 'stdout', array("\n", false));
$this->Shell->Dispatch->expectAt(4, 'stdout', array($bar . "\n", false));
$this->Shell->Dispatch->expectAt(5, 'stdout', array("\n", false));
$this->Shell->hr(true);
$this->Shell->Dispatch->expectAt(3, 'stdout', array("\n\n", false));
$this->Shell->Dispatch->expectAt(4, 'stdout', array($bar . "\n", false));
$this->Shell->Dispatch->expectAt(5, 'stdout', array("\n\n", false));
$this->Shell->hr(2);
}
/**
* testError
*
* @access public
* @return void
*/
function testError() {
$this->Shell->Dispatch->expectAt(0, 'stderr', array("Error: Foo Not Found\n"));
$this->Shell->error('Foo Not Found');
$this->assertIdentical($this->Shell->stopped, 1);
$this->Shell->stopped = null;
$this->Shell->Dispatch->expectAt(1, 'stderr', array("Error: Foo Not Found\n"));
$this->Shell->Dispatch->expectAt(2, 'stderr', array("Searched all...\n"));
$this->Shell->error('Foo Not Found', 'Searched all...');
$this->assertIdentical($this->Shell->stopped, 1);
}
/** /**
* testLoadTasks method * testLoadTasks method
* *

View file

@ -539,12 +539,12 @@ class HttpSocketTest extends CakeTestCase {
$this->Socket->setReturnValue('read', false); $this->Socket->setReturnValue('read', false);
$this->Socket->_mock->_call_counts['read'] = 0; $this->Socket->_mock->_call_counts['read'] = 0;
$number = mt_rand(0, 9999999); $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<h1>Hello, your lucky number is ".$number."</h1>"; $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<h1>Hello, your lucky number is " . $number . "</h1>";
$this->Socket->setReturnValueAt(0, 'read', $serverResponse); $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->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); $this->Socket->expectCallCount('read', 2);
$response = $this->Socket->request($request); $response = $this->Socket->request($request);
$this->assertIdentical($response, "<h1>Hello, your lucky number is ".$number."</h1>"); $this->assertIdentical($response, "<h1>Hello, your lucky number is " . $number . "</h1>");
$this->Socket->reset(); $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<h1>This is a cookie test!</h1>"; $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<h1>This is a cookie test!</h1>";

View file

@ -208,6 +208,18 @@ class InflectorTest extends CakeTestCase {
$result = Inflector::slug('#this melts your face1#2#3', '-'); $result = Inflector::slug('#this melts your face1#2#3', '-');
$expected = 'this-melts-your-face1-2-3'; $expected = 'this-melts-your-face1-2-3';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = Inflector::slug('controller/action/りんご/1');
$expected = 'controller_action_りんご_1';
$this->assertEqual($result, $expected);
$result = Inflector::slug('の話が出たので大丈夫かなあと');
$expected = 'の話が出たので大丈夫かなあと';
$this->assertEqual($result, $expected);
$result = Inflector::slug('posts/view/한국어/page:1/sort:asc');
$expected = 'posts_view_한국어_page_1_sort_asc';
$this->assertEqual($result, $expected);
} }
/** /**

View file

@ -1705,5 +1705,74 @@ class RouterTest extends CakeTestCase {
$this->assertEqual(Router::stripPlugin($url), $url); $this->assertEqual(Router::stripPlugin($url), $url);
$this->assertEqual(Router::stripPlugin($url, null), $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);
}
} }
?> ?>

View file

@ -311,8 +311,8 @@ class SanitizeTest extends CakeTestCase {
$result = Sanitize::stripScripts($string); $result = Sanitize::stripScripts($string);
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$string = '<link href="/css/styles.css" media="screen" rel="stylesheet" />'."\n".'<link rel="icon" href="/favicon.ico" type="image/x-icon" />'."\n".'<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />'."\n".'<link rel="alternate" href="/feed.xml" title="RSS Feed" type="application/rss+xml" />'; $string = '<link href="/css/styles.css" media="screen" rel="stylesheet" />' . "\n" . '<link rel="icon" href="/favicon.ico" type="image/x-icon" />' . "\n" . '<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />' . "\n" . '<link rel="alternate" href="/feed.xml" title="RSS Feed" type="application/rss+xml" />';
$expected = "\n".'<link rel="icon" href="/favicon.ico" type="image/x-icon" />'."\n".'<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />'."\n".'<link rel="alternate" href="/feed.xml" title="RSS Feed" type="application/rss+xml" />'; $expected = "\n" . '<link rel="icon" href="/favicon.ico" type="image/x-icon" />' . "\n" . '<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />'."\n".'<link rel="alternate" href="/feed.xml" title="RSS Feed" type="application/rss+xml" />';
$result = Sanitize::stripScripts($string); $result = Sanitize::stripScripts($string);
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);

View file

@ -152,6 +152,26 @@ class CacheHelperTest extends CakeTestCase {
@unlink($filename); @unlink($filename);
} }
/**
* test cache parsing with non-latin characters in current route
*
* @access public
* @return void
*/
function testCacheNonLatinCharactersInRoute() {
$this->Controller->cache_parsing();
$this->Controller->cacheAction = 21600;
$this->Controller->here = '/posts/view/風街ろまん';
$this->Controller->action = 'view';
$View = new View($this->Controller);
$result = $View->render('index');
$filename = CACHE . 'views' . DS . 'posts_view_風街ろまん.php';
$this->assertTrue(file_exists($filename));
@unlink($filename);
}
/** /**
* Test cache parsing with cake:nocache tags in view file. * Test cache parsing with cake:nocache tags in view file.
* *

View file

@ -765,29 +765,116 @@ class PaginatorHelperTest extends CakeTestCase {
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
); );
$result = $this->Paginator->numbers(); $result = $this->Paginator->numbers();
$expected = '<span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span class="current">8</span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span>'; $expected = array(
$this->assertEqual($result, $expected); 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')); $result = $this->Paginator->numbers(array('tag' => 'li'));
$expected = '<li><a href="/index/page:4">4</a></li> | <li><a href="/index/page:5">5</a></li> | <li><a href="/index/page:6">6</a></li> | <li><a href="/index/page:7">7</a></li> | <li class="current">8</li> | <li><a href="/index/page:9">9</a></li> | <li><a href="/index/page:10">10</a></li> | <li><a href="/index/page:11">11</a></li> | <li><a href="/index/page:12">12</a></li>'; $expected = array(
$this->assertEqual($result, $expected); 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)); $result = $this->Paginator->numbers(array('tag' => 'li', 'separator' => false));
$expected = '<li><a href="/index/page:4">4</a></li><li><a href="/index/page:5">5</a></li><li><a href="/index/page:6">6</a></li><li><a href="/index/page:7">7</a></li><li class="current">8</li><li><a href="/index/page:9">9</a></li><li><a href="/index/page:10">10</a></li><li><a href="/index/page:11">11</a></li><li><a href="/index/page:12">12</a></li>'; $expected = array(
$this->assertEqual($result, $expected); 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); $result = $this->Paginator->numbers(true);
$expected = '<span><a href="/index/page:1">first</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span class="current">8</span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span> | <span><a href="/index/page:15">last</a></span>'; $expected = array(
$this->assertEqual($result, $expected); 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( $this->Paginator->params['paging'] = array('Client' => array(
'page' => 1, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, '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()), '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())) 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
); );
$result = $this->Paginator->numbers(); $result = $this->Paginator->numbers();
$expected = '<span class="current">1</span> | <span><a href="/index/page:2">2</a></span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span>'; $expected = array(
$this->assertEqual($result, $expected); 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( $this->Paginator->params['paging'] = array('Client' => array(
'page' => 14, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, '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())) 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
); );
$result = $this->Paginator->numbers(); $result = $this->Paginator->numbers();
$expected = '<span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span> | <span><a href="/index/page:13">13</a></span> | <span class="current">14</span> | <span><a href="/index/page:15">15</a></span>'; $expected = array(
$this->assertEqual($result, $expected); 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( $this->Paginator->params['paging'] = array('Client' => array(
'page' => 2, 'current' => 3, 'count' => 27, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 9, '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)); $result = $this->Paginator->numbers(array('first' => 1));
$expected = '<span><a href="/index/page:1">1</a></span> | <span class="current">2</span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span>'; $expected = array(
$this->assertEqual($result, $expected); 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)); $result = $this->Paginator->numbers(array('last' => 1));
$expected = '<span><a href="/index/page:1">1</a></span> | <span class="current">2</span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span>'; $expected = array(
$this->assertEqual($result, $expected); 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( $this->Paginator->params['paging'] = array('Client' => array(
'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, '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)); $result = $this->Paginator->numbers(array('first' => 1));
$expected = '<span><a href="/index/page:1">1</a></span>...<span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span> | <span><a href="/index/page:13">13</a></span> | <span><a href="/index/page:14">14</a></span> | <span class="current">15</span>'; $expected = array(
$this->assertEqual($result, $expected); 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( $this->Paginator->params['paging'] = array('Client' => array(
'page' => 10, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, '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)); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
$expected = '<span><a href="/index/page:1">1</a></span>...<span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span class="current">10</span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span> | <span><a href="/index/page:13">13</a></span> | <span><a href="/index/page:14">14</a></span> | <span><a href="/index/page:15">15</a></span>'; $expected = array(
$this->assertEqual($result, $expected); 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( $this->Paginator->params['paging'] = array('Client' => array(
'page' => 6, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42, '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)); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
$expected = '<span><a href="/index/page:1">1</a></span> | <span><a href="/index/page:2">2</a></span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span class="current">6</span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span>...<span><a href="/index/page:42">42</a></span>'; $expected = array(
$this->assertEqual($result, $expected); 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( $this->Paginator->params['paging'] = array('Client' => array(
'page' => 37, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42, '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)); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
$expected = '<span><a href="/index/page:1">1</a></span>...<span><a href="/index/page:33">33</a></span> | <span><a href="/index/page:34">34</a></span> | <span><a href="/index/page:35">35</a></span> | <span><a href="/index/page:36">36</a></span> | <span class="current">37</span> | <span><a href="/index/page:38">38</a></span> | <span><a href="/index/page:39">39</a></span> | <span><a href="/index/page:40">40</a></span> | <span><a href="/index/page:41">41</a></span> | <span><a href="/index/page:42">42</a></span>'; $expected = array(
$this->assertEqual($result, $expected); 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( $this->Paginator->params['paging'] = array(
'Client' => array( 'Client' => array(
@ -876,8 +1104,14 @@ class PaginatorHelperTest extends CakeTestCase {
); );
$options = array('modulus' => 10); $options = array('modulus' => 10);
$result = $this->Paginator->numbers($options); $result = $this->Paginator->numbers($options);
$expected = '<span class="current">1</span> | <span><a href="/index/page:2">2</a></span> | <span><a href="/index/page:3">3</a></span>'; $expected = array(
$this->assertEqual($result, $expected); 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( $this->Paginator->params['paging'] = array('Client' => array(
'page' => 2, 'current' => 10, 'count' => 31, 'prevPage' => true, 'nextPage' => true, 'pageCount' => 4, '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())) 'options' => array('page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
); );
$result = $this->Paginator->numbers(); $result = $this->Paginator->numbers();
$expected = '<span><a href="/index/page:1/sort:Client.name/direction:DESC">1</a></span> | <span class="current">2</span> | <span><a href="/index/page:3/sort:Client.name/direction:DESC">3</a></span> | <span><a href="/index/page:4/sort:Client.name/direction:DESC">4</a></span>'; $expected = array(
$this->assertEqual($result, $expected); 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( $this->Paginator->params['paging'] = array('Client' => array(
'page' => 4895, 'current' => 10, 'count' => 48962, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 4897, '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->assertTags($result, $expected);
$this->Paginator->params['paging'] = array('Client' => array( $this->Paginator->params['paging']['Client']['page'] = 3;
'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()))
);
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2)); $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2));
$expected = array( $expected = array(
@ -947,6 +1186,125 @@ class PaginatorHelperTest extends CakeTestCase {
array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
); );
$this->assertTags($result, $expected); $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);
} }
/** /**

View file

@ -97,7 +97,6 @@ class CakeHtmlReporter extends SimpleReporter {
echo "<strong>" . $this->getFailCount() . "</strong> fails and "; echo "<strong>" . $this->getFailCount() . "</strong> fails and ";
echo "<strong>" . $this->getExceptionCount() . "</strong> exceptions."; echo "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
echo "</div>\n"; echo "</div>\n";
echo "</body>\n</html>\n";
} }
/** /**