Merge branch '1.3' into 1.3-bake

This commit is contained in:
AD7six 2009-08-02 22:44:28 +02:00
commit d61e8736e4
71 changed files with 1067 additions and 415 deletions

View file

@ -44,8 +44,8 @@
/**
* As of 1.3, additional rules for the inflector are added below
*
* Inflector::rule('singular', array('rules' => array(), irregular' => array(), 'uninflected' => array()));
* Inflector::rule('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
* Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
* Inflector::rules('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
*
*/
?>
?>

View file

@ -89,6 +89,7 @@ if (!function_exists('clone')) {
* </code>
*
* @param string $name Filename without the .php part
* @deprecated
*/
function uses() {
$args = func_get_args();

View file

@ -1,7 +1,5 @@
#!/usr/bin/php -q
<?php
/* SVN FILE: $Id$ */
/**
* Command-line code generation utility to automate programmer chores.
*
@ -26,7 +24,9 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', 8192);
}
/**
* Shell dispatcher
*

View file

@ -137,52 +137,29 @@ class AclShell extends Shell {
* @access public
*/
function create() {
$this->_checkArgs(3, 'create');
$this->checkNodeType();
extract($this->__dataVars());
$class = ucfirst($this->args[0]);
$object = new $class();
if (preg_match('/^([\w]+)\.(.*)$/', $this->args[1], $matches) && count($matches) == 3) {
$parent = array(
'model' => $matches[1],
'foreign_key' => $matches[2],
);
} else {
$parent = $this->args[1];
}
$parent = $this->parseIdentifier($this->args[1]);
if (!empty($parent) && $parent != '/' && $parent != 'root') {
@$parent = $object->node($parent);
if (empty($parent)) {
$this->err(sprintf(__('Could not find parent node using reference "%s"', true), $this->args[1]));
return;
} else {
$parent = Set::extract($parent, "0.{$class}.id");
}
$parent = $this->_getNodeId($class, $parent);
} else {
$parent = null;
}
if (preg_match('/^([\w]+)\.(.*)$/', $this->args[2], $matches) && count($matches) == 3) {
$data = array(
'model' => $matches[1],
'foreign_key' => $matches[2],
);
} else {
if (!($this->args[2] == '/')) {
$data = array('alias' => $this->args[2]);
} else {
$this->error(__('/ can not be used as an alias!', true), __('\t/ is the root, please supply a sub alias', true));
}
$data = $this->parseIdentifier($this->args[2]);
if (is_string($data) && $data != '/') {
$data = array('alias' => $data);
} elseif (is_string($data)) {
$this->error(__('/ can not be used as an alias!', true), __("\t/ is the root, please supply a sub alias", true));
}
$data['parent_id'] = $parent;
$object->create();
if ($object->save($data)) {
$this->Acl->{$class}->create();
if ($this->Acl->{$class}->save($data)) {
$this->out(sprintf(__("New %s '%s' created.\n", true), $class, $this->args[2]), true);
} else {
$this->err(sprintf(__("There was a problem creating a new %s '%s'.", true), $class, $this->args[2]));
@ -198,7 +175,11 @@ class AclShell extends Shell {
$this->_checkArgs(2, 'delete');
$this->checkNodeType();
extract($this->__dataVars());
if (!$this->Acl->{$class}->delete($this->args[1])) {
$identifier = $this->parseIdentifier($this->args[1]);
$nodeId = $this->_getNodeId($class, $identifier);
if (!$this->Acl->{$class}->delete($nodeId)) {
$this->error(__("Node Not Deleted", true), sprintf(__("There was an error deleting the %s. Check that the node exists", true), $class) . ".\n");
}
$this->out(sprintf(__("%s deleted", true), $class) . ".\n", true);
@ -213,10 +194,13 @@ class AclShell extends Shell {
$this->_checkArgs(3, 'setParent');
$this->checkNodeType();
extract($this->__dataVars());
$target = $this->parseIdentifier($this->args[1]);
$parent = $this->parseIdentifier($this->args[2]);
$data = array(
$class => array(
'id' => $this->args[1],
'parent_id' => $this->args[2]
'id' => $this->_getNodeId($class, $target),
'parent_id' => $this->_getNodeId($class, $parent)
)
);
$this->Acl->{$class}->create();
@ -378,64 +362,81 @@ class AclShell extends Shell {
* @access public
*/
function help() {
$head = __("Usage: cake acl <command> <arg1> <arg2>...", true) . "\n";
$head = "-----------------------------------------------\n";
$head .= __("Usage: cake acl <command> <arg1> <arg2>...", true) . "\n";
$head .= "-----------------------------------------------\n";
$head .= __("Commands:", true) . "\n\n";
$head .= __("Commands:", true) . "\n";
$commands = array(
'create' => "\tcreate aro|aco <parent> <node>\n" .
"\t\t" . __("Creates a new ACL object <node> under the parent specified by <parent>, an id/alias.", true) . "\n" .
"\t\t" . __("The <parent> and <node> references can be in one of the following formats:", true) . "\n" .
"\t\t\t- " . __("<model>.<id> - The node will be bound to a specific record of the given model", true) . "\n" .
"\t\t\t- " . __("<alias> - The node will be given a string alias (or path, in the case of <parent>),", true) . "\n" .
"\t\t\t " . __("i.e. 'John'. When used with <parent>, this takes the form of an alias path,", true) . "\n" .
"\t\t\t " . __("i.e. <group>/<subgroup>/<parent>.", true) . "\n" .
"\t\t" . __("To add a node at the root level, enter 'root' or '/' as the <parent> parameter.", true) . "\n",
'create' => "create aro|aco <parent> <node>\n" .
"\t" . __("Creates a new ACL object <node> under the parent", true) . "\n" .
"\t" . __("specified by <parent>, an id/alias.", true) . "\n" .
"\t" . __("The <parent> and <node> references can be", true) . "\n" .
"\t" . __("in one of the following formats:", true) . "\n\n" .
"\t\t- " . __("<model>.<id> - The node will be bound to a", true) . "\n" .
"\t\t" . __("specific record of the given model.", true) . "\n\n" .
"\t\t- " . __("<alias> - The node will be given a string alias,", true) . "\n" .
"\t\t" . __(" (or path, in the case of <parent>)", true) . "\n" .
"\t\t " . __("i.e. 'John'. When used with <parent>,", true) . "\n" .
"\t\t" . __("this takes the form of an alias path,", true) . "\n" .
"\t\t " . __("i.e. <group>/<subgroup>/<parent>.", true) . "\n\n" .
"\t" . __("To add a node at the root level,", true) . "\n" .
"\t" . __("enter 'root' or '/' as the <parent> parameter.", true) . "\n",
'delete' => "\tdelete aro|aco <node>\n" .
"\t\t" . __("Deletes the ACL object with the given <node> reference (see 'create' for info on node references).", true) . "\n",
'delete' => "delete aro|aco <node>\n" .
"\t" . __("Deletes the ACL object with the given <node> reference", true) . "\n" .
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
"\t" . __("see help for the 'create' command.", true),
'setparent' => "\tsetParent aro|aco <node> <parent>\n" .
"\t\t" . __("Moves the ACL object specified by <node> beneath the parent ACL object specified by <parent>.", true) . "\n" .
"\t\t" . __("To identify the node and parent, use the row id.", true) . "\n",
'setparent' => "setParent aro|aco <node> <parent>\n" .
"\t" . __("Moves the ACL object specified by <node> beneath", true) . "\n" .
"\t" . __("the parent ACL object specified by <parent>.", true) . "\n" .
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
"\t" . __("see help for the 'create' command.", true),
'getpath' => "\tgetPath aro|aco <node>\n" .
"\t\t" . __("Returns the path to the ACL object specified by <node>. This command", true) . "\n" .
"\t\t" . __("is useful in determining the inhertiance of permissions for a certain", true) . "\n" .
"\t\t" . __("object in the tree.", true) . "\n" .
"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
'getpath' => "getPath aro|aco <node>\n" .
"\t" . __("Returns the path to the ACL object specified by <node>. This command", true) . "\n" .
"\t" . __("is useful in determining the inhertiance of permissions for a certain", true) . "\n" .
"\t" . __("object in the tree.", true) . "\n" .
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
"\t" . __("see help for the 'create' command.", true),
'check' => "\tcheck <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
"\t\t" . __("Use this command to check ACL permissions.", true) . "\n" .
"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
'check' => "check <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
"\t" . __("Use this command to check ACL permissions.", true) . "\n" .
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
"\t" . __("see help for the 'create' command.", true),
'grant' => "\tgrant <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
"\t\t" . __("Use this command to grant ACL permissions. Once executed, the ARO", true) . "\n" .
"\t\t" . __("specified (and its children, if any) will have ALLOW access to the", true) . "\n" .
"\t\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
'grant' => "grant <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
"\t" . __("Use this command to grant ACL permissions. Once executed, the ARO", true) . "\n" .
"\t" . __("specified (and its children, if any) will have ALLOW access to the", true) . "\n" .
"\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
"\t" . __("see help for the 'create' command.", true),
'deny' => "\tdeny <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
"\t\t" . __("Use this command to deny ACL permissions. Once executed, the ARO", true) . "\n" .
"\t\t" . __("specified (and its children, if any) will have DENY access to the", true) . "\n" .
"\t\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
'deny' => "deny <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
"\t" . __("Use this command to deny ACL permissions. Once executed, the ARO", true) . "\n" .
"\t" . __("specified (and its children, if any) will have DENY access to the", true) . "\n" .
"\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
"\t" . __("see help for the 'create' command.", true),
'inherit' => "\tinherit <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
"\t\t" . __("Use this command to force a child ARO object to inherit its", true) . "\n" .
"\t\t" . __("permissions settings from its parent.", true) . "\n" .
"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
'inherit' => "inherit <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
"\t" . __("Use this command to force a child ARO object to inherit its", true) . "\n" .
"\t" . __("permissions settings from its parent.", true) . "\n" .
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
"\t" . __("see help for the 'create' command.", true),
'view' => "\tview aro|aco [<node>]\n" .
"\t\t" . __("The view command will return the ARO or ACO tree. The optional", true) . "\n" .
"\t\t" . __("id/alias parameter allows you to return only a portion of the requested tree.", true) . "\n" .
"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
'view' => "view aro|aco [<node>]\n" .
"\t" . __("The view command will return the ARO or ACO tree.", true) . "\n" .
"\t" . __("The optional id/alias parameter allows you to return\n\tonly a portion of the requested tree.", true) . "\n" .
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
"\t" . __("see help for the 'create' command.", true),
'initdb' => "\tinitdb\n".
"\t\t" . __("Uses this command : cake schema run create DbAcl", true) . "\n",
'initdb' => "initdb\n".
"\t" . __("Uses this command : cake schema run create DbAcl", true),
'help' => "\thelp [<command>]\n" .
"\t\t" . __("Displays this help message, or a message on a specific command.", true) . "\n"
'help' => "help [<command>]\n" .
"\t" . __("Displays this help message, or a message on a specific command.", true)
);
$this->out($head);
@ -443,8 +444,8 @@ class AclShell extends Shell {
foreach ($commands as $cmd) {
$this->out("{$cmd}\n\n");
}
} elseif (isset($commands[low($this->args[0])])) {
$this->out($commands[low($this->args[0])] . "\n\n");
} elseif (isset($commands[strtolower($this->args[0])])) {
$this->out($commands[strtolower($this->args[0])] . "\n\n");
} else {
$this->out(sprintf(__("Command '%s' not found", true), $this->args[0]));
}
@ -477,7 +478,7 @@ class AclShell extends Shell {
return false;
}
extract($this->__dataVars($this->args[0]));
$key = (ife(is_numeric($this->args[1]), $secondary_id, 'alias'));
$key = is_numeric($this->args[1]) ? $secondary_id : 'alias';
$conditions = array($class . '.' . $key => $this->args[1]);
$possibility = $this->Acl->{$class}->find('all', compact('conditions'));
if (empty($possibility)) {
@ -486,6 +487,42 @@ class AclShell extends Shell {
return $possibility;
}
/**
* Parse an identifier into Model.foriegnKey or an alias.
* Takes an identifier determines its type and returns the result as used by other methods.
*
* @param string $identifier Identifier to parse
* @return mixed a string for aliases, and an array for model.foreignKey
**/
function parseIdentifier($identifier) {
if (preg_match('/^([\w]+)\.(.*)$/', $identifier, $matches)) {
return array(
'model' => $matches[1],
'foreign_key' => $matches[2],
);
}
return $identifier;
}
/**
* Get the node for a given identifier. $identifier can either be a string alias
* or an array of properties to use in AcoNode::node()
*
* @param string $class Class type you want (Aro/Aco)
* @param mixed $identifier A mixed identifier for finding the node.
* @return int Integer of NodeId. Will trigger an error if nothing is found.
**/
function _getNodeId($class, $identifier) {
$node = $this->Acl->{$class}->node($identifier);
if (empty($node)) {
if (is_array($identifier)) {
$identifier = var_export($identifier, true);
}
$this->error(sprintf(__('Could not find node using reference "%s"', true), $identifier));
}
return Set::extract($node, "0.{$class}.id");
}
/**
* get params for standard Acl methods
*
@ -533,7 +570,7 @@ class AclShell extends Shell {
}
$vars = array();
$class = ucwords($type);
$vars['secondary_id'] = ife(strtolower($class) == 'aro', 'foreign_key', 'object_id');
$vars['secondary_id'] = (strtolower($class) == 'aro') ? 'foreign_key' : 'object_id';
$vars['data_name'] = $type;
$vars['table_name'] = $type . 's';
$vars['class'] = $class;

View file

@ -47,7 +47,7 @@ class ApiShell extends Shell {
*
* @access public
*/
function initialize () {
function initialize() {
$this->paths = array_merge($this->paths, array(
'behavior' => LIBS . 'model' . DS . 'behaviors' . DS,
'cache' => LIBS . 'cache' . DS,

View file

@ -475,7 +475,7 @@ class Shell extends Object {
}
}
if (!class_exists('File')) {
uses('file');
require LIBS . 'file.php';
}
if ($File = new File($path, true)) {

View file

@ -200,7 +200,7 @@ class ProjectTask extends Shell {
$contents = $File->read();
if (preg_match('/([\\t\\x20]*Configure::write\\(\\\'Security.salt\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
if (!class_exists('Security')) {
uses('Security');
require LIBS . 'security.php';
}
$string = Security::generateAuthKey();
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.salt\', \''.$string.'\');', $contents);

View file

@ -52,7 +52,9 @@ endif;
</p>
<?php
if (!empty(\$filePresent)):
uses('model' . DS . 'connection_manager');
if (!class_exists('ConnectionManager')) {
require LIBS . 'model' . DS . 'connection_manager.php';
}
\$db = ConnectionManager::getInstance();
\$connected = \$db->getDataSource('default');
?>

View file

@ -29,7 +29,6 @@
<?php echo $html->charset(); ?>
<title><?php echo $page_title; ?></title>
<?php if (Configure::read() == 0) { ?>
<meta http-equiv="Refresh" content="<?php echo $pause?>;url=<?php echo $url?>"/>
<?php } ?>

View file

@ -34,7 +34,7 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
* Enter description here...
*/
if (!class_exists('File')) {
uses('file');
require LIBS . 'file.php';
}
/**

View file

@ -746,7 +746,7 @@ class CakeSession extends Object {
return false;
}
return $row[$model->alias]['data'];
return $row[$model->alias]['data'];
}
/**

View file

@ -219,7 +219,7 @@ class DbAcl extends AclBase {
function __construct() {
parent::__construct();
if (!class_exists('AclNode')) {
uses('model' . DS . 'db_acl');
require LIBS . 'model' . DS . 'db_acl.php';
}
$this->Aro =& ClassRegistry::init(array('class' => 'Aro', 'alias' => 'Aro'));
$this->Aco =& ClassRegistry::init(array('class' => 'Aco', 'alias' => 'Aco'));

View file

@ -581,7 +581,7 @@ class RequestHandlerComponent extends Object {
} elseif (count($types) === 1) {
return ($types[0] === $accepts[0]);
} elseif (count($accepts) === 1) {
return $accepts[0];
return $accepts[0];
}
$acceptedTypes = array();

View file

@ -165,7 +165,6 @@ class Debugger extends Object {
$this->_templates['js']['code'] = '<div id="{:id}-code" class="cake-code-dump" ';
$this->_templates['js']['code'] .= 'style="display: none;"><pre>{:code}</pre></div>';
$e = '<pre class="cake-debug"><b>{:error}</b> ({:code}) : {:description} ';
$e .= '[<b>{:path}</b>, line <b>{:line}]</b></pre>';
$this->_templates['html']['error'] = $e;

View file

@ -29,7 +29,7 @@
*
*/
if (!class_exists('Object')) {
uses('object');
require LIBS . 'object.php';
}
if (!class_exists('Folder')) {
require LIBS . 'folder.php';

View file

@ -29,7 +29,7 @@
*
*/
if (!class_exists('Object')) {
uses('object');
require LIBS . 'object.php';
}
/**

View file

@ -877,9 +877,16 @@ class HttpSocket extends CakeSocket {
$cookies = array();
foreach ((array)$header['Set-Cookie'] as $cookie) {
$parts = preg_split('/(?<![^;]");[ \t]*/', $cookie);
if (strpos($cookie, '";"') !== false) {
$cookie = str_replace('";"', "{__cookie_replace__}", $cookie);
$parts = str_replace("{__cookie_replace__}", '";"', preg_split('/\;/', $cookie));
} else {
$parts = preg_split('/\;[ \t]*/', $cookie);
}
list($name, $value) = explode('=', array_shift($parts), 2);
$cookies[$name] = compact('value');
foreach ($parts as $part) {
if (strpos($part, '=') !== false) {
list($key, $value) = explode('=', $part);

View file

@ -126,7 +126,7 @@ class Inflector extends Object {
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
'/([ftw]ax)es/' => '\1',
'/(cris|ax|test)es$/i' => '\1is',
'/(shoe)s$/i' => '\1',
'/(shoe|slave)s$/i' => '\1',
'/(o)es$/i' => '\1',
'/ouses$/' => 'ouse',
'/uses$/' => 'us',

View file

@ -160,8 +160,8 @@ class L10n extends Object {
/* Sami (Lappish) */ 'smi' => 'sz',
/* Serbian */ 'scc' => 'sr',
/* Serbian */ 'srp' => 'sr',
/* Slovack */ 'slo' => 'sk',
/* Slovack */ 'slk' => 'sk',
/* Slovak */ 'slo' => 'sk',
/* Slovak */ 'slk' => 'sk',
/* Slovenian */ 'slv' => 'sl',
/* Sorbian */ 'wen' => 'sb',
/* Spanish (Spain - Traditional) */ 'spa' => 'es',
@ -301,7 +301,7 @@ class L10n extends Object {
'ro-mo' => array('language' => 'Romanian (Moldavia)', 'locale' => 'ro_mo', 'localeFallback' => 'rum', 'charset' => 'utf-8'),
'ru-mo' => array('language' => 'Russian (Moldavia)', 'locale' => 'ru_mo', 'localeFallback' => 'rus', 'charset' => 'utf-8'),
'sb' => array('language' => 'Sorbian', 'locale' => 'wen', 'localeFallback' => 'wen', 'charset' => 'utf-8'),
'sk' => array('language' => 'Slovack', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8'),
'sk' => array('language' => 'Slovak', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8'),
'sl' => array('language' => 'Slovenian', 'locale' => 'slv', 'localeFallback' => 'slv', 'charset' => 'utf-8'),
'sq' => array('language' => 'Albanian', 'locale' => 'alb', 'localeFallback' => 'alb', 'charset' => 'utf-8'),
'sr' => array('language' => 'Serbian', 'locale' => 'scc', 'localeFallback' => 'scc', 'charset' => 'utf-8'),

View file

@ -23,8 +23,11 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
if (!class_exists('Object')) {
require LIBS . 'object.php';
}
if (!class_exists('File')) {
uses('object', 'file');
require LIBS . 'file.php';
}
/**

View file

@ -59,7 +59,7 @@ class AclBehavior extends ModelBehavior {
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
if (!class_exists('AclNode')) {
uses('model' . DS . 'db_acl');
require LIBS . 'model' . DS . 'db_acl.php';
}
$model->{$type} =& ClassRegistry::init($type);
if (!method_exists($model, 'parentNode')) {

View file

@ -323,7 +323,7 @@ class ContainableBehavior extends ModelBehavior {
$option = 'conditions';
$val = $Model->{$name}->alias.'.'.$key;
}
$children[$option] = isset($children[$option]) ? array_merge((array) $children[$option], (array) $val) : $val;
$children[$option] = is_array($val) ? $val : array($val);
$newChildren = null;
if (!empty($name) && !empty($children[$key])) {
$newChildren = $children[$key];

View file

@ -90,7 +90,7 @@ class CakeSchema extends Object {
}
if (empty($options['path'])) {
$this->path = CONFIGS . 'sql';
$this->path = CONFIGS . 'schema';
}
$options = array_merge(get_object_vars($this), $options);
@ -161,6 +161,7 @@ class CakeSchema extends Object {
extract(get_object_vars($this));
$class = $name .'Schema';
if (!class_exists($class)) {
if (file_exists($path . DS . $file) && is_file($path . DS . $file)) {
require_once($path . DS . $file);
@ -366,7 +367,6 @@ class CakeSchema extends Object {
}
$out .="}\n";
$File =& new File($path . DS . $file, true);
$header = '$Id';
$content = "<?php \n/* SVN FILE: {$header}$ */\n/* {$name} schema generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";

View file

@ -102,7 +102,7 @@ class DataSource extends Object {
* Enter description here...
*
* @var array
* @access private
* @access protected
*/
var $_result = null;
@ -110,7 +110,7 @@ class DataSource extends Object {
* Queries count.
*
* @var int
* @access private
* @access protected
*/
var $_queriesCnt = 0;
@ -118,7 +118,7 @@ class DataSource extends Object {
* Total duration of all queries.
*
* @var unknown_type
* @access private
* @access protected
*/
var $_queriesTime = null;
@ -126,7 +126,7 @@ class DataSource extends Object {
* Log of queries executed by this DataSource
*
* @var unknown_type
* @access private
* @access protected
*/
var $_queriesLog = array();
@ -136,7 +136,7 @@ class DataSource extends Object {
* >6000 queries on one system.
*
* @var int Maximum number of queries in the queries log.
* @access private
* @access protected
*/
var $_queriesLogMax = 200;
@ -144,7 +144,7 @@ class DataSource extends Object {
* Caches serialzed results of executed queries
*
* @var array Maximum number of queries in the queries log.
* @access private
* @access protected
*/
var $_queryCache = array();
@ -152,7 +152,7 @@ class DataSource extends Object {
* The default configuration of a specific DataSource
*
* @var array
* @access public
* @access protected
*/
var $_baseConfig = array();

View file

@ -226,9 +226,10 @@ class DboMssql extends DboSource {
return $cache;
}
$fields = false;
$cols = $this->fetchAll("SELECT COLUMN_NAME as Field, DATA_TYPE as Type, COL_LENGTH('" . $this->fullTableName($model, false) . "', COLUMN_NAME) as Length, IS_NULLABLE As [Null], COLUMN_DEFAULT as [Default], COLUMNPROPERTY(OBJECT_ID('" . $this->fullTableName($model, false) . "'), COLUMN_NAME, 'IsIdentity') as [Key], NUMERIC_SCALE as Size FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" . $this->fullTableName($model, false) . "'", false);
$table = $this->fullTableName($model, false);
$cols = $this->fetchAll("SELECT COLUMN_NAME as Field, DATA_TYPE as Type, COL_LENGTH('" . $table . "', COLUMN_NAME) as Length, IS_NULLABLE As [Null], COLUMN_DEFAULT as [Default], COLUMNPROPERTY(OBJECT_ID('" . $table . "'), COLUMN_NAME, 'IsIdentity') as [Key], NUMERIC_SCALE as Size FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" . $table . "'", false);
$fields = false;
foreach ($cols as $column) {
$field = $column[0]['Field'];
$fields[$field] = array(
@ -312,7 +313,8 @@ class DboMssql extends DboSource {
$fields = parent::fields($model, $alias, $fields, false);
$count = count($fields);
if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false) {
if ($count >= 1 && strpos($fields[0], 'COUNT(*)') === false) {
$result = array();
for ($i = 0; $i < $count; $i++) {
$prepend = '';
@ -323,6 +325,19 @@ class DboMssql extends DboSource {
$fieldAlias = count($this->__fieldMappings);
if (!preg_match('/\s+AS\s+/i', $fields[$i])) {
if (substr($fields[$i], -1) == '*') {
if (strpos($fields[$i], '.') !== false && $fields[$i] != $alias . '.*') {
$build = explode('.', $fields[$i]);
$AssociatedModel = $model->{$build[0]};
} else {
$AssociatedModel = $model;
}
$_fields = $this->fields($AssociatedModel, $AssociatedModel->alias, array_keys($AssociatedModel->schema()));
$result = array_merge($result, $_fields);
continue;
}
if (strpos($fields[$i], '.') === false) {
$this->__fieldMappings[$alias . '__' . $fieldAlias] = $alias . '.' . $fields[$i];
$fieldName = $this->name($alias . '.' . $fields[$i]);
@ -338,10 +353,12 @@ class DboMssql extends DboSource {
}
$fields[$i] = "{$fieldName} AS {$fieldAlias}";
}
$fields[$i] = $prepend . $fields[$i];
$result[] = $prepend . $fields[$i];
}
return $result;
} else {
return $fields;
}
return $fields;
}
/**
@ -392,6 +409,9 @@ class DboMssql extends DboSource {
if (isset($fields[$model->primaryKey])) {
unset($fields[$model->primaryKey]);
}
if (empty($fields)) {
return true;
}
return parent::update($model, array_keys($fields), array_values($fields), $conditions);
}
@ -485,8 +505,8 @@ class DboMssql extends DboSource {
}
return $col;
}
$col = str_replace(')', '', $real);
$limit = null;
$col = str_replace(')', '', $real);
$limit = null;
if (strpos($col, '(') !== false) {
list($col, $limit) = explode('(', $col);
}
@ -692,21 +712,15 @@ class DboMssql extends DboSource {
* Generate a database-native column schema string
*
* @param array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]),
* where options can be 'default', 'length', or 'key'.
* where options can be 'default', 'length', or 'key'.
* @return string
*/
function buildColumn($column) {
$result = preg_replace('/(int|integer)\([0-9]+\)/i', '$1', parent::buildColumn($column));
$null = (
(isset($column['null']) && $column['null'] == true) ||
(array_key_exists('default', $column) && $column['default'] === null) ||
(array_keys($column) == array('type', 'name'))
);
$primaryKey = (isset($column['key']) && $column['key'] == 'primary');
$stringKey = ($primaryKey && $column['type'] != 'integer');
if ($null && !$primaryKey) {
$result .= " NULL";
if (strpos($result, 'DEFAULT NULL') !== false) {
$result = str_replace('DEFAULT NULL', 'NULL', $result);
} else if (array_keys($column) == array('type', 'name')) {
$result .= ' NULL';
}
return $result;
}
@ -758,7 +772,6 @@ class DboMssql extends DboSource {
return $field;
}
}
return null;
}
}

View file

@ -204,10 +204,11 @@ class DboOracle extends DboSource {
}
return $this->connected;
}
/**
* Keeps track of the most recent Oracle error
*
*/
/**
* Keeps track of the most recent Oracle error
*
*/
function _setError($source = null, $clear = false) {
if ($source) {
$e = ocierror($source);
@ -497,11 +498,12 @@ class DboOracle extends DboSource {
* @access public
*/
function describe(&$model) {
$table = $model->fullTableName($model, false);
if (!empty($model->sequence)) {
$this->_sequenceMap[$model->table] = $model->sequence;
$this->_sequenceMap[$table] = $model->sequence;
} elseif (!empty($model->table)) {
$this->_sequenceMap[$model->table] = $model->table . '_seq';
$this->_sequenceMap[$table] = $model->table . '_seq';
}
$cache = parent::describe($model);
@ -509,12 +511,14 @@ class DboOracle extends DboSource {
if ($cache != null) {
return $cache;
}
$sql = 'SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH FROM all_tab_columns WHERE table_name = \'';
$sql .= strtoupper($this->fullTableName($model)) . '\'';
if (!$this->execute($sql)) {
return false;
}
$fields = array();
for ($i = 0; $row = $this->fetchRow(); $i++) {
@ -1069,7 +1073,6 @@ class DboOracle extends DboSource {
$q = str_replace('= (', 'IN (', $q);
$q = str_replace(' WHERE 1 = 1', '', $q);
$q = $this->insertQueryData($q, null, $association, $assocData, $model, $linkModel, $stack);
if ($q != false) {
$res = $this->fetchAll($q, $model->cacheQueries, $model->alias);
@ -1139,14 +1142,15 @@ class DboOracle extends DboSource {
}
}
}
/**
* Generate a "drop table" statement for the given Schema object
*
* @param object $schema An instance of a subclass of CakeSchema
* @param string $table Optional. If specified only the table name given will be generated.
* Otherwise, all tables defined in the schema are generated.
* @return string
*/
/**
* Generate a "drop table" statement for the given Schema object
*
* @param object $schema An instance of a subclass of CakeSchema
* @param string $table Optional. If specified only the table name given will be generated.
* Otherwise, all tables defined in the schema are generated.
* @return string
*/
function dropSchema($schema, $table = null) {
if (!is_a($schema, 'CakeSchema')) {
trigger_error(__('Invalid schema object', true), E_USER_WARNING);

View file

@ -1447,6 +1447,7 @@ class DboSource extends DataSource {
function _prepareUpdateFields(&$model, $fields, $quoteValues = true, $alias = false) {
$quotedAlias = $this->startQuote . $model->alias . $this->endQuote;
$updates = array();
foreach ($fields as $field => $value) {
if ($alias && strpos($field, '.') === false) {
$quoted = $model->escapeField($field);
@ -2459,11 +2460,12 @@ class DboSource extends DataSource {
if (!empty($value['unique'])) {
$out .= 'UNIQUE ';
}
$name = $this->startQuote . $name . $this->endQuote;
}
if (is_array($value['column'])) {
$out .= 'KEY '. $name .' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
$out .= 'KEY ' . $name . ' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
} else {
$out .= 'KEY '. $name .' (' . $this->name($value['column']) . ')';
$out .= 'KEY ' . $name . ' (' . $this->name($value['column']) . ')';
}
$join[] = $out;
}

View file

@ -2575,8 +2575,8 @@ class Model extends Overloadable {
* rule (in case of multiple validation for field) that was broken.
*
* @param string $field The name of the field to invalidate
* @param mixed $value Name of validation rule that was not failed. If no validation key
* is provided, defaults to true.
* @param mixed $value Name of validation rule that was not failed, or validation message to
* be returned. If no validation key is provided, defaults to true.
* @access public
*/
function invalidate($field, $value = true) {

View file

@ -1063,7 +1063,7 @@ class Multibyte extends Object {
* @return string
* @access private
*/
function __codepoint ($decimal) {
function __codepoint($decimal) {
if ($decimal > 128 && $decimal < 256) {
$return = '0080_00ff'; // Latin-1 Supplement
} elseif ($decimal < 384) {

View file

@ -83,9 +83,10 @@ class Object {
/**
* Calls a controller's method from any location.
*
* @param string $url URL in the form of Cake URL ("/controller/method/parameter")
* @param mixed $url String or array-based url.
* @param array $extra if array includes the key "return" it sets the AutoRender to true.
* @return mixed Success (true/false) or contents if 'return' is set in $extra
* @return mixed Boolean true or false on success/failure, or contents
* of rendered action if 'return' is set in $extra.
* @access public
*/
function requestAction($url, $extra = array()) {
@ -157,7 +158,7 @@ class Object {
*/
function log($msg, $type = LOG_ERROR) {
if (!class_exists('CakeLog')) {
uses('cake_log');
require LIBS . 'cake_log.php';
}
if (is_null($this->_log)) {
$this->_log = new CakeLog();

View file

@ -45,12 +45,12 @@ class Security extends Object {
var $hashType = null;
/**
* Singleton implementation to get object instance.
*
* @return object
* @access public
* @static
*/
* Singleton implementation to get object instance.
*
* @return object
* @access public
* @static
*/
function &getInstance() {
static $instance = array();
if (!$instance) {
@ -60,12 +60,12 @@ class Security extends Object {
}
/**
* Get allowed minutes of inactivity based on security level.
*
* @return integer Allowed inactivity in minutes
* @access public
* @static
*/
* Get allowed minutes of inactivity based on security level.
*
* @return integer Allowed inactivity in minutes
* @access public
* @static
*/
function inactiveMins() {
$_this =& Security::getInstance();
switch (Configure::read('Security.level')) {
@ -83,12 +83,12 @@ class Security extends Object {
}
/**
* Generate authorization hash.
*
* @return string Hash
* @access public
* @static
*/
* Generate authorization hash.
*
* @return string Hash
* @access public
* @static
*/
function generateAuthKey() {
if (!class_exists('String')) {
App::import('Core', 'String');

View file

@ -422,7 +422,7 @@ class Set extends Object {
$context['key'] = array_pop($context['trace']);
if (isset($context['trace'][1]) && $context['trace'][1] > 0) {
$context['item'] = $context['item'][0];
} else if(!empty($context['item'][$key])){
} elseif (!empty($context['item'][$key])) {
$context['item'] = $context['item'][$key];
} else {
$context['item'] = array_shift($context['item']);

View file

@ -778,7 +778,7 @@ class Validation extends Object {
* @return boolean Success
* @access public
*/
function range($check, $lower = null, $upper = null ) {
function range($check, $lower = null, $upper = null) {
if (!is_numeric($check)) {
return false;
}

View file

@ -508,7 +508,6 @@ class AjaxHelper extends AppHelper {
$options = $this->_optionsToString($options, array('paramName', 'indicator'));
$options = $this->_buildOptions($options, $this->autoCompleteOptions);
$text = $this->Form->text($field, $htmlOptions);
$div = $this->Html->div(null, '', $divOptions);
$script = "{$var}new Ajax.Autocompleter('{$htmlOptions['id']}', '{$divOptions['id']}', '";
@ -903,7 +902,7 @@ class AjaxHelper extends AppHelper {
$callback = $this->remoteFunction($options);
$hasFrequency = !(!isset($options['frequency']) || intval($options['frequency']) == 0);
$frequency = $hasFrequency ? $options['frequency'] . ', ' : '';
$frequency = $hasFrequency ? $options['frequency'] . ', ' : '';
return "new $klass('$name', {$frequency}function(element, value) {{$callback}})";
}
@ -1018,5 +1017,4 @@ class AjaxHelper extends AppHelper {
}
}
}
?>

View file

@ -598,6 +598,15 @@ class JavascriptHelper extends AppHelper {
* Generates a JavaScript object in JavaScript Object Notation (JSON)
* from an array
*
* ### Options
*
* - block - Wraps the return value in a script tag if true. Default is false
* - prefix - Prepends the string to the returned data. Default is ''
* - postfix - Appends the string to the returned data. Default is ''
* - stringKeys - A list of array keys to be treated as a string.
* - quoteKeys - If false treats $stringKeys as a list of keys **not** to be quoted. Default is true.
* - q - The type of quote to use. Default is "'"
*
* @param array $data Data to be converted
* @param array $options Set of options: block, prefix, postfix, stringKeys, quoteKeys, q
* @param string $prefix DEPRECATED, use $options['prefix'] instead. Prepends the string to the returned data

View file

@ -67,10 +67,10 @@ class PaginatorHelper extends AppHelper {
var $options = array();
/**
* Gets the current page of the in the recordset for the given model
* Gets the current paging parameters from the resultset for the given model
*
* @param string $model Optional model name. Uses the default if none is specified.
* @return string The current page number of the paginated resultset.
* @return array The array of paging parameters for the paginated resultset.
*/
function params($model = null) {
if (empty($model)) {

View file

@ -168,5 +168,4 @@ class XmlHelper extends AppHelper {
return $data->toString($options + array('header' => false));
}
}
?>

View file

@ -79,7 +79,9 @@ endif;
</p>
<?php
if (isset($filePresent)):
uses('model' . DS . 'connection_manager');
if (!class_exists('ConnectionManager')) {
require LIBS . 'model' . DS . 'connection_manager.php';
}
$db = ConnectionManager::getInstance();
@$connected = $db->getDataSource('default');
?>

View file

@ -58,7 +58,7 @@ class ThemeView extends View {
*
* @param unknown_type $controller
*/
function __construct (&$controller) {
function __construct(&$controller) {
parent::__construct($controller);
$this->theme =& $controller->theme;

View file

@ -216,6 +216,7 @@ class XmlNode extends Object {
}
$tagOpts = $this->__tagOptions($name);
if ($tagOpts === false) {
return;
}
@ -236,7 +237,6 @@ class XmlNode extends Object {
$attributes = array();
$children = array();
$chldObjs = array();
$document =& $this->document();
if (is_object($object)) {
$chldObjs = get_object_vars($object);
@ -254,7 +254,12 @@ class XmlNode extends Object {
$node->createTextNode($chldObjs[$tagOpts['value']]);
unset($chldObjs[$tagOpts['value']]);
}
unset($chldObjs['_name_']);
$n = $name;
if (!empty($chldObjs['_name_'])) {
$n = null;
unset($chldObjs['_name_']);
}
$c = 0;
foreach ($chldObjs as $key => $val) {
@ -262,14 +267,11 @@ class XmlNode extends Object {
$attributes[$key] = $val;
} else {
if (!isset($tagOpts['children']) || $tagOpts['children'] === array() || (is_array($tagOpts['children']) && in_array($key, $tagOpts['children']))) {
$n = $key;
if (is_numeric($n)) {
$n = $name;
if (!is_numeric($key)) {
$n = $key;
}
if (is_array($val)) {
foreach ($val as $i => $obj2) {
$n2 = $i;
foreach ($val as $n2 => $obj2) {
if (is_numeric($n2)) {
$n2 = $n;
}
@ -277,6 +279,7 @@ class XmlNode extends Object {
}
} else {
if (is_object($val)) {
$node->normalize($val, $n, $options);
} elseif ($options['format'] == 'tags' && $this->__tagOptions($key) !== false) {
$tmp =& $node->createElement($key);
@ -661,7 +664,6 @@ class XmlNode extends Object {
if ($options['whitespace']) {
$d .= "\n";
}
$count = count($this->children);
$cDepth = $depth + 1;
for ($i = 0; $i < $count; $i++) {

View file

@ -153,6 +153,7 @@ class BasicsTest extends CakeTestCase {
*
* @access public
* @return void
* @deprecated
*/
function testUses() {
$this->skipIf(class_exists('Security') || class_exists('Sanitize'), '%s Security and/or Sanitize class already loaded');
@ -587,7 +588,7 @@ class BasicsTest extends CakeTestCase {
ob_start();
debug('this-is-a-test');
$result = ob_get_clean();
$pattern = '/.*\>(cake(\/|\\\)tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
$pattern = '/.*\>(.+?cake(\/|\\\)tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
$pattern .= preg_quote(substr(__FILE__, 1), '/') . ')';
$pattern .= '.*line.*' . (__LINE__ - 4) . '.*this-is-a-test.*/s';
$this->assertPattern($pattern, $result);
@ -595,7 +596,7 @@ class BasicsTest extends CakeTestCase {
ob_start();
debug('<div>this-is-a-test</div>', true);
$result = ob_get_clean();
$pattern = '/.*\>(cake(\/|\\\)tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
$pattern = '/.*\>(.+?cake(\/|\\\)tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
$pattern .= preg_quote(substr(__FILE__, 1), '/') . ')';
$pattern .= '.*line.*' . (__LINE__ - 4) . '.*&lt;div&gt;this-is-a-test&lt;\/div&gt;.*/s';
$this->assertPattern($pattern, $result);

View file

@ -125,7 +125,7 @@ class TestShellDispatcher extends ShellDispatcher {
* @return void
*/
function clear() {
}
/**
@ -225,7 +225,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
$params = array('cake.php');
$expected = array(
'app' => 'app',
@ -237,7 +236,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
$params = array(
'cake.php',
'-app',
@ -253,7 +251,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
$params = array(
'./cake.php',
'bake',
@ -274,7 +271,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
$params = array(
'./console/cake.php',
'bake',
@ -293,7 +289,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
$params = array(
'./console/cake.php',
'bake',
@ -314,7 +309,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
$params = array(
'./console/cake.php',
'-working',
@ -340,11 +334,9 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
$expected = array('./console/cake.php', 'schema', 'run', 'create');
$this->assertEqual($expected, $Dispatcher->args);
$params = array(
'/cake/1.2.x.x/cake/console/cake.php',
'-working',
@ -368,7 +360,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
$expected = array('/cake/1.2.x.x/cake/console/cake.php', 'schema', 'run', 'create');
$this->assertEqual($expected, $Dispatcher->args);
$params = array(
@ -386,12 +377,10 @@ class ShellDispatcherTest extends CakeTestCase {
'root' => 'C:\wamp\www\apps\cake'
);
$Dispatcher->params = $Dispatcher->args = array();
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
$params = array(
'cake.php',
'-working',
@ -410,7 +399,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
$params = array(
'cake.php',
'-working',
@ -432,7 +420,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
$params = array(
'/home/amelo/dev/cake-common/cake/console/cake.php',
'-root',

View file

@ -46,9 +46,11 @@ Mock::generatePartial(
);
Mock::generatePartial(
'AclShell', 'MockAclShell',
array('in', 'out', 'hr', 'createFile')
array('in', 'out', 'hr', 'createFile', 'error', 'err')
);
Mock::generate('AclComponent', 'MockAclShellAclComponent');
/**
* AclShellTest class
*
@ -82,7 +84,7 @@ class AclShellTest extends CakeTestCase {
}
/**
* setUp method
* startTest method
*
* @return void
* @access public
@ -92,10 +94,13 @@ class AclShellTest extends CakeTestCase {
$this->Task =& new MockAclShell($this->Dispatcher);
$this->Task->Dispatch = new $this->Dispatcher;
$this->Task->params['datasource'] = 'test_suite';
$this->Task->Acl =& new AclComponent();
$controller = null;
$this->Task->Acl->startup($controller);
}
/**
* tearDown method
* endTest method
*
* @return void
* @access public
@ -128,5 +133,89 @@ class AclShellTest extends CakeTestCase {
$this->Task->view();
}
/**
* test the method that splits model.foreign key. and that it returns an array.
*
* @return void
**/
function testParsingModelAndForeignKey() {
$result = $this->Task->parseIdentifier('Model.foreignKey');
$expected = array('model' => 'Model', 'foreign_key' => 'foreignKey');
$result = $this->Task->parseIdentifier('mySuperUser');
$this->assertEqual($result, 'mySuperUser');
$result = $this->Task->parseIdentifier('111234');
$this->assertEqual($result, '111234');
}
/**
* test creating aro/aco nodes
*
* @return void
**/
function testCreate() {
$this->Task->args = array('aro', 'root', 'User.1');
$this->Task->expectAt(0, 'out', array(new PatternExpectation('/created/'), '*'));
$this->Task->create();
$Aro =& ClassRegistry::init('Aro');
$Aro->cacheQueries = false;
$result = $Aro->read();
$this->assertEqual($result['Aro']['model'], 'User');
$this->assertEqual($result['Aro']['foreign_key'], 1);
$this->assertEqual($result['Aro']['parent_id'], null);
$id = $result['Aro']['id'];
$this->Task->args = array('aro', 'User.1', 'User.3');
$this->Task->expectAt(1, 'out', array(new PatternExpectation('/created/'), '*'));
$this->Task->create();
$Aro =& ClassRegistry::init('Aro');
$result = $Aro->read();
$this->assertEqual($result['Aro']['model'], 'User');
$this->assertEqual($result['Aro']['foreign_key'], 3);
$this->assertEqual($result['Aro']['parent_id'], $id);
$this->Task->args = array('aro', 'root', 'somealias');
$this->Task->expectAt(2, 'out', array(new PatternExpectation('/created/'), '*'));
$this->Task->create();
$Aro =& ClassRegistry::init('Aro');
$result = $Aro->read();
$this->assertEqual($result['Aro']['alias'], 'somealias');
$this->assertEqual($result['Aro']['model'], null);
$this->assertEqual($result['Aro']['foreign_key'], null);
$this->assertEqual($result['Aro']['parent_id'], null);
}
/**
* test the delete method with different node types.
*
* @return void
**/
function testDelete() {
$this->Task->args = array('aro', 'AuthUser.1');
$this->Task->expectAt(0, 'out', array(new NoPatternExpectation('/not/'), true));
$this->Task->delete();
$Aro =& ClassRegistry::init('Aro');
$result = $Aro->read(null, 3);
$this->assertFalse($result);
}
/**
* test setParent method.
*
* @return void
**/
function testSetParent() {
$this->Task->args = array('aro', 'AuthUser.2', 'root');
$this->Task->setParent();
$Aro =& ClassRegistry::init('Aro');
$result = $Aro->read(null, 4);
$this->assertEqual($result['Aro']['parent_id'], null);
}
}
?>

View file

@ -33,7 +33,6 @@ if (!class_exists('ShellDispatcher')) {
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'db_config.php';
//require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php';
Mock::generatePartial(
'ShellDispatcher', 'TestDbConfigTaskMockShellDispatcher',
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
@ -54,7 +53,7 @@ class TEST_DATABASE_CONFIG {
'database' => 'database_name',
'prefix' => '',
);
var $otherOne = array(
'driver' => 'mysql',
'persistent' => false,
@ -73,6 +72,7 @@ class TEST_DATABASE_CONFIG {
* @subpackage cake.tests.cases.console.libs.tasks
*/
class DbConfigTaskTest extends CakeTestCase {
/**
* startTest method
*
@ -88,6 +88,7 @@ class DbConfigTaskTest extends CakeTestCase {
$this->Task->params['working'] = rtrim(APP, '/');
$this->Task->databaseClassName = 'TEST_DATABASE_CONFIG';
}
/**
* endTest method
*
@ -98,6 +99,7 @@ class DbConfigTaskTest extends CakeTestCase {
unset($this->Task, $this->Dispatcher);
ClassRegistry::flush();
}
/**
* Test the getConfig method.
*
@ -108,6 +110,7 @@ class DbConfigTaskTest extends CakeTestCase {
$result = $this->Task->getConfig();
$this->assertEqual($result, 'otherOne');
}
/**
* test that initialize sets the path up.
*
@ -118,8 +121,9 @@ class DbConfigTaskTest extends CakeTestCase {
$this->Task->initialize();
$this->assertFalse(empty($this->Task->path));
$this->assertEqual($this->Task->path, APP . 'config' . DS);
}
/**
* test execute and by extension __interactive
*

View file

@ -47,6 +47,7 @@ Mock::generatePartial(
'Shell', 'MockFixtureModelTask',
array('in', 'out', 'err', 'createFile', '_stop', 'getName', 'getTable', 'listAll')
);
/**
* FixtureTaskTest class
*
@ -54,12 +55,14 @@ Mock::generatePartial(
* @subpackage cake.tests.cases.console.libs.tasks
*/
class FixtureTaskTest extends CakeTestCase {
/**
* fixtures
*
* @var array
**/
var $fixtures = array('core.article', 'core.comment');
/**
* startTest method
*
@ -75,6 +78,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->Dispatch->shellPaths = App::path('shells');
$this->Task->Template->initialize();
}
/**
* endTest method
*
@ -85,6 +89,7 @@ class FixtureTaskTest extends CakeTestCase {
unset($this->Task, $this->Dispatcher);
ClassRegistry::flush();
}
/**
* test that initialize sets the path
*
@ -97,6 +102,7 @@ class FixtureTaskTest extends CakeTestCase {
$expected = '/my/path/tests/fixtures/';
$this->assertEqual($Task->path, $expected);
}
/**
* test import option array generation
*
@ -117,7 +123,7 @@ class FixtureTaskTest extends CakeTestCase {
$result = $this->Task->importOptions('Article');
$expected = array();
$this->assertEqual($result, $expected);
$this->Task->setReturnValueAt(5, 'in', 'n');
$this->Task->setReturnValueAt(6, 'in', 'n');
$this->Task->setReturnValueAt(7, 'in', 'y');
@ -125,6 +131,7 @@ class FixtureTaskTest extends CakeTestCase {
$expected = array('fromTable' => true);
$this->assertEqual($result, $expected);
}
/**
* test generating a fixture with database conditions.
*
@ -143,6 +150,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->assertPattern('/Second Article/', $result, 'Missing import data %s');
$this->assertPattern('/Third Article/', $result, 'Missing import data %s');
}
/**
* test that execute passes runs bake depending with named model.
*
@ -156,6 +164,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/')));
$this->Task->execute();
}
/**
* test that execute runs all() when args[0] = all
*
@ -175,6 +184,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/class CommentFixture/')));
$this->Task->execute();
}
/**
* test interactive mode of execute
*
@ -183,7 +193,7 @@ class FixtureTaskTest extends CakeTestCase {
function testExecuteInteractive() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->setReturnValue('in', 'y');
$this->Task->Model->setReturnValue('getName', 'Article');
$this->Task->Model->setReturnValue('getTable', 'articles', array('Article'));
@ -192,6 +202,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/')));
$this->Task->execute();
}
/**
* Test that bake works
*
@ -225,6 +236,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->assertNoPattern('/var \$fields/', $result);
$this->assertNoPattern('/var \$records/', $result);
}
/**
* Test that file generation includes headers and correct path for plugins.
*
@ -241,6 +253,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/\<\?php(.*)\?\>/ms')));
$result = $this->Task->generateFixtureFile('Article', array());
}
/**
* test generating files into plugins.
*

View file

@ -1,5 +1,6 @@
<?php
/* SVN FILE: $Id$ */
/**
* TestTaskTest file
*
@ -92,11 +93,12 @@ class TestTaskTag extends Model {
)
);
}
/**
* Simulated Plugin
**/
class TestTaskAppModel extends Model {
}
class TestTaskComment extends TestTaskAppModel {
var $name = 'TestTaskComment';
@ -123,6 +125,7 @@ class TestTaskCommentsController extends Controller {
class TestTaskTest extends CakeTestCase {
var $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
/**
* startTest method
*
@ -136,6 +139,7 @@ class TestTaskTest extends CakeTestCase {
$this->Task->Dispatch =& $this->Dispatcher;
$this->Task->Template =& new TemplateTask($this->Dispatcher);
}
/**
* endTest method
*
@ -145,13 +149,14 @@ class TestTaskTest extends CakeTestCase {
function endTest() {
ClassRegistry::flush();
}
/**
* Test that file path generation doesn't continuously append paths.
*
* @access public
* @return void
*/
function testFilePathGeneration () {
function testFilePathGeneration() {
$file = TESTS . 'cases' . DS . 'models' . DS . 'my_class.test.php';
$this->Task->Dispatch->expectNever('stderr');
@ -168,8 +173,9 @@ class TestTaskTest extends CakeTestCase {
$this->Task->expectAt(2, 'createFile', array($file, '*'));
$this->Task->bake('Controller', 'Comments');
}
/**
* Test that method introspection pulls all relevant non parent class
* Test that method introspection pulls all relevant non parent class
* methods into the test case.
*
* @return void
@ -179,6 +185,7 @@ class TestTaskTest extends CakeTestCase {
$expected = array('doSomething', 'doSomethingElse');
$this->assertEqual($result, $expected);
}
/**
* test that the generation of fixtures works correctly.
*
@ -187,11 +194,12 @@ class TestTaskTest extends CakeTestCase {
function testFixtureArrayGenerationFromModel() {
$subject = ClassRegistry::init('TestTaskArticle');
$result = $this->Task->generateFixtureList($subject);
$expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
$expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
'app.test_task_article', 'app.test_task_tag');
$this->assertEqual(sort($result), sort($expected));
}
/**
* test that the generation of fixtures works correctly.
*
@ -200,11 +208,12 @@ class TestTaskTest extends CakeTestCase {
function testFixtureArrayGenerationFromController() {
$subject = new TestTaskCommentsController();
$result = $this->Task->generateFixtureList($subject);
$expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
$expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
'app.test_task_article', 'app.test_task_tag');
$this->assertEqual(sort($result), sort($expected));
}
/**
* test user interaction to get object type
*
@ -219,6 +228,7 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->getObjectType();
$this->assertEqual($result, $this->Task->classTypes[1]);
}
/**
* creating test subjects should clear the registry so the registry is always fresh
*
@ -242,6 +252,7 @@ class TestTaskTest extends CakeTestCase {
$keys = ClassRegistry::keys();
$this->assertFalse(in_array('random', $keys));
}
/**
* test that getClassName returns the user choice as a classname.
*
@ -262,6 +273,7 @@ class TestTaskTest extends CakeTestCase {
$options = Configure::listObjects('model');
$this->assertEqual($result, $options[0]);
}
/**
* Test the user interaction for defining additional fixtures.
*
@ -274,6 +286,7 @@ class TestTaskTest extends CakeTestCase {
$expected = array('app.pizza', 'app.topping', 'app.side_dish');
$this->assertEqual($result, $expected);
}
/**
* test that resolving classnames works
*
@ -295,6 +308,7 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->getRealClassname('Component', 'Auth');
$this->assertEqual($result, 'AuthComponent');
}
/**
* test baking files.
*
@ -323,6 +337,7 @@ class TestTaskTest extends CakeTestCase {
$this->assertPattern("/'app\.test_task_tag'/", $result);
$this->assertPattern("/'app\.articles_tag'/", $result);
}
/**
* test baking controller test files, ensure that the stub class is generated.
*
@ -352,6 +367,7 @@ class TestTaskTest extends CakeTestCase {
$this->assertPattern("/'app\.test_task_tag'/", $result);
$this->assertPattern("/'app\.articles_tag'/", $result);
}
/**
* test Constructor generation ensure that constructClasses is called for controllers
*
@ -370,6 +386,7 @@ class TestTaskTest extends CakeTestCase {
$expected = "new FormHelper()\n";
$this->assertEqual($result, $expected);
}
/**
* Test that mock class generation works for the appropriate classes
*
@ -379,6 +396,7 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->hasMockClass('controller');
$this->assertTrue($result);
}
/**
* test bake() with a -plugin param
*
@ -391,6 +409,7 @@ class TestTaskTest extends CakeTestCase {
$this->Task->expectAt(0, 'createFile', array($path, '*'));
$this->Task->bake('Helper', 'Form');
}
/**
* Test filename generation for each type + plugins
*
@ -424,6 +443,7 @@ class TestTaskTest extends CakeTestCase {
$expected = APP . 'plugins' . DS . 'test_test' . DS . 'tests' . DS . 'cases' . DS . 'models' . DS . 'post.test.php';
$this->assertEqual($result, $expected);
}
/**
* test execute with a type defined
*
@ -436,6 +456,7 @@ class TestTaskTest extends CakeTestCase {
$this->Task->expectAt(0, 'createFile', array('*', new PatternExpectation('/class TestTaskTagTestCase extends CakeTestCase/')));
$this->Task->execute();
}
/**
* test execute with type and class name defined
*

View file

@ -66,9 +66,9 @@ class CakeTestFixtureTestFixture extends CakeTestFixture {
* @var array
*/
var $records = array(
array('name' => 'Gandalf'),
array('name' => 'Captain Picard'),
array('name' => 'Chewbacca')
array('name' => 'Gandalf', 'created' => '2009-04-28 19:20:00'),
array('name' => 'Captain Picard', 'created' => '2009-04-28 19:20:00'),
array('name' => 'Chewbacca', 'created' => '2009-04-28 19:20:00')
);
}

View file

@ -27,6 +27,7 @@
*/
App::import('Controller', array('Component', 'Controller'), false);
App::import('Component', 'Cookie');
/**
* CookieComponentTestController class
*

View file

@ -105,6 +105,7 @@ class InflectorTest extends CakeTestCase {
$this->assertEqual(Inflector::singularize('lives'), 'life');
$this->assertEqual(Inflector::singularize('knives'), 'knife');
$this->assertEqual(Inflector::singularize('wolves'), 'wolf');
$this->assertEqual(Inflector::singularize('slaves'), 'slave');
$this->assertEqual(Inflector::singularize('shelves'), 'shelf');
$this->assertEqual(Inflector::singularize('taxis'), 'taxi');
$this->assertEqual(Inflector::singularize('taxes'), 'tax');

View file

@ -854,7 +854,7 @@ class L10nTest extends CakeTestCase {
$result = $l10n->catalog(array('sk'));
$expected = array(
'sk' => array('language' => 'Slovack', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8')
'sk' => array('language' => 'Slovak', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8')
);
$this->assertEqual($result, $expected);

File diff suppressed because one or more lines are too long

View file

@ -1999,70 +1999,76 @@ class ContainableBehaviorTest extends CakeTestCase {
);
$this->assertEqual($result, $expected);
$result = $this->User->find('all', array('contain' => array(
'ArticleFeatured' => array(
'title', 'order' => 'title DESC',
'Featured' => array(
'category_id',
'Category' => 'name'
)
)
)));
$expected = array(
array(
'User' => array(
'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
),
'ArticleFeatured' => array(
array(
'title' => 'Third Article', 'id' => 3, 'user_id' => 1,
'Featured' => array()
),
array(
'title' => 'First Article', 'id' => 1, 'user_id' => 1,
'Featured' => array(
'category_id' => 1, 'id' => 1,
'Category' => array(
'name' => 'Category 1'
)
)
)
)
),
array(
'User' => array(
'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'
),
'ArticleFeatured' => array()
),
array(
'User' => array(
'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31'
),
'ArticleFeatured' => array(
array(
'title' => 'Second Article', 'id' => 2, 'user_id' => 3,
'Featured' => array(
'category_id' => 1, 'id' => 2,
'Category' => array(
'name' => 'Category 1'
)
)
)
)
),
array(
'User' => array(
'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'
),
'ArticleFeatured' => array()
)
$orders = array(
'title DESC', 'title DESC, published DESC',
array('title' => 'DESC'), array('title' => 'DESC', 'published' => 'DESC'),
);
$this->assertEqual($result, $expected);
foreach ($orders as $order) {
$result = $this->User->find('all', array('contain' => array(
'ArticleFeatured' => array(
'title', 'order' => $order,
'Featured' => array(
'category_id',
'Category' => 'name'
)
)
)));
$expected = array(
array(
'User' => array(
'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
),
'ArticleFeatured' => array(
array(
'title' => 'Third Article', 'id' => 3, 'user_id' => 1,
'Featured' => array()
),
array(
'title' => 'First Article', 'id' => 1, 'user_id' => 1,
'Featured' => array(
'category_id' => 1, 'id' => 1,
'Category' => array(
'name' => 'Category 1'
)
)
)
)
),
array(
'User' => array(
'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'
),
'ArticleFeatured' => array()
),
array(
'User' => array(
'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31'
),
'ArticleFeatured' => array(
array(
'title' => 'Second Article', 'id' => 2, 'user_id' => 3,
'Featured' => array(
'category_id' => 1, 'id' => 2,
'Category' => array(
'name' => 'Category 1'
)
)
)
)
),
array(
'User' => array(
'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'
),
'ArticleFeatured' => array()
)
);
$this->assertEqual($result, $expected);
}
}
/**
@ -3249,7 +3255,6 @@ class ContainableBehaviorTest extends CakeTestCase {
$options = array(
'conditions' => array(
'Comment.comment !=' => 'Crazy',
'Comment.published' => 'Y',
),
'contain' => 'User',
@ -3260,7 +3265,6 @@ class ContainableBehaviorTest extends CakeTestCase {
$dummyResult = $this->Article->Comment->find('all', array(
'conditions' => array(
'Comment.comment !=' => 'Silly',
'User.user' => 'mariano'
),
'fields' => array('User.password'),
@ -3345,7 +3349,6 @@ class ContainableBehaviorTest extends CakeTestCase {
$initialOptions = array(
'conditions' => array(
'Comment.comment' => '!= Crazy',
'Comment.published' => 'Y',
),
'contain' => 'User',
@ -3356,7 +3359,6 @@ class ContainableBehaviorTest extends CakeTestCase {
$findOptions = array(
'conditions' => array(
'Comment.comment !=' => 'Silly',
'User.user' => 'mariano',
),
'fields' => array('User.password'),
@ -3436,7 +3438,8 @@ class ContainableBehaviorTest extends CakeTestCase {
'joinTable' => 'articles_tags',
'foreignKey' => 'article_id',
'associationForeignKey' => 'tag_id',
'conditions' => 'LENGTH(ShortTag.tag) <= 3'
// LENGHT function mysql-only, using LIKE does almost the same
'conditions' => 'ShortTag.tag LIKE "???"'
)
)
);

View file

@ -441,15 +441,18 @@ class TranslateBehaviorTest extends CakeTestCase {
$expected = array(1 => 'Titel #1', 2 => 'Titel #2', 3 => 'Titel #3');
$this->assertEqual($result, $expected);
$debug = Configure::read('debug');
Configure::write('debug', 0);
// MSSQL trigger an error and stops the page even if the debug = 0
if ($this->db->config['driver'] != 'mssql') {
$debug = Configure::read('debug');
Configure::write('debug', 0);
$result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => false));
$this->assertEqual($result, array());
$result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => false));
$this->assertEqual($result, array());
$result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'after'));
$this->assertEqual($result, array());
Configure::write('debug', $debug);
$result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'after'));
$this->assertEqual($result, array());
Configure::write('debug', $debug);
}
$result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'before'));
$expected = array(1 => null, 2 => null, 3 => null);

View file

@ -47,6 +47,20 @@ class DboMssqlTestDb extends DboMssql {
*/
var $simulated = array();
/**
* simalate property
*
* @var array
* @access public
*/
var $simulate = true;
/**
* simalate property
*
* @var array
* @access public
*/
var $simulate = true;
/**
* fetchAllResultsStack
*
@ -63,8 +77,12 @@ class DboMssqlTestDb extends DboMssql {
* @return void
*/
function _execute($sql) {
$this->simulated[] = $sql;
return null;
if ($this->simulate) {
$this->simulated[] = $sql;
return null;
} else {
return parent::_execute($sql);
}
}
/**
@ -113,6 +131,15 @@ class DboMssqlTestDb extends DboMssql {
function getPrimaryKey($model) {
return parent::_getPrimaryKey($model);
}
/**
* clearFieldMappings method
*
* @access public
* @return void
*/
function clearFieldMappings() {
$this->__fieldMappings = array();
}
}
/**
@ -166,6 +193,28 @@ class MssqlTestModel extends Model {
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
/**
* belongsTo property
*
* @var array
* @access public
*/
var $belongsTo = array(
'MssqlClientTestModel' => array(
'foreignKey' => 'client_id'
)
);
/**
* belongsTo property
*
* @var array
* @access public
*/
var $belongsTo = array(
'MssqlClientTestModel' => array(
'foreignKey' => 'client_id'
)
);
/**
* find method
*
@ -206,6 +255,76 @@ class MssqlTestModel extends Model {
}
}
/**
* MssqlClientTestModel class
*
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class MssqlClientTestModel extends Model {
/**
* name property
*
* @var string 'MssqlAssociatedTestModel'
* @access public
*/
var $name = 'MssqlClientTestModel';
/**
* useTable property
*
* @var bool false
* @access public
*/
var $useTable = false;
/**
* _schema property
*
* @var array
* @access protected
*/
var $_schema = array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'created' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
}
/**
* MssqlClientTestModel class
*
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class MssqlClientTestModel extends Model {
/**
* name property
*
* @var string 'MssqlAssociatedTestModel'
* @access public
*/
var $name = 'MssqlClientTestModel';
/**
* useTable property
*
* @var bool false
* @access public
*/
var $useTable = false;
/**
* _schema property
*
* @var array
* @access protected
*/
var $_schema = array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'created' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
}
/**
* DboMssqlTest class
*
@ -222,6 +341,34 @@ class DboMssqlTest extends CakeTestCase {
*/
var $db = null;
/**
* autoFixtures property
*
* @var bool false
* @access public
*/
var $autoFixtures = false;
/**
* fixtures property
*
* @var array
* @access public
*/
var $fixtures = array('core.category');
/**
* autoFixtures property
*
* @var bool false
* @access public
*/
var $autoFixtures = false;
/**
* fixtures property
*
* @var array
* @access public
*/
var $fixtures = array('core.category');
/**
* Skip if cannot connect to mssql
*
@ -232,6 +379,46 @@ class DboMssqlTest extends CakeTestCase {
$this->skipUnless($this->db->config['driver'] == 'mssql', '%s SQL Server connection not available');
}
/**
* Make sure all fixtures tables are being created
*
* @access public
*/
function start() {
$this->db->simulate = false;
parent::start();
$this->db->simulate = true;
}
/**
* Make sure all fixtures tables are being dropped
*
* @access public
*/
function end() {
$this->db->simulate = false;
parent::end();
$this->db->simulate = true;
}
/**
* Make sure all fixtures tables are being created
*
* @access public
*/
function start() {
$this->db->simulate = false;
parent::start();
$this->db->simulate = true;
}
/**
* Make sure all fixtures tables are being dropped
*
* @access public
*/
function end() {
$this->db->simulate = false;
parent::end();
$this->db->simulate = true;
}
/**
* Sets up a Dbo class instance for testing
*
@ -260,8 +447,22 @@ class DboMssqlTest extends CakeTestCase {
* @return void
*/
function testQuoting() {
$result = $this->db->fields($this->model);
$expected = array(
$expected = "1.2";
$result = $this->db->value(1.2, 'float');
$this->assertIdentical($expected, $result);
$expected = "'1,2'";
$result = $this->db->value('1,2', 'float');
$this->assertIdentical($expected, $result);
}
/**
* testFields method
*
* @access public
* @return void
*/
function testFields() {
$fields = array(
'[MssqlTestModel].[id] AS [MssqlTestModel__0]',
'[MssqlTestModel].[client_id] AS [MssqlTestModel__1]',
'[MssqlTestModel].[name] AS [MssqlTestModel__2]',
@ -281,15 +482,32 @@ class DboMssqlTest extends CakeTestCase {
'[MssqlTestModel].[created] AS [MssqlTestModel__16]',
'CONVERT(VARCHAR(20), [MssqlTestModel].[updated], 20) AS [MssqlTestModel__17]'
);
$result = $this->db->fields($this->model);
$expected = $fields;
$this->assertEqual($result, $expected);
$expected = "1.2";
$result = $this->db->value(1.2, 'float');
$this->assertIdentical($expected, $result);
$this->db->clearFieldMappings();
$result = $this->db->fields($this->model, null, 'MssqlTestModel.*');
$expected = $fields;
$this->assertEqual($result, $expected);
$expected = "'1,2'";
$result = $this->db->value('1,2', 'float');
$this->assertIdentical($expected, $result);
$this->db->clearFieldMappings();
$result = $this->db->fields($this->model, null, array('*', 'AnotherModel.id', 'AnotherModel.name'));
$expected = array_merge($fields, array(
'[AnotherModel].[id] AS [AnotherModel__18]',
'[AnotherModel].[name] AS [AnotherModel__19]'));
$this->assertEqual($result, $expected);
$this->db->clearFieldMappings();
$result = $this->db->fields($this->model, null, array('*', 'MssqlClientTestModel.*'));
$expected = array_merge($fields, array(
'[MssqlClientTestModel].[id] AS [MssqlClientTestModel__18]',
'[MssqlClientTestModel].[name] AS [MssqlClientTestModel__19]',
'[MssqlClientTestModel].[email] AS [MssqlClientTestModel__20]',
'CONVERT(VARCHAR(20), [MssqlClientTestModel].[created], 20) AS [MssqlClientTestModel__21]',
'CONVERT(VARCHAR(20), [MssqlClientTestModel].[updated], 20) AS [MssqlClientTestModel__22]'));
$this->assertEqual($result, $expected);
}
/**
@ -356,6 +574,122 @@ class DboMssqlTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
/**
* testBuildColumn
*
* @return unknown_type
* @access public
*/
function testBuildColumn() {
$column = array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary');
$result = $this->db->buildColumn($column);
$expected = '[id] int IDENTITY (1, 1) NOT NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'client_id', 'type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11');
$result = $this->db->buildColumn($column);
$expected = '[client_id] int DEFAULT 0 NOT NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'client_id', 'type' => 'integer', 'null' => true);
$result = $this->db->buildColumn($column);
$expected = '[client_id] int NULL';
$this->assertEqual($result, $expected);
// 'name' => 'type' format for columns
$column = array('type' => 'integer', 'name' => 'client_id');
$result = $this->db->buildColumn($column);
$expected = '[client_id] int NULL';
$this->assertEqual($result, $expected);
$column = array('type' => 'string', 'name' => 'name');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) DEFAULT \'\' NOT NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'length' => '255');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) NOT NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => null, 'length' => '255');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) NOT NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '255');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) DEFAULT \'\'';
$this->assertEqual($result, $expected);
}
/**
* testBuildColumn
*
* @return unknown_type
* @access public
*/
function testBuildColumn() {
$column = array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary');
$result = $this->db->buildColumn($column);
$expected = '[id] int IDENTITY (1, 1) NOT NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'client_id', 'type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11');
$result = $this->db->buildColumn($column);
$expected = '[client_id] int DEFAULT 0 NOT NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'client_id', 'type' => 'integer', 'null' => true);
$result = $this->db->buildColumn($column);
$expected = '[client_id] int NULL';
$this->assertEqual($result, $expected);
// 'name' => 'type' format for columns
$column = array('type' => 'integer', 'name' => 'client_id');
$result = $this->db->buildColumn($column);
$expected = '[client_id] int NULL';
$this->assertEqual($result, $expected);
$column = array('type' => 'string', 'name' => 'name');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) DEFAULT \'\' NOT NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'length' => '255');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) NOT NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => null, 'length' => '255');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) NOT NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '255');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) DEFAULT \'\'';
$this->assertEqual($result, $expected);
}
/**
* testUpdateAllSyntax method
*
@ -380,6 +714,7 @@ class DboMssqlTest extends CakeTestCase {
* @access public
*/
function testGetPrimaryKey() {
// When param is a model
$result = $this->db->getPrimaryKey($this->model);
$this->assertEqual($result, 'id');
@ -388,6 +723,12 @@ class DboMssqlTest extends CakeTestCase {
$this->model->setSchema($schema);
$result = $this->db->getPrimaryKey($this->model);
$this->assertNull($result);
// When param is a table name
$this->db->simulate = false;
$this->loadFixtures('Category');
$result = $this->db->getPrimaryKey('categories');
$this->assertEqual($result, 'id');
}
/**

View file

@ -1332,6 +1332,8 @@ class DboSourceTest extends CakeTestCase {
$this->testDb =& new DboTest($this->__config);
$this->testDb->cacheSources = false;
$this->testDb->startQuote = '`';
$this->testDb->endQuote = '`';
Configure::write('debug', 1);
$this->debug = Configure::read('debug');
$this->Model =& new TestModel();
@ -1358,6 +1360,7 @@ class DboSourceTest extends CakeTestCase {
function testFieldDoubleEscaping() {
$config = array_merge($this->__config, array('driver' => 'test'));
$test =& ConnectionManager::create('quoteTest', $config);
$test->simulated = array();
$this->Model =& new Article2(array('alias' => 'Article', 'ds' => 'quoteTest'));
$this->Model->setDataSource('quoteTest');

View file

@ -1,5 +1,6 @@
<?php
/* SVN FILE: $Id: model.test.php 8225 2009-07-08 03:25:30Z mark_story $ */
/**
* ModelDeleteTest file
*
@ -26,6 +27,7 @@
*/
require_once dirname(__FILE__) . DS . 'model.test.php';
require_once dirname(__FILE__) . DS . 'model_delete.test.php';
/**
* ModelDeleteTest
*
@ -33,6 +35,7 @@ require_once dirname(__FILE__) . DS . 'model_delete.test.php';
* @subpackage cake.tests.cases.libs.model.operations
*/
class ModelDeleteTest extends BaseModelTest {
/**
* testDeleteHabtmReferenceWithConditions method
*
@ -123,6 +126,7 @@ class ModelDeleteTest extends BaseModelTest {
));
$this->assertFalse($result);
}
/**
* testDeleteArticleBLinks method
*
@ -151,6 +155,7 @@ class ModelDeleteTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
}
/**
* testDeleteDependentWithConditions method
*
@ -179,6 +184,7 @@ class ModelDeleteTest extends BaseModelTest {
$this->assertTrue(is_array($result));
$this->assertEqual($result, $expected);
}
/**
* testDel method
*
@ -228,7 +234,6 @@ class ModelDeleteTest extends BaseModelTest {
$this->assertEqual($result, $expected);
// make sure deleting a non-existent record doesn't break save()
// ticket #6293
$this->loadFixtures('Uuid');
@ -258,6 +263,7 @@ class ModelDeleteTest extends BaseModelTest {
'id' => 'B607DAB9-88A2-46CF-B57C-842CA9E3B3B3')));
$this->assertEqual($result, $expected);
}
/**
* testDeleteAll method
*
@ -399,6 +405,7 @@ class ModelDeleteTest extends BaseModelTest {
$result = $TestModel->deleteAll(array('Article.user_id' => 999));
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
}
/**
* testRecursiveDel method
*
@ -434,6 +441,7 @@ class ModelDeleteTest extends BaseModelTest {
$result = $TestModel->Comment->Attachment->find('count');
$this->assertEqual($result, 0);
}
/**
* testDependentExclusiveDelete method
*
@ -452,6 +460,7 @@ class ModelDeleteTest extends BaseModelTest {
$TestModel->delete(1);
$this->assertEqual($TestModel->Comment->find('count'), 2);
}
/**
* testDeleteLinks method
*
@ -499,6 +508,7 @@ class ModelDeleteTest extends BaseModelTest {
$result = $TestModel->deleteAll(array('Article.user_id' => 999));
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
}
/**
* testHabtmDeleteLinksWhenNoPrimaryKeyInJoinTable method
*

View file

@ -1,5 +1,6 @@
<?php
/* SVN FILE: $Id: model.test.php 8225 2009-07-08 03:25:30Z mark_story $ */
/**
* ModelDeleteTest file
*
@ -34,6 +35,7 @@ require_once dirname(__FILE__) . DS . 'model_integration.test.php';
* @subpackage cake.tests.cases.libs.model.operations
*/
class ModelIntegrationTest extends BaseModelTest {
/**
* testPkInHAbtmLinkModelArticleB
*
@ -45,6 +47,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel2 =& new ArticleB();
$this->assertEqual($TestModel2->ArticlesTag->primaryKey, 'article_id');
}
/**
* Tests that $cacheSources can only be disabled in the db using model settings, not enabled
*
@ -64,6 +67,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->setSource('join_as');
$this->assertFalse($this->db->cacheSources);
}
/**
* testPkInHabtmLinkModel method
*
@ -92,6 +96,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($TestModel4->JoinAsJoinB->primaryKey, 'id');
}
/**
* testDynamicBehaviorAttachment method
*
@ -128,6 +133,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($TestModel->Behaviors->attached(), array());
$this->assertFalse(isset($TestModel->Behaviors->Tree));
}
/**
* Tests cross database joins. Requires $test and $test2 to both be set in DATABASE_CONFIG
* NOTE: When testing on MySQL, you must set 'persistent' => false on *both* database connections,
@ -490,6 +496,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->_fixtures[$this->_fixtureClassMap[$class]]->drop($db2);
}
}
/**
* testDisplayField method
*
@ -506,6 +513,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($Person->displayField, 'name');
$this->assertEqual($Comment->displayField, 'id');
}
/**
* testSchema method
*
@ -528,6 +536,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($Post->getColumnTypes(), array_combine($columns, $types));
}
/**
* test deconstruct() with time fields.
*
@ -613,6 +622,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->set($data);
$this->assertEqual($TestModel->data, $data);
}
/**
* testDeconstructFields with datetime, timestamp, and date fields
*
@ -789,6 +799,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->set($data);
$this->assertEqual($TestModel->data, $data);
}
/**
* testTablePrefixSwitching method
*
@ -842,6 +853,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($db2->fullTableName($TestModel, false), 'apples');
$this->assertEqual($db1->fullTableName($TestModel, false), 'apples');
}
/**
* Tests validation parameter order in custom validation methods
*
@ -852,6 +864,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel =& new ValidationTest1();
$this->assertNull($TestModel->getAssociated('Foo'));
}
/**
* testLoadModelSecondIteration method
*
@ -868,6 +881,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertIsA($model->ModelC, 'ModelC');
$this->assertIsA($model->ModelC->ModelD, 'ModelD');
}
/**
* ensure that __exists is reset on create
*
@ -889,6 +903,7 @@ class ModelIntegrationTest extends BaseModelTest {
$result = $Article->read(null, 2);
$this->assertEqual($result['Article']['title'], 'Staying alive');
}
/**
* testPluginAssociations method
*
@ -1013,6 +1028,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
/**
* Tests getAssociated method
*
@ -1161,6 +1177,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($TestModel->Tag->name, 'Tag');
$this->assertEqual($TestFakeModel->Tag->name, 'Tag');
}
/**
* test Model::__construct
*
@ -1181,6 +1198,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($TestModel->actsAs, $expected);
$this->assertTrue(isset($TestModel->Behaviors->Containable));
}
/**
* test Model::__construct
*
@ -1198,6 +1216,7 @@ class ModelIntegrationTest extends BaseModelTest {
$NewVoid =& new TheVoid(null, false, 'other');
$this->assertEqual('other', $NewVoid->useDbConfig);
}
/**
* testColumnTypeFetching method
*
@ -1216,6 +1235,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($model->getColumnType('Tag.id'), 'integer');
$this->assertEqual($model->getColumnType('Article.id'), 'integer');
}
/**
* testHabtmUniqueKey method
*
@ -1226,6 +1246,7 @@ class ModelIntegrationTest extends BaseModelTest {
$model =& new Item();
$this->assertFalse($model->hasAndBelongsToMany['Portfolio']['unique']);
}
/**
* testIdentity method
*
@ -1248,6 +1269,7 @@ class ModelIntegrationTest extends BaseModelTest {
$expected = 'AnotherTest';
$this->assertEqual($result, $expected);
}
/**
* testWithAssociation method
*
@ -1499,6 +1521,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
/**
* testFindSelfAssociations method
*
@ -1608,6 +1631,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
/**
* testDynamicAssociations method
*
@ -1715,6 +1739,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
/**
* testCreation method
*

View file

@ -1,5 +1,6 @@
<?php
/* SVN FILE: $Id: model.test.php 8225 2009-07-08 03:25:30Z mark_story $ */
/**
* ModelReadTest file
*
@ -26,6 +27,7 @@
*/
require_once dirname(__FILE__) . DS . 'model.test.php';
require_once dirname(__FILE__) . DS . 'model_read.test.php';
/**
* ModelReadTest
*
@ -33,6 +35,7 @@ require_once dirname(__FILE__) . DS . 'model_read.test.php';
* @subpackage cake.tests.cases.libs.model.operations
*/
class ModelReadTest extends BaseModelTest {
/**
* testFetchingNonUniqueFKJoinTableRecords()
*
@ -70,6 +73,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result['SomethingElse'][0]['JoinThing']['doomed'], 1);
$this->assertEqual($result['SomethingElse'][1]['JoinThing']['doomed'], 0);
}
/**
* testGroupBy method
*
@ -196,28 +200,24 @@ class ModelReadTest extends BaseModelTest {
));
$this->assertEqual($result, $expected);
$result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1),
'group' => array('project_id')
));
$this->assertEqual($result, $expected);
$result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1),
'group' => array('project_id', 'Project.id')
));
$this->assertEqual($result, $expected);
$result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1),
'group' => array('Thread.project_id', 'Project.id')
));
$this->assertEqual($result, $expected);
$expected = array(
array('Product' => array('type' => 'Clothing'), array('price' => 32)),
array('Product' => array('type' => 'Food'), array('price' => 9)),
@ -237,6 +237,7 @@ class ModelReadTest extends BaseModelTest {
'order' => 'Product.type ASC'));
$this->assertEqual($result, $expected);
}
/**
* testOldQuery method
*
@ -272,6 +273,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertTrue(isset($this->db->_queryCache[$query]));
$this->assertTrue(is_array($results));
}
/**
* testPreparedQuery method
*
@ -353,6 +355,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertTrue(isset($this->db->_queryCache[$expected]));
}
/**
* testParameterMismatch method
*
@ -374,6 +377,7 @@ class ModelReadTest extends BaseModelTest {
ob_end_clean();
$this->assertEqual($result, null);
}
/**
* testVeryStrangeUseCase method
*
@ -403,6 +407,7 @@ class ModelReadTest extends BaseModelTest {
$result = $Article->query($query, $param);
ob_end_clean();
}
/**
* testRecursiveUnbind method
*
@ -2997,6 +3002,7 @@ class ModelReadTest extends BaseModelTest {
)));
$this->assertEqual($result, $expected);
}
/**
* testSelfAssociationAfterFind method
*
@ -3024,6 +3030,7 @@ class ModelReadTest extends BaseModelTest {
}
$this->assertEqual($afterFindData, $noAfterFindData);
}
/**
* testFindAllThreaded method
*
@ -3500,6 +3507,7 @@ class ModelReadTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
}
/**
* test find('neighbors')
*
@ -3933,6 +3941,7 @@ class ModelReadTest extends BaseModelTest {
));
$this->assertEqual($result, $expected);
}
/**
* testSaveEmpty method
*
@ -4045,7 +4054,6 @@ class ModelReadTest extends BaseModelTest {
$result = $TestModel->find('all', compact('conditions', 'recursive', 'order'));
$this->assertEqual($result, $expected);
$conditions = array('id' => array('1', 2, '3.0'));
$order = 'Article.id ASC';
$result = $TestModel->find('all', compact('recursive', 'conditions', 'order'));
@ -4086,6 +4094,7 @@ class ModelReadTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
}
/**
* testBindUnbind method
*
@ -4545,6 +4554,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($TestModel2->hasMany['NewFeatureSet'], $expected);
$this->assertTrue(is_object($TestModel2->NewFeatureSet));
}
/**
* testBindMultipleTimes method
*
@ -4825,6 +4835,7 @@ class ModelReadTest extends BaseModelTest {
);
$this->assertEqual($result[0]['Post'][0]['Comment'][0], $expected);
}
/**
* Tests that callbacks can be properly disabled
*
@ -4851,6 +4862,7 @@ class ModelReadTest extends BaseModelTest {
$expected = array('mariano', 'nate', 'larry', 'garrett');
$this->assertEqual($result, $expected);
}
/**
* testMultipleBelongsToWithSameClass method
*
@ -4949,6 +4961,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
/**
* testHabtmRecursiveBelongsTo method
*
@ -5007,6 +5020,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
/**
* testHabtmFinderQuery method
*
@ -5055,6 +5069,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result['Tag'], $expected);
}
/**
* testHabtmLimitOptimization method
*
@ -5125,6 +5140,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
/**
* testHasManyLimitOptimization method
*
@ -5239,6 +5255,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
/**
* testFindAllRecursiveSelfJoin method
*
@ -5344,10 +5361,8 @@ class ModelReadTest extends BaseModelTest {
)))));
$this->assertEqual($result, $expected);
}
/**
* testFindAllRecursiveWithHabtm method
*
@ -5416,6 +5431,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertIdentical($result, $expected);
}
/**
* testReadFakeThread method
*
@ -5480,6 +5496,7 @@ class ModelReadTest extends BaseModelTest {
$this->db->fullDebug = $fullDebug;
$this->assertEqual($result, $expected);
}
/**
* testFindFakeThread method
*
@ -5544,6 +5561,7 @@ class ModelReadTest extends BaseModelTest {
$this->db->fullDebug = $fullDebug;
$this->assertEqual($result, $expected);
}
/**
* testFindAllFakeThread method
*
@ -5764,6 +5782,7 @@ class ModelReadTest extends BaseModelTest {
$this->db->fullDebug = $fullDebug;
$this->assertEqual($result, $expected);
}
/**
* testConditionalNumerics method
*
@ -6011,6 +6030,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
}
/**
* test find('list') method
*
@ -6274,6 +6294,7 @@ class ModelReadTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
}
/**
* testFindField method
*
@ -6303,6 +6324,7 @@ class ModelReadTest extends BaseModelTest {
$result = $TestModel->field('COUNT(*)', true);
$this->assertEqual($result, 4);
}
/**
* testFindUnique method
*
@ -6325,6 +6347,7 @@ class ModelReadTest extends BaseModelTest {
'password' => '5f4dcc3b5aa765d61d8327deb882cf99'
)));
}
/**
* test find('count') method
*
@ -6371,6 +6394,7 @@ class ModelReadTest extends BaseModelTest {
$result = $TestModel->find('count', array('fields' => 'DISTINCT name'));
$this->assertEqual($result, 4);
}
/**
* Test find(count) with Db::expression
*
@ -6395,6 +6419,7 @@ class ModelReadTest extends BaseModelTest {
)));
$this->assertEqual($result, 1);
}
/**
* testFindMagic method
*
@ -6426,6 +6451,7 @@ class ModelReadTest extends BaseModelTest {
));
$this->assertEqual($result, $expected);
}
/**
* testRead method
*
@ -6506,6 +6532,7 @@ class ModelReadTest extends BaseModelTest {
)));
$this->assertEqual($result, $expected);
}
/**
* testRecursiveRead method
*
@ -6932,6 +6959,7 @@ class ModelReadTest extends BaseModelTest {
)));
$this->assertEqual($result, $expected);
}
/**
* testRecursiveFindAllWithLimit method
*

View file

@ -1,5 +1,6 @@
<?php
/* SVN FILE: $Id: model.test.php 8225 2009-07-08 03:25:30Z mark_story $ */
/**
* ModelValidationTest file
*
@ -26,6 +27,7 @@
*/
require_once dirname(__FILE__) . DS . 'model.test.php';
require_once dirname(__FILE__) . DS . 'model_validation.test.php';
/**
* ModelValidationTest
*
@ -33,6 +35,7 @@ require_once dirname(__FILE__) . DS . 'model_validation.test.php';
* @subpackage cake.tests.cases.libs.model.operations
*/
class ModelValidationTest extends BaseModelTest {
/**
* Tests validation parameter order in custom validation methods
*
@ -74,6 +77,7 @@ class ModelValidationTest extends BaseModelTest {
$this->assertEqual($TestModel->invalidFields(), $expected);
}
/**
* Tests validation parameter fieldList in invalidFields
*

View file

@ -1,5 +1,6 @@
<?php
/* SVN FILE: $Id: model.test.php 8225 2009-07-08 03:25:30Z mark_story $ */
/**
* ModelWriteTest file
*
@ -26,6 +27,7 @@
*/
require_once dirname(__FILE__) . DS . 'model.test.php';
require_once dirname(__FILE__) . DS . 'model_write.test.php';
/**
* ModelWriteTest
*
@ -33,6 +35,7 @@ require_once dirname(__FILE__) . DS . 'model_write.test.php';
* @subpackage cake.tests.cases.libs.model.operations
*/
class ModelWriteTest extends BaseModelTest {
/**
* testInsertAnotherHabtmRecordWithSameForeignKey method
*
@ -87,6 +90,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->JoinAsJoinB->findById(1);
$this->assertEqual($result['JoinAsJoinB']['other'], $updatedValue);
}
/**
* testSaveDateAsFirstEntry method
*
@ -117,6 +121,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($testResult['Article']['created'], '2008-01-01 00:00:00');
}
/**
* testUnderscoreFieldSave method
*
@ -142,6 +147,7 @@ class ModelWriteTest extends BaseModelTest {
$currentCount = $UnderscoreField->find('count');
$this->assertEqual($currentCount, 4);
}
/**
* testAutoSaveUuid method
*
@ -149,12 +155,8 @@ class ModelWriteTest extends BaseModelTest {
* @return void
*/
function testAutoSaveUuid() {
// SQLite does not support non-integer primary keys, and SQL Server
// is still having problems with custom PK's
$this->skipIf(
$this->db->config['driver'] == 'sqlite'
|| $this->db->config['driver'] == 'mssql'
);
// SQLite does not support non-integer primary keys
$this->skipIf($this->db->config['driver'] == 'sqlite');
$this->loadFixtures('Uuid');
$TestModel =& new Uuid();
@ -167,6 +169,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual(strlen($result['Uuid']['id']), 36);
}
/**
* testZeroDefaultFieldValue method
*
@ -187,6 +190,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertIdentical($result['DataTest']['count'], '0');
$this->assertIdentical($result['DataTest']['float'], '0');
}
/**
* testNonNumericHabtmJoinKey method
*
@ -285,6 +289,7 @@ class ModelWriteTest extends BaseModelTest {
));
$this->assertEqual($result, $expected);
}
/**
* Tests validation parameter order in custom validation methods
*
@ -305,6 +310,7 @@ class ModelWriteTest extends BaseModelTest {
));
$this->assertEqual($TestModel->data, $expected);
}
/**
* test that Caches are getting cleared on save().
* ensure that both inflections of controller names are getting cleared
@ -342,6 +348,7 @@ class ModelWriteTest extends BaseModelTest {
Configure::write('Cache.check', $_back['check']);
Configure::write('Cache.disable', $_back['disable']);
}
/**
* testSaveWithCounterCache method
*
@ -378,6 +385,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->findById(2);
$this->assertIdentical($result['Syfile']['item_count'], '0');
}
/**
* Tests that counter caches are updated when records are added
*
@ -403,6 +411,7 @@ class ModelWriteTest extends BaseModelTest {
$expected = 3;
$this->assertEqual($result, $expected);
}
/**
* Tests that counter caches are updated when records are deleted
*
@ -424,6 +433,7 @@ class ModelWriteTest extends BaseModelTest {
$expected = 1;
$this->assertEqual($result, $expected);
}
/**
* Tests that counter caches are updated when foreign keys of counted records change
*
@ -446,6 +456,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($users[0]['User']['post_count'], 1);
$this->assertEqual($users[1]['User']['post_count'], 2);
}
/**
* Test counter cache with models that use a non-standard (i.e. not using 'id')
* as their primary key.
@ -453,14 +464,14 @@ class ModelWriteTest extends BaseModelTest {
* @access public
* @return void
*/
function testCounterCacheWithNonstandardPrimaryKey() {
$this->loadFixtures(
function testCounterCacheWithNonstandardPrimaryKey() {
$this->loadFixtures(
'CounterCacheUserNonstandardPrimaryKey',
'CounterCachePostNonstandardPrimaryKey'
);
$User = new CounterCacheUserNonstandardPrimaryKey();
$Post = new CounterCachePostNonstandardPrimaryKey();
$User = new CounterCacheUserNonstandardPrimaryKey();
$Post = new CounterCachePostNonstandardPrimaryKey();
$data = $Post->find('first', array(
'conditions' => array('pid' => 1),
@ -472,7 +483,7 @@ class ModelWriteTest extends BaseModelTest {
$users = $User->find('all',array('order' => 'User.uid'));
$this->assertEqual($users[0]['User']['post_count'], 1);
$this->assertEqual($users[1]['User']['post_count'], 2);
}
}
/**
* test Counter Cache With Self Joining table
@ -502,6 +513,7 @@ class ModelWriteTest extends BaseModelTest {
$expected = array_fill(0, 1, 1);
$this->assertEqual($result, $expected);
}
/**
* testSaveWithCounterCacheScope method
*
@ -541,6 +553,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->findById(1);
$this->assertIdentical($result['Syfile']['item_count'], '1');
}
/**
* testValidatesBackwards method
*
@ -606,6 +619,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->validates();
$this->assertTrue($result);
}
/**
* testValidates method
*
@ -958,6 +972,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
}
/**
* testSaveField method
*
@ -1026,6 +1041,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $Node->read();
$this->assertEqual(Set::extract('/ParentNode/name', $result), array('Second'));
}
/**
* testSaveWithCreate method
*
@ -1247,6 +1263,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
/**
* testSaveWithSet method
*
@ -1374,6 +1391,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
}
/**
* testSaveWithNonExistentFields method
*
@ -1425,6 +1443,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 5);
$this->assertEqual($result, $expected);
}
/**
* testSaveFromXml method
*
@ -1442,6 +1461,7 @@ class ModelWriteTest extends BaseModelTest {
$results = $Article->find(array('Article.title' => 'test xml'));
$this->assertTrue($results);
}
/**
* testSaveHabtm method
*
@ -1913,6 +1933,7 @@ class ModelWriteTest extends BaseModelTest {
$expected = array('new record', 'new record');
$this->assertEqual(Set::extract('/JoinC/JoinAsJoinC/other', $result), $expected);
}
/**
* testSaveHabtmCustomKeys method
*
@ -1963,6 +1984,7 @@ class ModelWriteTest extends BaseModelTest {
));
$this->assertEqual($result, $expected);
}
/**
* testHabtmSaveKeyResolution method
*
@ -2052,6 +2074,7 @@ class ModelWriteTest extends BaseModelTest {
));
$this->assertEqual($result['Monkey'], $expected);
}
/**
* testCreationOfEmptyRecord method
*
@ -2071,6 +2094,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertTrue(isset($result['Author']['updated']));
$this->assertEqual($TestModel->find('count'), 1);
}
/**
* testCreateWithPKFiltering method
*
@ -2167,6 +2191,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($result, $expected);
$this->assertFalse($TestModel->id);
}
/**
* testCreationWithMultipleData method
*
@ -2338,6 +2363,7 @@ class ModelWriteTest extends BaseModelTest {
))));
}
/**
* testCreationWithMultipleDataSameModel method
*
@ -2396,6 +2422,7 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'Brand New Article'
))));
}
/**
* testCreationWithMultipleDataSameModelManualInstances method
*
@ -2434,6 +2461,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $Primary->find('count');
$this->assertEqual($result, 2);
}
/**
* testRecordExists method
*
@ -2457,6 +2485,7 @@ class ModelWriteTest extends BaseModelTest {
$TestModel->id = 5;
$this->assertFalse($TestModel->exists());
}
/**
* testUpdateExisting method
*
@ -2504,6 +2533,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $Comment->save($data);
$this->assertTrue($result);
}
/**
* testUpdateMultiple method
*
@ -2537,6 +2567,7 @@ class ModelWriteTest extends BaseModelTest {
$expected = array_fill(0, 2, 'Updated today');
$this->assertEqual($result, $expected);
}
/**
* testHabtmUuidWithUuidId method
*
@ -2556,6 +2587,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual(1, count($result['Uuiditem']));
$this->assertEqual(strlen($result['Uuiditem'][0]['UuiditemsUuidportfolio']['id']), 36);
}
/**
* test HABTM saving when join table has no primary key and only 2 columns.
*
@ -2579,6 +2611,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertTrue($Fruit->save($data));
}
/**
* test HABTM saving when join table has no primary key and only 2 columns, no with model is used.
*
@ -2621,6 +2654,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->read(null, $id);
$this->assertEqual(1, count($result['Uuidportfolio']));
}
/**
* testSaveMultipleHabtm method
*
@ -2739,6 +2773,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
/**
* testSaveAll method
*
@ -2878,6 +2913,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual($result[6]['Attachment'], $expected);
}
/**
* Test SaveAll with Habtm relations
*
@ -2909,6 +2945,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual(count($result['Comment']), 1);
$this->assertEqual(count($result['Comment'][0]['comment']['Article comment']), 1);
}
/**
* Test SaveAll with Habtm relations and extra join table fields
*
@ -2952,6 +2989,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertTrue(Set::matches('/SomethingElse[id=3]/JoinThing[something_else_id=3]', $result));
$this->assertTrue(Set::matches('/SomethingElse[id=3]/JoinThing[doomed=1]', $result));
}
/**
* testSaveAllHasOne method
*
@ -2991,6 +3029,7 @@ class ModelWriteTest extends BaseModelTest {
)));
$this->assertEqual($result, $expected);
}
/**
* testSaveAllBelongsTo method
*
@ -3030,6 +3069,7 @@ class ModelWriteTest extends BaseModelTest {
)));
$this->assertEqual($result, $expected);
}
/**
* testSaveAllHasOneValidation method
*
@ -3076,6 +3116,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($model->validationErrors, $expected['Comment']);
$this->assertEqual($model->Attachment->validationErrors, $expected['Attachment']);
}
/**
* testSaveAllAtomic method
*
@ -3149,6 +3190,7 @@ class ModelWriteTest extends BaseModelTest {
), array('atomic' => false));
$this->assertIdentical($result, array('Article' => true, 'Comment' => array(true, true)));
}
/**
* testSaveAllHasMany method
*
@ -3225,6 +3267,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual(Set::extract($result['Comment'], '{n}.comment'), $expected);
}
/**
* testSaveAllHasManyValidation method
*
@ -3265,6 +3308,7 @@ class ModelWriteTest extends BaseModelTest {
))
), array('validate' => 'only'));
}
/**
* testSaveAllTransaction method
*
@ -3654,6 +3698,7 @@ class ModelWriteTest extends BaseModelTest {
$TestModel->validate['body'] = 'notEmpty';
}
/**
* testSaveAllValidationOnly method
*
@ -3706,6 +3751,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual($TestModel->validationErrors, $expected);
}
/**
* testSaveAllValidateFirst method
*
@ -3784,6 +3830,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual($result[0]['Comment'][0]['comment'], 'Only new comment');
}
/**
* testUpdateWithCalculation method
*
@ -3812,6 +3859,7 @@ class ModelWriteTest extends BaseModelTest {
$result = Set::extract('/DataTest/count', $model->find('all', array('fields' => 'count')));
$this->assertEqual($result, array(6, 4, 5, 2));
}
/**
* testSaveAllHasManyValidationOnly method
*

View file

@ -1777,7 +1777,6 @@ class SetTest extends CakeTestCase {
$result = Set::reverse($class);
$this->assertIdentical($result, $expected);
uses('model'.DS.'model');
$model = new Model(array('id' => false, 'name' => 'Model', 'table' => false));
$expected = array(
'Behaviors' => array('modelName' => 'Model', '_attached' => array(), '_disabled' => array(), '__methods' => array(), '__mappedMethods' => array(), '_log' => null),

View file

@ -1,6 +1,5 @@
<?php
/* SVN FILE: $Id$ */
/**
* AjaxHelperTest file
*
@ -28,17 +27,7 @@
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
uses(
'view' . DS . 'helpers' . DS . 'app_helper',
'controller' . DS . 'controller',
'model' . DS . 'model',
'view' . DS . 'helper',
'view' . DS . 'helpers'.DS.'ajax',
'view' . DS . 'helpers' . DS . 'html',
'view' . DS . 'helpers' . DS . 'form',
'view' . DS . 'helpers' . DS . 'javascript'
);
App::import('Helper', array('Html', 'Form', 'Javascript', 'Ajax'));
/**
* AjaxTestController class
*
@ -46,7 +35,6 @@ uses(
* @subpackage cake.tests.cases.libs.view.helpers
*/
class AjaxTestController extends Controller {
/**
* name property
*
@ -54,7 +42,6 @@ class AjaxTestController extends Controller {
* @access public
*/
var $name = 'AjaxTest';
/**
* uses property
*
@ -63,7 +50,6 @@ class AjaxTestController extends Controller {
*/
var $uses = null;
}
/**
* PostAjaxTest class
*
@ -71,7 +57,6 @@ class AjaxTestController extends Controller {
* @subpackage cake.tests.cases.libs.view.helpers
*/
class PostAjaxTest extends Model {
/**
* primaryKey property
*
@ -79,7 +64,6 @@ class PostAjaxTest extends Model {
* @access public
*/
var $primaryKey = 'id';
/**
* useTable property
*
@ -87,7 +71,6 @@ class PostAjaxTest extends Model {
* @access public
*/
var $useTable = false;
/**
* schema method
*
@ -103,7 +86,6 @@ class PostAjaxTest extends Model {
);
}
}
/**
* TestAjaxHelper class
*
@ -111,7 +93,6 @@ class PostAjaxTest extends Model {
* @subpackage cake.tests.cases.libs.view.helpers
*/
class TestAjaxHelper extends AjaxHelper {
/**
* stop method
*
@ -121,7 +102,6 @@ class TestAjaxHelper extends AjaxHelper {
function _stop() {
}
}
/**
* TestJavascriptHelper class
*
@ -129,7 +109,6 @@ class TestAjaxHelper extends AjaxHelper {
* @subpackage cake.tests.cases.libs.view.helpers
*/
class TestJavascriptHelper extends JavascriptHelper {
/**
* codeBlocks property
*
@ -137,7 +116,6 @@ class TestJavascriptHelper extends JavascriptHelper {
* @access public
*/
var $codeBlocks;
/**
* codeBlock method
*
@ -152,7 +130,6 @@ class TestJavascriptHelper extends JavascriptHelper {
$this->codeBlocks[] = $parameter;
}
}
/**
* AjaxTest class
*
@ -160,21 +137,18 @@ class TestJavascriptHelper extends JavascriptHelper {
* @subpackage cake.tests.cases.libs.view.helpers
*/
class AjaxHelperTest extends CakeTestCase {
/**
* Regexp for CDATA start block
*
* @var string
*/
var $cDataStart = 'preg:/^\/\/<!\[CDATA\[[\n\r]*/';
/**
* Regexp for CDATA end block
*
* @var string
*/
var $cDataEnd = 'preg:/[^\]]*\]\]\>[\s\r\n]*/';
/**
* setUp method
*
@ -192,7 +166,6 @@ class AjaxHelperTest extends CakeTestCase {
ClassRegistry::addObject('view', $view);
ClassRegistry::addObject('PostAjaxTest', new PostAjaxTest());
}
/**
* tearDown method
*
@ -203,7 +176,6 @@ class AjaxHelperTest extends CakeTestCase {
unset($this->Ajax);
ClassRegistry::flush();
}
/**
* testEvalScripts method
*
@ -237,7 +209,6 @@ class AjaxHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
}
/**
* testAutoComplete method
*
@ -284,7 +255,6 @@ class AjaxHelperTest extends CakeTestCase {
$this->assertPattern('/{parameters:\'key=value&key2=value2\'}/', $result);
}
/**
* testAsynchronous method
*
@ -305,7 +275,6 @@ class AjaxHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
}
/**
* testDraggable method
*
@ -327,7 +296,6 @@ class AjaxHelperTest extends CakeTestCase {
$this->assertPattern('/onDrag:doDrag/', $result);
$this->assertPattern('/onEnd:doEnd/', $result);
}
/**
* testDroppable method
*
@ -375,7 +343,6 @@ class AjaxHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
}
/**
* testForm method
*
@ -390,7 +357,6 @@ class AjaxHelperTest extends CakeTestCase {
$this->assertPattern('/id="MyFormID"/', $result);
$this->assertPattern('/name="SomeFormName"/', $result);
}
/**
* testSortable method
*
@ -464,7 +430,6 @@ class AjaxHelperTest extends CakeTestCase {
$expected = "Sortable.create('div', {scroll:$('someElement')});";
$this->assertEqual($result, $expected);
}
/**
* testSubmitWithIndicator method
*
@ -476,7 +441,6 @@ class AjaxHelperTest extends CakeTestCase {
$this->assertPattern('/onLoading:function\(request\) {doSomething\(\);\s+Element.show\(\'loading\'\);}/', $result);
$this->assertPattern('/onComplete:function\(request, json\) {doSomethingElse\(\) ;\s+Element.hide\(\'loading\'\);}/', $result);
}
/**
* testLink method
*
@ -586,7 +550,6 @@ class AjaxHelperTest extends CakeTestCase {
$this->assertNoPattern('/^<a[^<>]+complete="test"[^<>]*>Ajax Link<\/a>/', $result);
$this->assertNoPattern('/^<a\s+[^<>]*url="[^"]*"[^<>]*>/', $result);
}
/**
* testRemoteTimer method
*
@ -642,7 +605,6 @@ class AjaxHelperTest extends CakeTestCase {
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*new PeriodicalExecuter\(function\(\) {.+}, 10\)\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
$this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, postBody:\'var1=value1\'})')) . '/', $result);
}
/**
* testObserveField method
*
@ -674,7 +636,6 @@ class AjaxHelperTest extends CakeTestCase {
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*new Form.Element.EventObserver\(\'field\', function\(element, value\) {.+}\)\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
$this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Updater(\'divId\',\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, parameters:Form.Element.serialize(\'otherField\'), requestHeaders:[\'X-Update\', \'divId\']})')) . '/', $result);
}
/**
* testObserveForm method
*
@ -722,7 +683,6 @@ class AjaxHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
}
/**
* testSlider method
*
@ -800,7 +760,6 @@ class AjaxHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
}
/**
* testRemoteFunction method
*
@ -824,7 +783,6 @@ class AjaxHelperTest extends CakeTestCase {
$expected = "if (confirm('Are you sure?')) { new Ajax.Updater('myDiv','/', {asynchronous:true, evalScripts:true, requestHeaders:['X-Update', 'myDiv']}); } else { event.returnValue = false; return false; }";
$this->assertEqual($result, $expected);
}
/**
* testDiv method
*
@ -857,7 +815,6 @@ class AjaxHelperTest extends CakeTestCase {
$_SERVER['HTTP_X_UPDATE'] = $oldXUpdate;
}
/**
* testAfterRender method
*
@ -885,7 +842,6 @@ class AjaxHelperTest extends CakeTestCase {
$_SERVER['HTTP_X_UPDATE'] = $oldXUpdate;
}
/**
* testEditor method
*

View file

@ -1,6 +1,5 @@
<?php
/* SVN FILE: $Id$ */
/**
* JsHelperTest file
*
@ -28,14 +27,6 @@
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
uses(
'view' . DS . 'helpers' . DS . 'app_helper',
'controller' . DS . 'controller',
'model' . DS . 'model',
'view' . DS . 'helper',
'view' . DS . 'helpers' . DS . 'js'
);
/**
* JsHelperTest class
*
@ -43,7 +34,6 @@ uses(
* @subpackage cake.tests.cases.libs.view.helpers
*/
class JsHelperTest extends UnitTestCase {
/**
* skip method
*
@ -53,7 +43,6 @@ class JsHelperTest extends UnitTestCase {
function skip() {
$this->skipIf(true, '%s JsHelper test not implemented');
}
/**
* setUp method
*
@ -63,7 +52,6 @@ class JsHelperTest extends UnitTestCase {
function setUp() {
$this->Js = new JsHelper();
}
/**
* tearDown method
*

View file

@ -215,7 +215,7 @@ class XmlHelperTest extends CakeTestCase {
$result = $this->Xml->serialize($data, array('format' => 'tags'));
$expected = '<service_day><service_time><service_time_price><dollar>1</dollar><cents>2</cents></service_time_price></service_time></service_day>';
$this->assertIdentical($result, $expected);
$data = array(
'Pages' => array('id' => 2, 'url' => 'http://www.url.com/rb/153/?id=bbbb&t=access')
);
@ -224,6 +224,42 @@ class XmlHelperTest extends CakeTestCase {
$this->assertIdentical($result, $expected);
}
/**
* testSerializeOnMultiDimensionalArray method
*
* @access public
* @return void
*/
function testSerializeOnMultiDimensionalArray() {
$data = array(
'Statuses' => array(
array('Status' => array('id' => 1)),
array('Status' => array('id' => 2))
)
);
$result = $this->Xml->serialize($data, array('format' => 'tags'));
$expected = '<statuses><status><id>1</id></status><status><id>2</id></status></statuses>';
$this->assertIdentical($result, $expected);
}
/**
* testSerializeOnMultiDimensionalArray method
*
* @access public
* @return void
*/
function testSerializeOnMultiDimensionalArray() {
$data = array(
'Statuses' => array(
array('Status' => array('id' => 1)),
array('Status' => array('id' => 2))
)
);
$result = $this->Xml->serialize($data, array('format' => 'tags'));
$expected = '<statuses><status><id>1</id></status><status><id>2</id></status></statuses>';
$this->assertIdentical($result, $expected);
}
/**
* testHeader method
*

View file

@ -103,6 +103,25 @@ class XmlTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
/**
* testSerializeOnMultiDimensionalArray method
*
* @access public
* @return void
*/
function testSerializeOnMultiDimensionalArray() {
$data = array(
'Statuses' => array(
array('Status' => array('id' => 1)),
array('Status' => array('id' => 2))
)
);
$result =& new Xml($data, array('format' => 'tags'));
$expected = '<statuses><status><id>1</id></status><status><id>2</id></status></statuses>';
$this->assertIdentical($result->toString(), $expected);
}
/**
* test serialization of boolean and null values. false = 0, true = 1, null = ''
*

View file

@ -50,7 +50,7 @@ class UuidTreeFixture extends CakeTestFixture {
var $fields = array(
'id' => array('type' => 'string', 'length' => 36, 'key' => 'primary'),
'name' => array('type' => 'string','null' => false),
'parent_id' => array('type' => 'string', 'length' => 36),
'parent_id' => array('type' => 'string', 'length' => 36, 'null' => true),
'lft' => array('type' => 'integer','null' => false),
'rght' => array('type' => 'integer','null' => false)
);

View file

@ -40,6 +40,7 @@ class CakeTestFixture extends Object {
* @var string
**/
var $name = null;
/**
* Cake's DBO driver (e.g: DboMysql).
*
@ -53,6 +54,7 @@ class CakeTestFixture extends Object {
* @access public
*/
var $table = null;
/**
* Instantiate the fixture.
*

View file

@ -35,5 +35,4 @@
<cake:nocache>
<?php echo $variable; ?>
</cake:nocache>
<p>Additional regular text.</p>
<p>Additional regular text.</p>

View file

@ -26,4 +26,4 @@
<?php echo $content_for_layout;?>
This email was sent using the CakePHP Framework, http://cakephp.org.
This email was sent using the CakePHP Framework, http://cakephp.org.

View file

@ -51,7 +51,9 @@ endif;
</p>
<?php
if (!empty($filePresent)):
uses('model' . DS . 'connection_manager');
if (!class_exists('ConnectionManager')) {
require LIBS . 'model' . DS . 'connection_manager.php';
}
$db = ConnectionManager::getInstance();
$connected = $db->getDataSource('default');
?>

View file

@ -82,7 +82,9 @@
</p>
<?php
if (!empty($filePresent)):
uses('model' . DS . 'connection_manager');
if (!class_exists('ConnectionManager')) {
require LIBS . 'model' . DS . 'connection_manager.php';
}
$db = ConnectionManager::getInstance();
$connected = $db->getDataSource('default');
?>