mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing coding standards violations in core, and adding misc tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7222 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
66ea6be098
commit
df75a06756
75 changed files with 1142 additions and 928 deletions
|
@ -627,7 +627,7 @@ if (!function_exists('clone')) {
|
|||
} else {
|
||||
return I18n::translate($msg, null, $domain);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Allows you to override the current domain for a single plural message lookup
|
||||
* Returns correct plural form of message identified by $singular and $plural for count $count
|
||||
|
@ -761,7 +761,7 @@ if (!function_exists('clone')) {
|
|||
} else {
|
||||
return I18n::translate($msg, null, null, $category);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Computes the difference of arrays using keys for comparison
|
||||
*
|
||||
|
|
|
@ -214,7 +214,7 @@ class ShellDispatcher {
|
|||
$includes = array(
|
||||
CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php',
|
||||
CORE_PATH . 'cake' . DS . 'libs' . DS . 'object.php',
|
||||
CORE_PATH . 'cake' . DS . 'libs' . DS . 'inflector.php',
|
||||
CORE_PATH . 'cake' . DS . 'libs' . DS . 'inflector.php',
|
||||
CORE_PATH . 'cake' . DS . 'libs' . DS . 'configure.php',
|
||||
CORE_PATH . 'cake' . DS . 'libs' . DS . 'file.php',
|
||||
CORE_PATH . 'cake' . DS . 'libs' . DS . 'cache.php',
|
||||
|
@ -455,7 +455,7 @@ class ShellDispatcher {
|
|||
} else {
|
||||
$params['root'] = $params['working'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($params['app'][0] == '/' || preg_match('/([a-z])(:)/i', $params['app'], $matches)) {
|
||||
$params['root'] = dirname($params['app']);
|
||||
|
|
|
@ -61,19 +61,19 @@ class SchemaShell extends Shell {
|
|||
function startup() {
|
||||
$name = null;
|
||||
if (!empty($this->params['name'])) {
|
||||
$name = $this->params['name'];
|
||||
$name = $this->params['name'];
|
||||
}
|
||||
$path = null;
|
||||
if (!empty($this->params['path'])) {
|
||||
$path = $this->params['path'];
|
||||
$path = $this->params['path'];
|
||||
}
|
||||
$file = null;
|
||||
if (!empty($this->params['file'])) {
|
||||
$file = $this->params['file'];
|
||||
$file = $this->params['file'];
|
||||
}
|
||||
$connection = null;
|
||||
if (!empty($this->params['connection'])) {
|
||||
$connection = $this->params['connection'];
|
||||
$connection = $this->params['connection'];
|
||||
}
|
||||
$this->Schema =& new CakeSchema(compact('name', 'path', 'file', 'connection'));
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ class SchemaShell extends Shell {
|
|||
}
|
||||
|
||||
$options = array('name' => $name, 'file' => $this->Schema->file);
|
||||
if (isset($this->params['s'])) {
|
||||
if (isset($this->params['s'])) {
|
||||
$options = array('file' => 'schema_'.$this->params['s'].'.php');
|
||||
}
|
||||
|
||||
|
|
|
@ -321,7 +321,7 @@ class Shell extends Object {
|
|||
}
|
||||
if (is_array($options)) {
|
||||
while ($in == '' || ($in && (!in_array(low($in), $options) && !in_array(up($in), $options)) && !in_array($in, $options))) {
|
||||
$in = $this->Dispatch->getInput($prompt, $options, $default);
|
||||
$in = $this->Dispatch->getInput($prompt, $options, $default);
|
||||
}
|
||||
}
|
||||
if ($in) {
|
||||
|
|
|
@ -199,7 +199,7 @@ class ExtractTask extends Shell{
|
|||
$response = '';
|
||||
$filename = '';
|
||||
while ($response == '') {
|
||||
$response = $this->in(__('Would you like to merge all translations into one file?', true), array('y','n'), 'y');
|
||||
$response = $this->in(__('Would you like to merge all translations into one file?', true), array('y','n'), 'y');
|
||||
if (strtolower($response) == 'n') {
|
||||
$this->__oneFile = false;
|
||||
} else {
|
||||
|
@ -220,7 +220,7 @@ class ExtractTask extends Shell{
|
|||
* @access public
|
||||
*/
|
||||
function help() {
|
||||
$this->out(__('CakePHP Language String Extraction:', true));
|
||||
$this->out(__('CakePHP Language String Extraction:', true));
|
||||
$this->hr();
|
||||
$this->out(__('The Extract script generates .pot file(s) with translations', true));
|
||||
$this->out(__('By default the .pot file(s) will be place in the locale directory of -app', true));
|
||||
|
|
|
@ -370,20 +370,21 @@ class ViewTask extends Shell {
|
|||
* @return array $associations
|
||||
* @access private
|
||||
*/
|
||||
function __associations($model) {
|
||||
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
||||
$associations = array();
|
||||
function __associations($model) {
|
||||
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
||||
$associations = array();
|
||||
|
||||
foreach ($keys as $key => $type){
|
||||
foreach ($model->{$type} as $assocKey => $assocData) {
|
||||
$associations[$type][$assocKey]['primaryKey'] = $model->{$assocKey}->primaryKey;
|
||||
$associations[$type][$assocKey]['displayField'] = $model->{$assocKey}->displayField;
|
||||
$associations[$type][$assocKey]['foreignKey'] = $assocData['foreignKey'];
|
||||
$associations[$type][$assocKey]['controller'] = Inflector::pluralize(Inflector::underscore($assocData['className']));
|
||||
$associations[$type][$assocKey]['fields'] = array_keys($model->{$assocKey}->schema());
|
||||
}
|
||||
}
|
||||
return $associations;
|
||||
}
|
||||
foreach ($keys as $key => $type){
|
||||
foreach ($model->{$type} as $assocKey => $assocData) {
|
||||
$associations[$type][$assocKey]['primaryKey'] = $model->{$assocKey}->primaryKey;
|
||||
$associations[$type][$assocKey]['displayField'] = $model->{$assocKey}->displayField;
|
||||
$associations[$type][$assocKey]['foreignKey'] = $assocData['foreignKey'];
|
||||
$associations[$type][$assocKey]['controller'] = Inflector::pluralize(Inflector::underscore($assocData['className']));
|
||||
$associations[$type][$assocKey]['fields'] = array_keys($model->{$assocKey}->schema());
|
||||
}
|
||||
}
|
||||
return $associations;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -192,7 +192,7 @@ class TestSuiteShell extends Shell {
|
|||
* @return bool true if it's a valid test file, false otherwise
|
||||
* @access private
|
||||
*/
|
||||
function __canRun(){
|
||||
function __canRun() {
|
||||
$isNeitherAppNorCore = !in_array($this->category, array('app', 'core'));
|
||||
$isPlugin = in_array(Inflector::underscore($this->category), $this->plugins);
|
||||
|
||||
|
|
|
@ -677,11 +677,11 @@ class Dispatcher extends Object {
|
|||
include ($assetFile);
|
||||
|
||||
if(Configure::read('Asset.compress')) {
|
||||
header("Content-length: " . ob_get_length());
|
||||
header("Content-length: " . ob_get_length());
|
||||
ob_end_flush();
|
||||
}
|
||||
$this->_stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
*
|
||||
*/
|
||||
if (!class_exists('File')) {
|
||||
uses('file');
|
||||
uses('file');
|
||||
}
|
||||
/**
|
||||
* Set up error level constants to be used within the framework if they are not defined within the
|
||||
|
|
|
@ -62,7 +62,7 @@ class ClassRegistry {
|
|||
if (!$instance) {
|
||||
$instance[0] =& new ClassRegistry();
|
||||
}
|
||||
return $instance[0];
|
||||
return $instance[0];
|
||||
}
|
||||
/**
|
||||
* Loads a class, registers the object in the registry and returns instance of the object.
|
||||
|
|
|
@ -1126,22 +1126,22 @@ class App extends Object {
|
|||
}
|
||||
return $paths;
|
||||
}
|
||||
$paths = Configure::read(strtolower($type) . 'Paths');
|
||||
$paths = Configure::read(strtolower($type) . 'Paths');
|
||||
|
||||
if (empty($paths)) {
|
||||
if (strtolower($type) === 'plugin') {
|
||||
$paths = array(APP . 'plugins' . DS);
|
||||
} elseif (strtolower($type) === 'vendor') {
|
||||
$paths = array(APP . 'vendors' . DS, VENDORS, APP . 'plugins' . DS);
|
||||
} elseif (strtolower($type) === 'controller') {
|
||||
$paths = array(APP . 'controllers' . DS, APP);
|
||||
} elseif (strtolower($type) === 'model') {
|
||||
$paths = array(APP . 'models' . DS, APP);
|
||||
} elseif (strtolower($type) === 'view') {
|
||||
$paths = array(APP . 'views' . DS);
|
||||
}
|
||||
}
|
||||
return $paths;
|
||||
if (empty($paths)) {
|
||||
if (strtolower($type) === 'plugin') {
|
||||
$paths = array(APP . 'plugins' . DS);
|
||||
} elseif (strtolower($type) === 'vendor') {
|
||||
$paths = array(APP . 'vendors' . DS, VENDORS, APP . 'plugins' . DS);
|
||||
} elseif (strtolower($type) === 'controller') {
|
||||
$paths = array(APP . 'controllers' . DS, APP);
|
||||
} elseif (strtolower($type) === 'model') {
|
||||
$paths = array(APP . 'models' . DS, APP);
|
||||
} elseif (strtolower($type) === 'view') {
|
||||
$paths = array(APP . 'views' . DS);
|
||||
}
|
||||
}
|
||||
return $paths;
|
||||
}
|
||||
/**
|
||||
* Removes file location from map if file has been deleted
|
||||
|
|
|
@ -131,7 +131,7 @@ class Component extends Object {
|
|||
return false;
|
||||
}
|
||||
$response[] = $resp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
@ -228,4 +228,5 @@ class Component extends Object {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -377,22 +377,22 @@ class CookieComponent extends Object {
|
|||
setcookie($this->name . $name, '', time() - 42000, $this->path, $this->domain, $this->secure);
|
||||
}
|
||||
/**
|
||||
* Encrypts $value using var $type method in Security class
|
||||
*
|
||||
* @param string $value Value to encrypt
|
||||
* @return string encrypted string
|
||||
* @access private
|
||||
*/
|
||||
function __encrypt($value) {
|
||||
if (is_array($value)) {
|
||||
$value = $this->__implode($value);
|
||||
}
|
||||
* Encrypts $value using var $type method in Security class
|
||||
*
|
||||
* @param string $value Value to encrypt
|
||||
* @return string encrypted string
|
||||
* @access private
|
||||
*/
|
||||
function __encrypt($value) {
|
||||
if (is_array($value)) {
|
||||
$value = $this->__implode($value);
|
||||
}
|
||||
|
||||
if ($this->__encrypted === true) {
|
||||
$type = $this->__type;
|
||||
$value = "Q2FrZQ==." .base64_encode(Security::$type($value, $this->key));
|
||||
}
|
||||
return($value);
|
||||
if ($this->__encrypted === true) {
|
||||
$type = $this->__type;
|
||||
$value = "Q2FrZQ==." .base64_encode(Security::$type($value, $this->key));
|
||||
}
|
||||
return($value);
|
||||
}
|
||||
/**
|
||||
* Decrypts $value using var $type method in Security class
|
||||
|
|
|
@ -294,7 +294,7 @@ class SessionComponent extends CakeSession {
|
|||
*
|
||||
* @access private
|
||||
*/
|
||||
function __start(){
|
||||
function __start() {
|
||||
if ($this->__started === false) {
|
||||
if (!$this->id() && parent::start()) {
|
||||
$this->__started = true;
|
||||
|
@ -306,4 +306,5 @@ class SessionComponent extends CakeSession {
|
|||
return $this->__started;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -632,7 +632,7 @@ class Controller extends Object {
|
|||
* @return bool true if authorized, false otherwise
|
||||
* @access public
|
||||
*/
|
||||
function isAuthorized() {
|
||||
function isAuthorized() {
|
||||
trigger_error(sprintf(__('%s::isAuthorized() is not defined.', true), $this->name), E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -238,10 +238,10 @@ class Scaffold extends Object {
|
|||
*/
|
||||
function __scaffoldIndex($params) {
|
||||
if ($this->controller->_beforeScaffold('index')) {
|
||||
$this->ScaffoldModel->recursive = 0;
|
||||
$this->controller->set(Inflector::variable($this->controller->name), $this->controller->paginate());
|
||||
$this->ScaffoldModel->recursive = 0;
|
||||
$this->controller->set(Inflector::variable($this->controller->name), $this->controller->paginate());
|
||||
$this->controller->render($this->action, $this->layout);
|
||||
$this->_output();
|
||||
$this->_output();
|
||||
} elseif ($this->controller->_scaffoldError('index') === false) {
|
||||
return $this->__scaffoldError();
|
||||
}
|
||||
|
@ -451,21 +451,22 @@ class Scaffold extends Object {
|
|||
* @return array Associations for model
|
||||
* @access private
|
||||
*/
|
||||
function __associations() {
|
||||
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
||||
$associations = array();
|
||||
function __associations() {
|
||||
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
||||
$associations = array();
|
||||
|
||||
foreach ($keys as $key => $type){
|
||||
foreach ($this->ScaffoldModel->{$type} as $assocKey => $assocData) {
|
||||
$associations[$type][$assocKey]['primaryKey'] = $this->ScaffoldModel->{$assocKey}->primaryKey;
|
||||
$associations[$type][$assocKey]['displayField'] = $this->ScaffoldModel->{$assocKey}->displayField;
|
||||
$associations[$type][$assocKey]['foreignKey'] = $assocData['foreignKey'];
|
||||
$associations[$type][$assocKey]['controller'] = Inflector::pluralize(Inflector::underscore($assocData['className']));
|
||||
}
|
||||
}
|
||||
return $associations;
|
||||
}
|
||||
foreach ($keys as $key => $type){
|
||||
foreach ($this->ScaffoldModel->{$type} as $assocKey => $assocData) {
|
||||
$associations[$type][$assocKey]['primaryKey'] = $this->ScaffoldModel->{$assocKey}->primaryKey;
|
||||
$associations[$type][$assocKey]['displayField'] = $this->ScaffoldModel->{$assocKey}->displayField;
|
||||
$associations[$type][$assocKey]['foreignKey'] = $assocData['foreignKey'];
|
||||
$associations[$type][$assocKey]['controller'] = Inflector::pluralize(Inflector::underscore($assocData['className']));
|
||||
}
|
||||
}
|
||||
return $associations;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scaffold View.
|
||||
*
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
*
|
||||
*/
|
||||
if (!class_exists('Object')) {
|
||||
uses('object');
|
||||
uses('object');
|
||||
}
|
||||
if (!class_exists('CakeLog')) {
|
||||
uses('cake_log');
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
*
|
||||
*/
|
||||
if (!class_exists('Object')) {
|
||||
uses ('object');
|
||||
uses ('object');
|
||||
}
|
||||
|
||||
if (!class_exists('Folder')) {
|
||||
uses('folder');
|
||||
uses('folder');
|
||||
}
|
||||
/**
|
||||
* Convenience class for reading, writing and appending to files.
|
||||
|
@ -278,7 +278,7 @@ class File extends Object {
|
|||
return unlink($this->pwd());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the File extension.
|
||||
*
|
||||
|
@ -441,7 +441,7 @@ class File extends Object {
|
|||
return fileowner($this->pwd());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the File group.
|
||||
*
|
||||
|
@ -453,7 +453,7 @@ class File extends Object {
|
|||
return filegroup($this->pwd());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns last access time.
|
||||
*
|
||||
|
@ -465,7 +465,7 @@ class File extends Object {
|
|||
return fileatime($this->pwd());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns last modified time.
|
||||
*
|
||||
|
|
|
@ -137,7 +137,7 @@ class Folder extends Object{
|
|||
return $this->path = $path;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns an array of the contents of the current directory, or false on failure.
|
||||
* The returned array holds two arrays: one of dirs and one of files.
|
||||
|
@ -302,7 +302,7 @@ class Folder extends Object{
|
|||
return $path;
|
||||
}
|
||||
return $path . Folder::correctSlashFor($path);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns $path with $element added, with correct slash in-between.
|
||||
*
|
||||
|
@ -326,7 +326,7 @@ class Folder extends Object{
|
|||
$newdir = $dir . $path;
|
||||
|
||||
return $this->inPath($newdir);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns true if the File is in given path.
|
||||
*
|
||||
|
@ -358,44 +358,44 @@ class Folder extends Object{
|
|||
* @return boolean Returns TRUE on success, FALSE on failure
|
||||
* @access public
|
||||
*/
|
||||
function chmod($path, $mode = false, $recursive = true, $exceptions = array()) {
|
||||
if (!$mode) {
|
||||
$mode = $this->mode;
|
||||
}
|
||||
function chmod($path, $mode = false, $recursive = true, $exceptions = array()) {
|
||||
if (!$mode) {
|
||||
$mode = $this->mode;
|
||||
}
|
||||
|
||||
if ($recursive === false && is_dir($path)) {
|
||||
if (chmod($path, intval($mode, 8))) {
|
||||
$this->__messages[] = sprintf(__('%s changed to %s', true), $path, $mode);
|
||||
return true;
|
||||
} else {
|
||||
$this->__errors[] = sprintf(__('%s NOT changed to %s', true), $path, $mode);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($recursive === false && is_dir($path)) {
|
||||
if (chmod($path, intval($mode, 8))) {
|
||||
$this->__messages[] = sprintf(__('%s changed to %s', true), $path, $mode);
|
||||
return true;
|
||||
} else {
|
||||
$this->__errors[] = sprintf(__('%s NOT changed to %s', true), $path, $mode);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_dir($path)) {
|
||||
list($paths) = $this->tree($path);
|
||||
if (is_dir($path)) {
|
||||
list($paths) = $this->tree($path);
|
||||
|
||||
foreach ($paths as $key => $fullpath) {
|
||||
$check = explode(DS, $fullpath);
|
||||
$count = count($check);
|
||||
foreach ($paths as $key => $fullpath) {
|
||||
$check = explode(DS, $fullpath);
|
||||
$count = count($check);
|
||||
|
||||
if (in_array($check[$count - 1], $exceptions)) {
|
||||
continue;
|
||||
}
|
||||
if (in_array($check[$count - 1], $exceptions)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (chmod($fullpath, intval($mode, 8))) {
|
||||
$this->__messages[] = sprintf(__('%s changed to %s', true), $fullpath, $mode);
|
||||
} else {
|
||||
$this->__errors[] = sprintf(__('%s NOT changed to %s', true), $fullpath, $mode);
|
||||
}
|
||||
}
|
||||
if (empty($this->__errors)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (chmod($fullpath, intval($mode, 8))) {
|
||||
$this->__messages[] = sprintf(__('%s changed to %s', true), $fullpath, $mode);
|
||||
} else {
|
||||
$this->__errors[] = sprintf(__('%s NOT changed to %s', true), $fullpath, $mode);
|
||||
}
|
||||
}
|
||||
if (empty($this->__errors)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Returns an array of nested directories and files in each directory
|
||||
*
|
||||
|
|
|
@ -95,8 +95,8 @@ class HttpSocket extends CakeSocket {
|
|||
'raw' => array(
|
||||
'status-line' => null,
|
||||
'header' => null,
|
||||
'body' => null,
|
||||
'response' => null
|
||||
'body' => null,
|
||||
'response' => null
|
||||
),
|
||||
'status' => array(
|
||||
'http-version' => null,
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
*
|
||||
*/
|
||||
if (!class_exists('Object')) {
|
||||
uses('object');
|
||||
uses('object');
|
||||
}
|
||||
if (!class_exists('Set')) {
|
||||
uses('set');
|
||||
uses('set');
|
||||
}
|
||||
/**
|
||||
* Pluralize and singularize English words.
|
||||
|
|
|
@ -265,18 +265,25 @@ class TreeBehavior extends ModelBehavior {
|
|||
$conditions = array($scope, $model->escapeField($parent) => $id);
|
||||
return $model->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive'));
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
$constraint = $scope;
|
||||
$conditions = $scope;
|
||||
} else {
|
||||
$result = array_values($model->find('first', array('conditions' => array($scope, $model->escapeField() => $id), 'fields' => array($left, $right), 'recursive' => $recursive)));
|
||||
if (!empty($result) && isset($result[0])) {
|
||||
$item = $result[0];
|
||||
} else {
|
||||
$result = array_values($model->find('first', array(
|
||||
'conditions' => array($scope, $model->escapeField() => $id),
|
||||
'fields' => array($left, $right),
|
||||
'recursive' => $recursive
|
||||
)));
|
||||
|
||||
if (empty($result) || !isset($result[0])) {
|
||||
return array();
|
||||
}
|
||||
$constraint = array($scope, $model->escapeField($right) . ' <' => $item[$right], $model->escapeField($left) . ' >' => $item[$left]);
|
||||
$conditions = array($scope,
|
||||
$model->escapeField($right) . ' <' => $result[0][$right],
|
||||
$model->escapeField($left) . ' >' => $result[0][$left]
|
||||
);
|
||||
}
|
||||
return $model->find('all', array('conditions' => $constraint, 'fields' => $fields, 'order' => $order, 'limit' => $limit, 'page' => $page, 'recursive' => $recursive));
|
||||
return $model->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive'));
|
||||
}
|
||||
/**
|
||||
* A convenience method for returning a hierarchical array used for HTML select boxes
|
||||
|
@ -450,6 +457,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
$this->__sync($model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right]);
|
||||
$this->__sync($model, $nextNode[$left] - $node[$left], '-', 'BETWEEN ' . $nextNode[$left] . ' AND ' . $nextNode[$right]);
|
||||
$this->__sync($model, $edge - $node[$left] - ($nextNode[$right] - $nextNode[$left]), '-', '> ' . $edge);
|
||||
|
||||
if (is_int($number)) {
|
||||
$number--;
|
||||
}
|
||||
|
@ -570,7 +578,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
$model->{$model->primaryKey} = $array[$model->alias][$model->primaryKey];
|
||||
$lft = $count++;
|
||||
$rght = $count++;
|
||||
$model->save(array($left => $lft,$right => $rght));
|
||||
$model->save(array($left => $lft, $right => $rght), array('callbacks' => false));
|
||||
}
|
||||
foreach ($model->find('all', array('conditions' => $scope, 'fields' => array($model->primaryKey, $parent), 'order' => $left)) as $array) {
|
||||
$model->create();
|
||||
|
@ -613,6 +621,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
$fields = array($model->primaryKey, $field, $left, $right);
|
||||
$sort = $field . ' ' . $order;
|
||||
$nodes = $model->children($id, true, $fields, $sort, null, null, $recursive);
|
||||
|
||||
if ($nodes) {
|
||||
foreach ($nodes as $node) {
|
||||
$id = $node[$model->alias][$model->primaryKey];
|
||||
|
@ -685,7 +694,10 @@ class TreeBehavior extends ModelBehavior {
|
|||
$edge = $edge - 2;
|
||||
}
|
||||
$model->id = $id;
|
||||
return $model->save(array($left => $edge + 1, $right => $edge + 2, $parent => null));
|
||||
return $model->save(
|
||||
array($left => $edge + 1, $right => $edge + 2, $parent => null),
|
||||
array('callbacks' => false)
|
||||
);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -697,13 +709,19 @@ class TreeBehavior extends ModelBehavior {
|
|||
* @param mixed $parentId The ID to set as the parent of the current node.
|
||||
* @return true on success
|
||||
* @access public
|
||||
* @deprecated
|
||||
*/
|
||||
function setparent(&$model, $parentId = null , $created = null) {
|
||||
trigger_error(
|
||||
__('(TreeBehavior::setParent) Deprecated - save the record with a parent ID instead', true),
|
||||
E_USER_ERROR
|
||||
);
|
||||
extract($this->settings[$model->alias]);
|
||||
|
||||
if ($created === false && $parentId == $model->field($parent)) {
|
||||
return true;
|
||||
}
|
||||
return $model->saveField($parent, $parentId);
|
||||
return $model->saveField($parent, $parentId, array('callbacks' => false));
|
||||
}
|
||||
/**
|
||||
* Check if the current tree is valid.
|
||||
|
@ -787,16 +805,22 @@ class TreeBehavior extends ModelBehavior {
|
|||
*/
|
||||
function _setParent(&$model, $parentId = null, $created = false) {
|
||||
extract($this->settings[$model->alias]);
|
||||
list($node) = array_values($model->find('first', array('conditions' => array($scope, $model->escapeField() => $model->id),
|
||||
'fields' => array($model->primaryKey, $parent, $left, $right), 'recursive' => $recursive)));
|
||||
list($node) = array_values($model->find('first', array(
|
||||
'conditions' => array($scope, $model->escapeField() => $model->id),
|
||||
'fields' => array($model->primaryKey, $parent, $left, $right),
|
||||
'recursive' => $recursive
|
||||
)));
|
||||
$edge = $this->__getMax($model, $scope, $right, $recursive, $created);
|
||||
|
||||
if (empty ($parentId)) {
|
||||
$this->__sync($model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created);
|
||||
$this->__sync($model, $node[$right] - $node[$left] + 1, '-', '> ' . $node[$left], $created);
|
||||
} else {
|
||||
$parentNode = array_values($model->find('first', array('conditions' => array($scope, $model->escapeField() => $parentId),
|
||||
'fields' => array($model->primaryKey, $left, $right), 'recursive' => $recursive)));
|
||||
$parentNode = array_values($model->find('first', array(
|
||||
'conditions' => array($scope, $model->escapeField() => $parentId),
|
||||
'fields' => array($model->primaryKey, $left, $right),
|
||||
'recursive' => $recursive
|
||||
)));
|
||||
|
||||
if (empty($parentNode) || empty($parentNode[0])) {
|
||||
return false;
|
||||
|
@ -811,7 +835,10 @@ class TreeBehavior extends ModelBehavior {
|
|||
}
|
||||
if (empty ($node[$left]) && empty ($node[$right])) {
|
||||
$this->__sync($model, 2, '+', '>= ' . $parentNode[$right], $created);
|
||||
$model->save(array($left => $parentNode[$right], $right => $parentNode[$right] + 1, $parent => $parentId), false);
|
||||
$model->save(
|
||||
array($left => $parentNode[$right], $right => $parentNode[$right] + 1, $parent => $parentId),
|
||||
array('validate' => false, 'callbacks' => false)
|
||||
);
|
||||
} else {
|
||||
$this->__sync($model, $edge - $node[$left] +1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created);
|
||||
$diff = $node[$right] - $node[$left] + 1;
|
||||
|
@ -870,12 +897,12 @@ class TreeBehavior extends ModelBehavior {
|
|||
function __getMin($model, $scope, $left, $recursive = -1) {
|
||||
$db =& ConnectionManager::getDataSource($model->useDbConfig);
|
||||
list($edge) = array_values($model->find('first', array(
|
||||
'conditions' => $scope,
|
||||
'fields' => $db->calculate($model, 'min', array($left)),
|
||||
'recursive' => $recursive
|
||||
'conditions' => $scope,
|
||||
'fields' => $db->calculate($model, 'min', array($left)),
|
||||
'recursive' => $recursive
|
||||
)));
|
||||
return ife(empty($edge[$left]), 0, $edge[$left]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Table sync method.
|
||||
*
|
||||
|
|
|
@ -47,24 +47,22 @@ class DboAdodb extends DboSource {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
var $description = "ADOdb DBO Driver";
|
||||
|
||||
var $description = "ADOdb DBO Driver";
|
||||
/**
|
||||
* ADOConnection object with which we connect.
|
||||
*
|
||||
* @var ADOConnection The connection object.
|
||||
* @access private
|
||||
*/
|
||||
var $_adodb = null;
|
||||
|
||||
var $_adodb = null;
|
||||
/**
|
||||
* Array translating ADOdb column MetaTypes to cake-supported metatypes
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_adodbColumnTypes = array(
|
||||
'string' => 'C',
|
||||
var $_adodbColumnTypes = array(
|
||||
'string' => 'C',
|
||||
'text' => 'X',
|
||||
'date' => 'D',
|
||||
'timestamp' => 'T',
|
||||
|
@ -84,7 +82,7 @@ class DboAdodb extends DboSource {
|
|||
'primary_key' => array('name' => 'R', 'limit' => 11),
|
||||
'string' => array('name' => 'C', 'limit' => '255'),
|
||||
'text' => array('name' => 'X'),
|
||||
'integer' => array('name' => 'I', 'limit' => '11', 'formatter' => 'intval',),
|
||||
'integer' => array('name' => 'I', 'limit' => '11', 'formatter' => 'intval'),
|
||||
'float' => array('name' => 'N', 'formatter' => 'floatval'),
|
||||
'timestamp' => array('name' => 'T', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
|
||||
'time' => array('name' => 'T', 'format' => 'H:i:s', 'formatter' => 'date'),
|
||||
|
@ -98,7 +96,7 @@ class DboAdodb extends DboSource {
|
|||
*
|
||||
* @param array $config Configuration array for connecting
|
||||
*/
|
||||
function connect() {
|
||||
function connect() {
|
||||
$config = $this->config;
|
||||
$persistent = strrpos($config['connect'], '|p');
|
||||
|
||||
|
@ -126,9 +124,9 @@ class DboAdodb extends DboSource {
|
|||
*
|
||||
* @return boolean True if the database could be disconnected, else false
|
||||
*/
|
||||
function disconnect() {
|
||||
return $this->_adodb->Close();
|
||||
}
|
||||
function disconnect() {
|
||||
return $this->_adodb->Close();
|
||||
}
|
||||
/**
|
||||
* Executes given SQL statement.
|
||||
*
|
||||
|
@ -219,13 +217,12 @@ class DboAdodb extends DboSource {
|
|||
function listSources() {
|
||||
$tables = $this->_adodb->MetaTables('TABLES');
|
||||
|
||||
if (!sizeof($tables) > 0) {
|
||||
trigger_error(ERROR_NO_TABLE_LIST, E_USER_NOTICE);
|
||||
exit;
|
||||
}
|
||||
|
||||
return $tables;
|
||||
}
|
||||
if (!sizeof($tables) > 0) {
|
||||
trigger_error(ERROR_NO_TABLE_LIST, E_USER_NOTICE);
|
||||
exit;
|
||||
}
|
||||
return $tables;
|
||||
}
|
||||
/**
|
||||
* Returns an array of the fields in the table used by the given model.
|
||||
*
|
||||
|
@ -289,10 +286,9 @@ class DboAdodb extends DboSource {
|
|||
*
|
||||
* @Returns the last autonumbering ID inserted. Returns false if function not supported.
|
||||
*/
|
||||
function lastInsertId() {
|
||||
return $this->_adodb->Insert_ID();
|
||||
}
|
||||
|
||||
function lastInsertId() {
|
||||
return $this->_adodb->Insert_ID();
|
||||
}
|
||||
/**
|
||||
* Returns a LIMIT statement in the correct format for the particular database.
|
||||
*
|
||||
|
@ -301,7 +297,7 @@ class DboAdodb extends DboSource {
|
|||
* @return string SQL limit/offset statement
|
||||
* @todo Please change output string to whatever select your database accepts. adodb doesn't allow us to get the correct limit string out of it.
|
||||
*/
|
||||
function limit($limit, $offset = null) {
|
||||
function limit($limit, $offset = null) {
|
||||
if ($limit) {
|
||||
$rt = '';
|
||||
if (!strpos(strtolower($limit), 'limit') || strpos(strtolower($limit), 'limit') === 0) {
|
||||
|
@ -316,10 +312,9 @@ class DboAdodb extends DboSource {
|
|||
return $rt;
|
||||
}
|
||||
return null;
|
||||
// please change to whatever select your database accepts
|
||||
// adodb doesn't allow us to get the correct limit string out of it
|
||||
}
|
||||
|
||||
// please change to whatever select your database accepts
|
||||
// adodb doesn't allow us to get the correct limit string out of it
|
||||
}
|
||||
/**
|
||||
* Converts database-layer column types to basic types
|
||||
*
|
||||
|
|
|
@ -557,7 +557,7 @@ class DboDb2 extends DboSource {
|
|||
$i = 0;
|
||||
|
||||
foreach ($row as $index => $field) {
|
||||
$table = $this->map[$index][0];
|
||||
$table = $this->map[$index][0];
|
||||
$column = strtolower($this->map[$index][1]);
|
||||
$resultRow[$table][$column] = $row[$index];
|
||||
$i++;
|
||||
|
|
|
@ -387,7 +387,7 @@ class DboMssql extends DboSource {
|
|||
$error = mssql_get_last_message($this->connection);
|
||||
|
||||
if ($error) {
|
||||
if (strpos(strtolower($error), 'changed database') === false) {
|
||||
if (!preg_match('/contesto di database|changed database/i', $error)) {
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,15 +152,14 @@ class DboMysqli extends DboSource {
|
|||
* @access protected
|
||||
*/
|
||||
function _executeProcedure($sql) {
|
||||
$answer = mysqli_multi_query($this->connection, $sql);
|
||||
$answer = mysqli_multi_query($this->connection, $sql);
|
||||
|
||||
$firstResult = mysqli_store_result($this->connection);
|
||||
$firstResult = mysqli_store_result($this->connection);
|
||||
|
||||
if (mysqli_more_results($this->connection)) {
|
||||
while($lastResult = mysqli_next_result($this->connection));
|
||||
}
|
||||
|
||||
return $firstResult;
|
||||
if (mysqli_more_results($this->connection)) {
|
||||
while($lastResult = mysqli_next_result($this->connection));
|
||||
}
|
||||
return $firstResult;
|
||||
}
|
||||
/**
|
||||
* Returns an array of sources (tables) in the database.
|
||||
|
|
|
@ -482,15 +482,16 @@ class DboOracle extends DboSource {
|
|||
}
|
||||
$fields = array();
|
||||
|
||||
for($i=0; $row = $this->fetchRow(); $i++) {
|
||||
$fields[strtolower($row[0]['COLUMN_NAME'])] = array('type'=> $this->column($row[0]['DATA_TYPE']),
|
||||
'length'=> $row[0]['DATA_LENGTH']);
|
||||
for ($i = 0; $row = $this->fetchRow(); $i++) {
|
||||
$fields[strtolower($row[0]['COLUMN_NAME'])] = array(
|
||||
'type'=> $this->column($row[0]['DATA_TYPE']),
|
||||
'length'=> $row[0]['DATA_LENGTH']
|
||||
);
|
||||
}
|
||||
$this->__cacheDescription($this->fullTableName($model, false), $fields);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all the records in a table and drops all associated auto-increment sequences.
|
||||
* Using DELETE instead of TRUNCATE because it causes locking problems.
|
||||
|
@ -532,11 +533,10 @@ class DboOracle extends DboSource {
|
|||
$this->execute("SELECT {$this->_sequenceMap[$table]}.nextval FROM dual");
|
||||
$this->execute("ALTER SEQUENCE {$this->_sequenceMap[$table]} INCREMENT BY 1");
|
||||
} else {
|
||||
#$this->execute("DROP SEQUENCE {$this->_sequenceMap[$table]}");
|
||||
//$this->execute("DROP SEQUENCE {$this->_sequenceMap[$table]}");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables, disables, and lists table constraints
|
||||
*
|
||||
|
@ -821,9 +821,9 @@ class DboOracle extends DboSource {
|
|||
* @access public
|
||||
*/
|
||||
function value($data, $column = null, $safe = false) {
|
||||
$parent = parent::value($data, $column, $safe);
|
||||
$parent = parent::value($data, $column, $safe);
|
||||
|
||||
if ($parent != null) {
|
||||
if ($parent != null) {
|
||||
return $parent;
|
||||
}
|
||||
|
||||
|
@ -839,7 +839,7 @@ class DboOracle extends DboSource {
|
|||
case 'date':
|
||||
$data = date('Y-m-d H:i:s', strtotime($data));
|
||||
$data = "TO_DATE('$data', 'YYYY-MM-DD HH24:MI:SS')";
|
||||
break;
|
||||
break;
|
||||
case 'integer' :
|
||||
case 'float' :
|
||||
case null :
|
||||
|
@ -847,9 +847,9 @@ class DboOracle extends DboSource {
|
|||
break;
|
||||
}
|
||||
default:
|
||||
$data = str_replace("'", "''", $data);
|
||||
$data = "'$data'";
|
||||
break;
|
||||
$data = str_replace("'", "''", $data);
|
||||
$data = "'$data'";
|
||||
break;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -1692,28 +1692,12 @@ class DboSource extends DataSource {
|
|||
*/
|
||||
function conditions($conditions, $quoteValues = true, $where = true, $model = null) {
|
||||
$clause = $out = '';
|
||||
if (is_string($conditions) || empty($conditions) || $conditions === true) {
|
||||
if (empty($conditions) || trim($conditions) == '' || $conditions === true) {
|
||||
if ($where) {
|
||||
return ' WHERE 1 = 1';
|
||||
}
|
||||
return '1 = 1';
|
||||
}
|
||||
if (!preg_match('/^WHERE\\x20|^GROUP\\x20BY\\x20|^HAVING\\x20|^ORDER\\x20BY\\x20/i', $conditions, $match)) {
|
||||
if ($where) {
|
||||
$clause = ' WHERE ';
|
||||
}
|
||||
}
|
||||
if (trim($conditions) == '') {
|
||||
$conditions = ' 1 = 1';
|
||||
} else {
|
||||
$conditions = $this->__quoteFields($conditions);
|
||||
}
|
||||
return $clause . $conditions;
|
||||
} else {
|
||||
if ($where) {
|
||||
$clause = ' WHERE ';
|
||||
}
|
||||
|
||||
if ($where) {
|
||||
$clause = ' WHERE ';
|
||||
}
|
||||
|
||||
if (is_array($conditions) && !empty($conditions)) {
|
||||
if (!empty($conditions)) {
|
||||
$out = $this->conditionKeysToString($conditions, $quoteValues, $model);
|
||||
}
|
||||
|
@ -1722,6 +1706,19 @@ class DboSource extends DataSource {
|
|||
}
|
||||
return $clause . join(' AND ', $out);
|
||||
}
|
||||
|
||||
if (empty($conditions) || trim($conditions) == '' || $conditions === true) {
|
||||
return $clause . '1 = 1';
|
||||
}
|
||||
if (preg_match('/^WHERE\\x20|^GROUP\\x20BY\\x20|^HAVING\\x20|^ORDER\\x20BY\\x20/i', $conditions, $match)) {
|
||||
$clause = '';
|
||||
}
|
||||
if (trim($conditions) == '') {
|
||||
$conditions = ' 1 = 1';
|
||||
} else {
|
||||
$conditions = $this->__quoteFields($conditions);
|
||||
}
|
||||
return $clause . $conditions;
|
||||
}
|
||||
/**
|
||||
* Creates a WHERE clause by parsing given conditions array. Used by DboSource::conditions().
|
||||
|
|
|
@ -241,7 +241,7 @@ class AcoAction extends AppModel {
|
|||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $belongsTo = array('Aco');
|
||||
var $belongsTo = array('Aco');
|
||||
}
|
||||
/**
|
||||
* Access Request Object
|
||||
|
@ -292,21 +292,21 @@ class Permission extends AppModel {
|
|||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $useTable = 'aros_acos';
|
||||
var $useTable = 'aros_acos';
|
||||
/**
|
||||
* Permissions link AROs with ACOs
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $belongsTo = array('Aro', 'Aco');
|
||||
var $belongsTo = array('Aro', 'Aco');
|
||||
/**
|
||||
* No behaviors for this model
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $actsAs = null;
|
||||
var $actsAs = null;
|
||||
/**
|
||||
* Constructor, used to tell this model to use the
|
||||
* database configured for ACL
|
||||
|
|
|
@ -1024,18 +1024,24 @@ class Model extends Overloadable {
|
|||
*
|
||||
* @param string $name Name of the table field
|
||||
* @param mixed $value Value of the field
|
||||
* @param boolean $validate Whether or not this model should validate before saving (defaults to false)
|
||||
* @return boolean True on success save
|
||||
* @param array $options See $options param in Model::save(). Does not respect 'fieldList' key if passed
|
||||
* @return boolean See Model::save()
|
||||
* @access public
|
||||
* @see Model::save()
|
||||
*/
|
||||
function saveField($name, $value, $validate = false) {
|
||||
$id = $this->id;
|
||||
$this->create(false);
|
||||
return $this->save(array($this->alias => array(
|
||||
$this->primaryKey => $id,
|
||||
$name => $value,
|
||||
)), $validate, array($name));
|
||||
|
||||
if (is_array($validate)) {
|
||||
$options = array_merge(array('validate' => false, 'fieldList' => array($name)), $options);
|
||||
} else {
|
||||
$options = array('validate' => $validate, 'fieldList' => array($name));
|
||||
}
|
||||
|
||||
return $this->save(
|
||||
array($this->alias => array($this->primaryKey => $id, $name => $value)), $options
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Saves model data to the database. By default, validation occurs before save.
|
||||
|
@ -1104,7 +1110,7 @@ class Model extends Overloadable {
|
|||
}
|
||||
}
|
||||
|
||||
if ($options['callbacks'] === true || $options['callbacks'] == 'before') {
|
||||
if ($options['callbacks'] === true || $options['callbacks'] === 'before') {
|
||||
if (!$this->Behaviors->trigger($this, 'beforeSave', array($options), array('break' => true, 'breakOn' => false)) || !$this->beforeSave($options)) {
|
||||
$this->whitelist = $_whitelist;
|
||||
return false;
|
||||
|
@ -1183,7 +1189,7 @@ class Model extends Overloadable {
|
|||
if (!empty($this->data)) {
|
||||
$success = $this->data;
|
||||
}
|
||||
if ($options['callbacks'] === true || $options['callbacks'] == 'after') {
|
||||
if ($options['callbacks'] === true || $options['callbacks'] === 'after') {
|
||||
$this->Behaviors->trigger($this, 'afterSave', array($created, $options));
|
||||
$this->afterSave($created);
|
||||
}
|
||||
|
@ -1435,7 +1441,7 @@ class Model extends Overloadable {
|
|||
$return[$association][] = $val;
|
||||
}
|
||||
} else {
|
||||
$return[$association] = $_return;
|
||||
$return[$association] = $_return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1696,9 +1702,10 @@ class Model extends Overloadable {
|
|||
if ($this->__exists !== null && $reset !== true) {
|
||||
return $this->__exists;
|
||||
}
|
||||
return $this->__exists = ($this->find('count', array(
|
||||
'conditions' => array($this->alias . '.' . $this->primaryKey => $this->getID()), 'recursive' => -1
|
||||
)) > 0);
|
||||
$conditions = array($this->alias . '.' . $this->primaryKey => $this->getID());
|
||||
$recursive = -1;
|
||||
|
||||
return $this->__exists = ($this->find('count', compact('conditions', 'recursive')) > 0);
|
||||
}
|
||||
/**
|
||||
* Returns true if a record that meets given conditions exists
|
||||
|
|
|
@ -1020,7 +1020,7 @@ class Multibyte extends Object {
|
|||
* @return array
|
||||
* @access private
|
||||
*/
|
||||
function __find($char, $type = 'lower'){
|
||||
function __find($char, $type = 'lower') {
|
||||
$_this =& Multibyte::getInstance();
|
||||
$value = false;
|
||||
$found = array();
|
||||
|
@ -1048,7 +1048,7 @@ class Multibyte extends Object {
|
|||
}
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* resets the utf8 map array
|
||||
*
|
||||
|
|
|
@ -97,7 +97,7 @@ class Object {
|
|||
$params = am(array('autoRender' => 0, 'return' => 1, 'bare' => 1, 'requested' => 1), $extra);
|
||||
$dispatcher = new Dispatcher;
|
||||
return $dispatcher->dispatch($url, $params);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Calls a method on this object with the given parameters. Provides an OO wrapper
|
||||
* for call_user_func_array, and improves performance by using straight method calls
|
||||
|
|
|
@ -974,7 +974,7 @@ class Router extends Object {
|
|||
} elseif (!empty($routeParams) && !empty($route[3])) {
|
||||
|
||||
if (!empty($required)) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
foreach ($params as $key => $val) {
|
||||
if ((!isset($url[$key]) || $url[$key] != $val) || (!isset($defaults[$key]) || $defaults[$key] != $val) && !in_array($key, $routeParams)) {
|
||||
|
@ -1022,7 +1022,7 @@ class Router extends Object {
|
|||
}
|
||||
|
||||
if (isset($params['pass']) && is_array($params['pass'])) {
|
||||
$params['pass'] = implode('/', Set::filter($params['pass'], true));
|
||||
$params['pass'] = implode('/', Set::filter($params['pass'], true));
|
||||
} elseif (!isset($params['pass'])) {
|
||||
$params['pass'] = '';
|
||||
}
|
||||
|
|
|
@ -52,10 +52,10 @@ class Security extends Object {
|
|||
*/
|
||||
function &getInstance() {
|
||||
static $instance = array();
|
||||
if (!$instance) {
|
||||
$instance[0] =& new Security;
|
||||
}
|
||||
return $instance[0];
|
||||
if (!$instance) {
|
||||
$instance[0] =& new Security;
|
||||
}
|
||||
return $instance[0];
|
||||
}
|
||||
/**
|
||||
* Get allowed minutes of inactivity based on security level.
|
||||
|
@ -142,7 +142,7 @@ class Security extends Object {
|
|||
return $return;
|
||||
} else {
|
||||
$type = 'md5';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($type == 'md5') {
|
||||
|
|
|
@ -176,7 +176,7 @@ class CakeSession extends Object {
|
|||
*
|
||||
* @access public
|
||||
*/
|
||||
function started(){
|
||||
function started() {
|
||||
if (isset($_SESSION)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ class CakeSession extends Object {
|
|||
function check($name) {
|
||||
$var = $this->__validateKeys($name);
|
||||
if (empty($var)) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
$result = Set::extract($_SESSION, $var);
|
||||
return isset($result);
|
||||
|
|
|
@ -517,7 +517,7 @@ class Set extends Object {
|
|||
}
|
||||
if (!preg_match('/(.+?)([><!]?[=]|[><])(.*)/', $condition, $match)) {
|
||||
if (ctype_digit($condition)) {
|
||||
if ($i != $condition) {
|
||||
if ($i != $condition) {
|
||||
return false;
|
||||
}
|
||||
} elseif (preg_match_all('/(?:^[0-9]+|(?<=,)[0-9]+)/', $condition, $matches)) {
|
||||
|
@ -924,9 +924,9 @@ class Set extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function combine($data, $path1 = null, $path2 = null, $groupPath = null) {
|
||||
if (empty($data)) {
|
||||
return array();
|
||||
}
|
||||
if (empty($data)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (is_a($this, 'set') && is_string($data) && is_string($path1) && is_string($path2)) {
|
||||
$groupPath = $path2;
|
||||
|
|
|
@ -257,9 +257,9 @@ class CakeSocket extends Object {
|
|||
*
|
||||
* @access private
|
||||
*/
|
||||
function __destruct() {
|
||||
$this->disconnect();
|
||||
}
|
||||
function __destruct() {
|
||||
$this->disconnect();
|
||||
}
|
||||
/**
|
||||
* Resets the state of this Socket instance to it's initial state (before Object::__construct got executed)
|
||||
*
|
||||
|
|
|
@ -84,7 +84,7 @@ class Validation extends Object {
|
|||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $deep = null;
|
||||
var $deep = null;
|
||||
/**
|
||||
* Some class methods use the $type param to determine which validation to perfom in the method
|
||||
*
|
||||
|
@ -623,7 +623,7 @@ class Validation extends Object {
|
|||
break;
|
||||
}
|
||||
return $_this->_check();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Validate a multiple select.
|
||||
*
|
||||
|
@ -634,9 +634,9 @@ class Validation extends Object {
|
|||
* @todo Implement
|
||||
*/
|
||||
function multiple($check, $type, $regex = null) {
|
||||
//Validate a select object for a selected index past 0.
|
||||
//Validate a select against a list of restriced indexes.
|
||||
//Validate a multiple-select for the quantity selected.
|
||||
//Validate a select object for a selected index past 0.
|
||||
//Validate a select against a list of restriced indexes.
|
||||
//Validate a multiple-select for the quantity selected.
|
||||
}
|
||||
/**
|
||||
* Checks if a value is numeric.
|
||||
|
@ -793,7 +793,7 @@ class Validation extends Object {
|
|||
$_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\\/\\/)?(?:(?:(?:25[0-5]|2[0-4]\d|(?:(?:1\d)?|[1-9]?)\d)\.){3}(?:25[0-5]|2[0-4]\d|(?:(?:1\d)?|[1-9]?)\d)'
|
||||
. '|(?:[0-9a-z]{1}[0-9a-z\\-]*\\.)*(?:[0-9a-z]{1}[0-9a-z\\-]{0,62})\\.(?:[a-z]{2,6}|[a-z]{2}\\.[a-z]{2,6})'
|
||||
. '(?::[0-9]{1,4})?)(?:\\/?|\\/[\\w\\-\\.,\'@?^=%&:;\/~\\+#]*[\\w\\-\\@?^=%&\/~\\+#])$/i';
|
||||
return $_this->_check();
|
||||
return $_this->_check();
|
||||
}
|
||||
/**
|
||||
* Checks if a value is in a given list.
|
||||
|
|
|
@ -558,8 +558,7 @@ class DispatcherTest extends UnitTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testQueryStringOnRoot() {
|
||||
$_GET = array('coffee' => 'life',
|
||||
'sleep' => 'sissies');
|
||||
$_GET = array('coffee' => 'life', 'sleep' => 'sissies');
|
||||
$Dispatcher =& new Dispatcher();
|
||||
$uri = 'posts/home/?coffee=life&sleep=sissies';
|
||||
$result = $Dispatcher->parseParams($uri);
|
||||
|
|
|
@ -254,7 +254,7 @@ PHP;
|
|||
34 => -2,
|
||||
35 => -2,
|
||||
36 => -2,
|
||||
37=> -2,
|
||||
37 => -2,
|
||||
38 => -2,
|
||||
39 => -2,
|
||||
40 => -2,
|
||||
|
@ -411,7 +411,7 @@ PHP;
|
|||
34 => -2,
|
||||
35 => -2,
|
||||
36 => -2,
|
||||
37=> -2,
|
||||
37 => -2,
|
||||
38 => -2,
|
||||
39 => -2,
|
||||
40 => -2,
|
||||
|
@ -424,7 +424,7 @@ PHP;
|
|||
47 => -2,
|
||||
48 => 1,
|
||||
49 => 1,
|
||||
50 => -1,
|
||||
50 => -1,
|
||||
51 => 1,
|
||||
52 => 1,
|
||||
53 => -2,
|
||||
|
@ -437,7 +437,7 @@ PHP;
|
|||
60 => 1,
|
||||
61 => 1,
|
||||
62 => -2,
|
||||
63 => -2,
|
||||
63 => -2,
|
||||
64 => 1,
|
||||
65 => -2,
|
||||
66 => 1,
|
||||
|
@ -486,7 +486,7 @@ PHP;
|
|||
34 => 'ignored',
|
||||
35 => 'ignored',
|
||||
36 => 'ignored',
|
||||
37 => 'ignored',
|
||||
37 => 'ignored',
|
||||
38 => 'ignored',
|
||||
39 => 'ignored',
|
||||
40 => 'ignored show start',
|
||||
|
@ -502,7 +502,7 @@ PHP;
|
|||
47 => 'ignored show',
|
||||
48 => 'covered show',
|
||||
49 => 'covered show',
|
||||
50 => 'uncovered show',
|
||||
50 => 'uncovered show',
|
||||
51 => 'covered show',
|
||||
52 => 'covered show',
|
||||
53 => 'ignored show end',
|
||||
|
@ -515,7 +515,7 @@ PHP;
|
|||
60 => 'covered show',
|
||||
61 => 'covered show',
|
||||
62 => 'ignored show end',
|
||||
63 => 'ignored',
|
||||
63 => 'ignored',
|
||||
64 => 'covered show start',
|
||||
65 => 'ignored show',
|
||||
66 => 'covered show show',
|
||||
|
|
|
@ -67,7 +67,7 @@ if (!class_exists('AppController')) {
|
|||
|
||||
}
|
||||
} else {
|
||||
define('AppControllerExists', true);
|
||||
define('APP_CONTROLLER_EXISTS', true);
|
||||
}
|
||||
/**
|
||||
* ParamTestComponent
|
||||
|
@ -335,7 +335,7 @@ class ComponentTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testComponentsWithParams() {
|
||||
$this->skipIf(defined('AppControllerExists'), 'Components with Params test will be skipped as it needs a non-existent AppController. As the an AppController class exists, this cannot be run.');
|
||||
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), 'Components with Params test will be skipped as it needs a non-existent AppController. As the an AppController class exists, this cannot be run.');
|
||||
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->components = array('ParamTest' => array('test' => 'value', 'flag'), 'Apple');
|
||||
|
|
|
@ -444,7 +444,7 @@ class AuthTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testAuthorizeController(){
|
||||
function testAuthorizeController() {
|
||||
$this->AuthUser =& new AuthUser();
|
||||
$user = $this->AuthUser->find();
|
||||
$this->Controller->Session->write('Auth', $user);
|
||||
|
@ -567,7 +567,7 @@ class AuthTest extends CakeTestCase {
|
|||
$this->Controller->params['url']['url'] = 'users/login';
|
||||
$this->Controller->Auth->initialize($this->Controller);
|
||||
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
$this->Controller->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'display', 'welcome');
|
||||
$this->Controller->Auth->startup($this->Controller);
|
||||
$expected = Router::normalize($this->Controller->Auth->loginRedirect);
|
||||
|
@ -577,7 +577,7 @@ class AuthTest extends CakeTestCase {
|
|||
|
||||
$this->Controller->params['url']['url'] = 'admin/';
|
||||
$this->Controller->Auth->initialize($this->Controller);
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
$this->Controller->Auth->loginRedirect = null;
|
||||
$this->Controller->Auth->startup($this->Controller);
|
||||
$expected = Router::normalize('admin/');
|
||||
|
@ -596,7 +596,7 @@ class AuthTest extends CakeTestCase {
|
|||
|
||||
$this->Controller->Auth->loginAction = 'auth_test/login';
|
||||
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
$this->Controller->Auth->loginRedirect = false;
|
||||
$this->Controller->Auth->startup($this->Controller);
|
||||
$expected = Router::normalize('admin');
|
||||
|
@ -609,7 +609,7 @@ class AuthTest extends CakeTestCase {
|
|||
$this->Controller->params = Router::parse($url);
|
||||
$this->Controller->Auth->initialize($this->Controller);
|
||||
$this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
$this->Controller->Auth->startup($this->Controller);
|
||||
$expected = Router::normalize('posts/index/year:2008/month:feb');
|
||||
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
|
||||
|
@ -620,7 +620,7 @@ class AuthTest extends CakeTestCase {
|
|||
$this->Controller->params = Router::parse($url);
|
||||
$this->Controller->Auth->initialize($this->Controller);
|
||||
$this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
$this->Controller->Auth->startup($this->Controller);
|
||||
$expected = Router::normalize('posts/view/1');
|
||||
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
|
||||
|
|
|
@ -264,7 +264,7 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
'posted',
|
||||
array('type' => 'basic', 'users' => array('admin' => 'password'))
|
||||
);
|
||||
$_SERVER['PHP_AUTH_USER'] = 'admin';
|
||||
$_SERVER['PHP_AUTH_USER'] = 'admin';
|
||||
$_SERVER['PHP_AUTH_PW'] = 'password';
|
||||
$this->Controller->Security->startup($this->Controller);
|
||||
$this->assertFalse($this->Controller->failed);
|
||||
|
@ -275,7 +275,7 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
'posted',
|
||||
array('type' => 'basic', 'users' => array('admin' => 'password'))
|
||||
);
|
||||
$_SERVER['PHP_AUTH_USER'] = 'admin2';
|
||||
$_SERVER['PHP_AUTH_USER'] = 'admin2';
|
||||
$_SERVER['PHP_AUTH_PW'] = 'password';
|
||||
$this->Controller->Security->startup($this->Controller);
|
||||
$this->assertTrue($this->Controller->failed);
|
||||
|
@ -285,7 +285,7 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
'posted',
|
||||
array('type' => 'basic', 'users' => array('admin' => 'password'))
|
||||
);
|
||||
$_SERVER['PHP_AUTH_USER'] = 'admin';
|
||||
$_SERVER['PHP_AUTH_USER'] = 'admin';
|
||||
$_SERVER['PHP_AUTH_PW'] = 'password2';
|
||||
$this->Controller->Security->startup($this->Controller);
|
||||
$this->assertTrue($this->Controller->failed);
|
||||
|
@ -719,9 +719,10 @@ DIGEST;
|
|||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
|
||||
$result = $this->Controller->Security->generateDigestResponseHash($data);
|
||||
$expected = md5(
|
||||
$expected = md5(
|
||||
md5($data['username'] . ':' . $loginData['realm'].':'.$data['password']) . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' .
|
||||
md5(env('REQUEST_METHOD') . ':' . $data['uri']));
|
||||
md5(env('REQUEST_METHOD') . ':' . $data['uri'])
|
||||
);
|
||||
$this->assertIdentical($result, $expected);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -108,7 +108,7 @@ class SessionComponentTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testSessionValid() {
|
||||
function testSessionValid() {
|
||||
$Session =& new SessionComponent();
|
||||
|
||||
$this->assertTrue($Session->valid());
|
||||
|
@ -128,7 +128,7 @@ class SessionComponentTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testSessionError() {
|
||||
function testSessionError() {
|
||||
$Session =& new SessionComponent();
|
||||
|
||||
$this->assertFalse($Session->error());
|
||||
|
@ -225,7 +225,7 @@ class SessionComponentTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testSessionCheck() {
|
||||
function testSessionCheck() {
|
||||
$Session =& new SessionComponent();
|
||||
|
||||
$this->assertFalse($Session->check('Test'));
|
||||
|
@ -246,7 +246,7 @@ class SessionComponentTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testSessionFlash() {
|
||||
function testSessionFlash() {
|
||||
$Session =& new SessionComponent();
|
||||
|
||||
$this->assertNull($Session->read('Message.flash'));
|
||||
|
|
|
@ -157,8 +157,8 @@ if (!class_exists('AppController')) {
|
|||
*/
|
||||
var $components = array('Cookie');
|
||||
}
|
||||
} else if (!defined('AppControllerExists')) {
|
||||
define('AppControllerExists', true);
|
||||
} else if (!defined('APP_CONTROLLER_EXISTS')) {
|
||||
define('APP_CONTROLLER_EXISTS', true);
|
||||
}
|
||||
/**
|
||||
* TestController class
|
||||
|
@ -378,7 +378,7 @@ class ControllerTest extends CakeTestCase {
|
|||
<p><a href="/flash">this should work</a></p>
|
||||
</body>
|
||||
</html>';
|
||||
$result = str_replace(array("\t", "\r\n", "\n"), "", $result);
|
||||
$result = str_replace(array("\t", "\r\n", "\n"), "", $result);
|
||||
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ class ControllerTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testMergeVars() {
|
||||
$this->skipIf(defined('AppControllerExists'), 'MergeVars will be skipped as it needs a non-existent AppController. As the an AppController class exists, this cannot be run.');
|
||||
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), 'MergeVars will be skipped as it needs a non-existent AppController. As the an AppController class exists, this cannot be run.');
|
||||
|
||||
$TestController =& new TestController();
|
||||
$TestController->constructClasses();
|
||||
|
|
|
@ -59,10 +59,10 @@ class DebuggerTest extends UnitTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testDocRef() {
|
||||
ini_set('docref_root', '');
|
||||
$this->assertEqual(ini_get('docref_root'), '');
|
||||
$debugger = new Debugger();
|
||||
$this->assertEqual(ini_get('docref_root'), 'http://php.net/');
|
||||
ini_set('docref_root', '');
|
||||
$this->assertEqual(ini_get('docref_root'), '');
|
||||
$debugger = new Debugger();
|
||||
$this->assertEqual(ini_get('docref_root'), 'http://php.net/');
|
||||
}
|
||||
/**
|
||||
* testOutput method
|
||||
|
|
|
@ -244,7 +244,7 @@ class FolderTest extends UnitTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testWindowsPath(){
|
||||
function testWindowsPath() {
|
||||
$Folder =& new Folder();
|
||||
$this->assertTrue($Folder->isWindowsPath('C:\cake'));
|
||||
$this->assertTrue($Folder->isWindowsPath('c:\cake'));
|
||||
|
@ -255,7 +255,7 @@ class FolderTest extends UnitTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testIsAbsolute(){
|
||||
function testIsAbsolute() {
|
||||
$Folder =& new Folder();
|
||||
$this->assertTrue($Folder->isAbsolute('C:\cake'));
|
||||
$this->assertTrue($Folder->isAbsolute('/usr/local'));
|
||||
|
@ -267,7 +267,7 @@ class FolderTest extends UnitTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testIsSlashTerm(){
|
||||
function testIsSlashTerm() {
|
||||
$Folder =& new Folder();
|
||||
$this->assertTrue($Folder->isSlashTerm('C:\cake\\'));
|
||||
$this->assertTrue($Folder->isSlashTerm('/usr/local/'));
|
||||
|
|
|
@ -1195,10 +1195,12 @@ class HttpSocketTest extends UnitTestCase {
|
|||
function testTokenEscapeChars() {
|
||||
$this->Socket->reset();
|
||||
|
||||
$expected = array('\x22','\x28','\x29','\x3c','\x3e','\x40','\x2c','\x3b','\x3a','\x5c','\x2f','\x5b','\x5d','\x3f','\x3d','\x7b',
|
||||
'\x7d','\x20','\x00','\x01','\x02','\x03','\x04','\x05','\x06','\x07','\x08','\x09','\x0a','\x0b','\x0c','\x0d',
|
||||
'\x0e','\x0f','\x10','\x11','\x12','\x13','\x14','\x15','\x16','\x17','\x18','\x19','\x1a','\x1b','\x1c','\x1d',
|
||||
'\x1e','\x1f','\x7f');
|
||||
$expected = array(
|
||||
'\x22','\x28','\x29','\x3c','\x3e','\x40','\x2c','\x3b','\x3a','\x5c','\x2f','\x5b','\x5d','\x3f','\x3d','\x7b',
|
||||
'\x7d','\x20','\x00','\x01','\x02','\x03','\x04','\x05','\x06','\x07','\x08','\x09','\x0a','\x0b','\x0c','\x0d',
|
||||
'\x0e','\x0f','\x10','\x11','\x12','\x13','\x14','\x15','\x16','\x17','\x18','\x19','\x1a','\x1b','\x1c','\x1d',
|
||||
'\x1e','\x1f','\x7f'
|
||||
);
|
||||
$r = $this->Socket->__tokenEscapeChars();
|
||||
$this->assertEqual($r, $expected);
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ class Campaign extends CakeTestModel {
|
|||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $hasMany = array('Ad' => array('fields' => array('id','campaign_id','name') ));
|
||||
var $hasMany = array('Ad' => array('fields' => array('id','campaign_id','name')));
|
||||
}
|
||||
/**
|
||||
* Ad class
|
||||
|
@ -150,7 +150,7 @@ class Ad extends CakeTestModel {
|
|||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $belongsTo = array('Campaign' );
|
||||
var $belongsTo = array('Campaign');
|
||||
}
|
||||
/**
|
||||
* NumberTreeCase class
|
||||
|
@ -165,7 +165,9 @@ class NumberTreeCase extends CakeTestCase {
|
|||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $fixtures = array('core.number_tree', 'core.flag_tree', 'core.campaign','core.ad');
|
||||
var $fixtures = array(
|
||||
'core.number_tree', 'core.flag_tree', 'core.campaign','core.ad', 'core.translate'
|
||||
);
|
||||
/**
|
||||
* testInitialize method
|
||||
*
|
||||
|
@ -929,7 +931,7 @@ class NumberTreeCase extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testMoveToRootAndMoveUp(){
|
||||
function testMoveToRootAndMoveUp() {
|
||||
$this->NumberTree =& new NumberTree();
|
||||
$this->NumberTree->initialize(1, 1);
|
||||
$data = $this->NumberTree->find(array('NumberTree.name' => '1.1'), array('id'));
|
||||
|
@ -1255,7 +1257,7 @@ class NumberTreeCase extends CakeTestCase {
|
|||
*/
|
||||
function testMoveDownWithScope() {
|
||||
$this->Ad =& new Ad();
|
||||
$this->Ad->Behaviors->attach('Tree', array('scope'=>'Campaign'));
|
||||
$this->Ad->Behaviors->attach('Tree', array('scope' => 'Campaign'));
|
||||
$this->Ad->moveDown(6);
|
||||
|
||||
$this->Ad->id = 4;
|
||||
|
@ -1272,9 +1274,109 @@ class NumberTreeCase extends CakeTestCase {
|
|||
function testArraySyntax() {
|
||||
$this->NumberTree =& new NumberTree();
|
||||
$this->NumberTree->initialize(3, 3);
|
||||
$this->assertIdentical($this->NumberTree->childcount(2), $this->NumberTree->childcount(array('id' => 2)));
|
||||
$this->assertIdentical($this->NumberTree->getparentnode(2), $this->NumberTree->getparentnode(array('id' => 2)));
|
||||
$this->assertIdentical($this->NumberTree->getpath(4), $this->NumberTree->getpath(array('id' => 4)));
|
||||
$this->assertIdentical($this->NumberTree->childCount(2), $this->NumberTree->childCount(array('id' => 2)));
|
||||
$this->assertIdentical($this->NumberTree->getParentNode(2), $this->NumberTree->getParentNode(array('id' => 2)));
|
||||
$this->assertIdentical($this->NumberTree->getPath(4), $this->NumberTree->getPath(array('id' => 4)));
|
||||
}
|
||||
/**
|
||||
* Tests the interaction (non-interference) between TreeBehavior and other behaviors with respect
|
||||
* to callback hooks
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testTranslatingTree() {
|
||||
$this->FlagTree =& new FlagTree();
|
||||
$this->FlagTree->cacheQueries = false;
|
||||
$this->FlagTree->translateModel = 'TranslateTreeTestModel';
|
||||
$this->FlagTree->Behaviors->attach('Translate', array('name'));
|
||||
|
||||
//Save
|
||||
$this->FlagTree->locale = 'eng';
|
||||
$data = array('FlagTree' => array(
|
||||
'name' => 'name #1',
|
||||
'locale' => 'eng',
|
||||
'parent_id' => null,
|
||||
));
|
||||
$this->FlagTree->save($data);
|
||||
$result = $this->FlagTree->find('all');
|
||||
$expected = array(array('FlagTree' => array(
|
||||
'id' => 1,
|
||||
'name' => 'name #1',
|
||||
'parent_id' => null,
|
||||
'lft' => 1,
|
||||
'rght' => 2,
|
||||
'flag' => 0,
|
||||
'locale' => 'eng',
|
||||
)));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
//update existing record, same locale
|
||||
$this->FlagTree->create();
|
||||
$data['FlagTree']['name'] = 'Named 2';
|
||||
$this->FlagTree->id = 1;
|
||||
$this->FlagTree->save($data);
|
||||
$result = $this->FlagTree->find('all');
|
||||
$expected = array(array('FlagTree' => array(
|
||||
'id' => 1,
|
||||
'name' => 'Named 2',
|
||||
'parent_id' => null,
|
||||
'lft' => 1,
|
||||
'rght' => 2,
|
||||
'flag' => 0,
|
||||
'locale' => 'eng',
|
||||
)));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
//update different locale, same record
|
||||
$this->FlagTree->create();
|
||||
$this->FlagTree->locale = 'deu';
|
||||
$this->FlagTree->id = 1;
|
||||
$data = array('FlagTree' => array(
|
||||
'id' => 1,
|
||||
'parent_id' => null,
|
||||
'name' => 'namen #1',
|
||||
'locale' => 'deu',
|
||||
));
|
||||
$this->FlagTree->save($data);
|
||||
|
||||
$this->FlagTree->locale = 'deu';
|
||||
$result = $this->FlagTree->find('all');
|
||||
$expected = array(array('FlagTree' => array(
|
||||
'id' => 1,
|
||||
'name' => 'namen #1',
|
||||
'parent_id' => null,
|
||||
'lft' => 1,
|
||||
'rght' => 2,
|
||||
'flag' => 0,
|
||||
'locale' => 'deu',
|
||||
)));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
//Save with bindTranslation
|
||||
$this->FlagTree->locale = 'eng';
|
||||
$data = array(
|
||||
'name' => array('eng' => 'New title', 'spa' => 'Nuevo leyenda'),
|
||||
'parent_id' => null
|
||||
);
|
||||
$this->FlagTree->create($data);
|
||||
$this->FlagTree->save();
|
||||
|
||||
$this->FlagTree->unbindTranslation();
|
||||
$translations = array('name' => 'Name');
|
||||
$this->FlagTree->bindTranslation($translations, false);
|
||||
$this->FlagTree->locale = array('eng', 'spa');
|
||||
|
||||
$result = $this->FlagTree->read();
|
||||
$expected = array(
|
||||
'FlagTree' => array('id' => 2, 'parent_id' => null, 'locale' => 'eng', 'name' => 'New title', 'flag' => null, 'lft' => 3, 'rght' => 4),
|
||||
'Name' => array(
|
||||
array('id' => 4, 'locale' => 'eng', 'model' => 'FlagTree', 'foreign_key' => 2, 'field' => 'name', 'content' => 'New title'),
|
||||
array('id' => 5, 'locale' => 'spa', 'model' => 'FlagTree', 'foreign_key' => 2, 'field' => 'name', 'content' => 'Nuevo leyenda')
|
||||
),
|
||||
);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -73,9 +73,6 @@ class DboOracleTest extends CakeTestCase {
|
|||
$r = 'ORA-01017: invalid username/password; logon denied';
|
||||
$this->assertEqual($e, $r);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -829,13 +829,9 @@ class Article2 extends CakeTestModel {
|
|||
* @access public
|
||||
*/
|
||||
var $belongsTo = array(
|
||||
'Category2' => array(
|
||||
'className' => 'Category2'
|
||||
),
|
||||
'User2' => array(
|
||||
'className' => 'User2'
|
||||
)
|
||||
);
|
||||
'Category2' => array('className' => 'Category2'),
|
||||
'User2' => array('className' => 'User2')
|
||||
);
|
||||
/**
|
||||
* schema method
|
||||
*
|
||||
|
@ -861,7 +857,7 @@ class Article2 extends CakeTestModel {
|
|||
'moderate_comments' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'),
|
||||
'published' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'),
|
||||
'multipage' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'),
|
||||
'published_date' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null),
|
||||
'published_date' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null),
|
||||
'created' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null),
|
||||
'modified' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null)
|
||||
);
|
||||
|
@ -1061,22 +1057,18 @@ class ArticleFeatured2 extends CakeTestModel {
|
|||
* @access public
|
||||
*/
|
||||
var $belongsTo = array(
|
||||
'CategoryFeatured2' => array(
|
||||
'className' => 'CategoryFeatured2'
|
||||
),
|
||||
'User2' => array(
|
||||
'className' => 'User2'
|
||||
)
|
||||
);
|
||||
'CategoryFeatured2' => array('className' => 'CategoryFeatured2'),
|
||||
'User2' => array('className' => 'User2')
|
||||
);
|
||||
/**
|
||||
* hasOne property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $hasOne = array(
|
||||
'Featured2' => array('className' => 'Featured2')
|
||||
);
|
||||
var $hasOne = array(
|
||||
'Featured2' => array('className' => 'Featured2')
|
||||
);
|
||||
/**
|
||||
* hasMany property
|
||||
*
|
||||
|
@ -1633,19 +1625,23 @@ class DboSourceTest extends CakeTestCase {
|
|||
$params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding);
|
||||
|
||||
$result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet);
|
||||
$this->assertPattern('/^SELECT\s+' .
|
||||
'`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+'.
|
||||
'FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+' .
|
||||
'`TestModel6`.`test_model5_id`\s+IN\s+\({\$__cakeID__\$}\)\s*'.
|
||||
'LIMIT \d*'.
|
||||
'\s*$/', $result);
|
||||
$this->assertPattern(
|
||||
'/^SELECT\s+' .
|
||||
'`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+'.
|
||||
'FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+' .
|
||||
'`TestModel6`.`test_model5_id`\s+IN\s+\({\$__cakeID__\$}\)\s*'.
|
||||
'LIMIT \d*'.
|
||||
'\s*$/', $result
|
||||
);
|
||||
|
||||
$result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null);
|
||||
$this->assertPattern('/^SELECT\s+'.
|
||||
'`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+'.
|
||||
'FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+'.
|
||||
'(?:\()?\s*1 = 1\s*(?:\))?'.
|
||||
'\s*$/', $result);
|
||||
$this->assertPattern(
|
||||
'/^SELECT\s+'.
|
||||
'`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+'.
|
||||
'FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+'.
|
||||
'(?:\()?\s*1 = 1\s*(?:\))?'.
|
||||
'\s*$/', $result
|
||||
);
|
||||
}
|
||||
/**
|
||||
* testGenerateAssociationQueryHasManyWithConditions method
|
||||
|
@ -2502,6 +2498,11 @@ class DboSourceTest extends CakeTestCase {
|
|||
$result = $this->testDb->conditions(array("Book.id" => NULL));
|
||||
$expected = " WHERE `Book`.`id` IS NULL";
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
pr($this->testDb->conditions(array(
|
||||
'User.id > 1',
|
||||
'User.user = "User.user is the message body"',
|
||||
)));
|
||||
}
|
||||
/**
|
||||
* testMixedConditionsParsing method
|
||||
|
@ -2642,359 +2643,356 @@ class DboSourceTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testMergeAssociations() {
|
||||
$data = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
'Topic' => array(
|
||||
array('id' => '1', 'topic' => 'Topic', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Topic' => array(
|
||||
'id' => '1', 'topic' => 'Topic', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Topic', 'hasOne');
|
||||
$this->assertEqual($data, $expected);
|
||||
function testMergeAssociations() {
|
||||
$data = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
'Topic' => array(
|
||||
array('id' => '1', 'topic' => 'Topic', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Topic' => array(
|
||||
'id' => '1', 'topic' => 'Topic', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Topic', 'hasOne');
|
||||
$this->assertEqual($data, $expected);
|
||||
|
||||
$data = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
'User2' => array(
|
||||
array('id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'User2', 'belongsTo');
|
||||
$this->assertEqual($data, $expected);
|
||||
$data = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
'User2' => array(
|
||||
array('id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'User2', 'belongsTo');
|
||||
$this->assertEqual($data, $expected);
|
||||
|
||||
$data = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(array('Comment' => false));
|
||||
$expected = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Comment' => array()
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Comment', 'hasMany');
|
||||
$this->assertEqual($data, $expected);
|
||||
$data = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(array('Comment' => false));
|
||||
$expected = array(
|
||||
'Article2' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Comment' => array()
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Comment', 'hasMany');
|
||||
$this->assertEqual($data, $expected);
|
||||
|
||||
$data = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
array(
|
||||
'Comment' => array(
|
||||
'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Comment' => array(
|
||||
'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Comment' => array(
|
||||
array(
|
||||
'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
array(
|
||||
'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Comment', 'hasMany');
|
||||
$this->assertEqual($data, $expected);
|
||||
$data = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
array(
|
||||
'Comment' => array(
|
||||
'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Comment' => array(
|
||||
'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Comment' => array(
|
||||
array(
|
||||
'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
array(
|
||||
'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Comment', 'hasMany');
|
||||
$this->assertEqual($data, $expected);
|
||||
|
||||
$data = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
array(
|
||||
'Comment' => array(
|
||||
'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Comment' => array(
|
||||
'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Comment' => array(
|
||||
array(
|
||||
'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31',
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31',
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Comment', 'hasMany');
|
||||
$this->assertEqual($data, $expected);
|
||||
$data = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
array(
|
||||
'Comment' => array(
|
||||
'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Comment' => array(
|
||||
'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Comment' => array(
|
||||
array(
|
||||
'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31',
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31',
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Comment', 'hasMany');
|
||||
$this->assertEqual($data, $expected);
|
||||
|
||||
$data = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
array(
|
||||
'Comment' => array(
|
||||
'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'Tag' => array(
|
||||
array('id' => 1, 'tag' => 'Tag 1'),
|
||||
array('id' => 2, 'tag' => 'Tag 2')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Comment' => array(
|
||||
'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'Tag' => array()
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Comment' => array(
|
||||
array(
|
||||
'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31',
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'Tag' => array(
|
||||
array('id' => 1, 'tag' => 'Tag 1'),
|
||||
array('id' => 2, 'tag' => 'Tag 2')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31',
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'Tag' => array()
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Comment', 'hasMany');
|
||||
$this->assertEqual($data, $expected);
|
||||
$data = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
array(
|
||||
'Comment' => array(
|
||||
'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'Tag' => array(
|
||||
array('id' => 1, 'tag' => 'Tag 1'),
|
||||
array('id' => 2, 'tag' => 'Tag 2')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Comment' => array(
|
||||
'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'Tag' => array()
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Comment' => array(
|
||||
array(
|
||||
'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31',
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'Tag' => array(
|
||||
array('id' => 1, 'tag' => 'Tag 1'),
|
||||
array('id' => 2, 'tag' => 'Tag 2')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31',
|
||||
'User2' => array(
|
||||
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
'Tag' => array()
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Comment', 'hasMany');
|
||||
$this->assertEqual($data, $expected);
|
||||
|
||||
$data = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
array(
|
||||
'Tag' => array(
|
||||
'id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Tag' => array(
|
||||
'id' => '2', 'tag' => 'Tag 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Tag' => array(
|
||||
'id' => '3', 'tag' => 'Tag 3', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Tag' => array(
|
||||
array(
|
||||
'id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
array(
|
||||
'id' => '2', 'tag' => 'Tag 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
array(
|
||||
'id' => '3', 'tag' => 'Tag 3', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Tag', 'hasAndBelongsToMany');
|
||||
$this->assertEqual($data, $expected);
|
||||
$data = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
array(
|
||||
'Tag' => array(
|
||||
'id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Tag' => array(
|
||||
'id' => '2', 'tag' => 'Tag 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Tag' => array(
|
||||
'id' => '3', 'tag' => 'Tag 3', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Tag' => array(
|
||||
array(
|
||||
'id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
array(
|
||||
'id' => '2', 'tag' => 'Tag 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
),
|
||||
array(
|
||||
'id' => '3', 'tag' => 'Tag 3', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Tag', 'hasAndBelongsToMany');
|
||||
$this->assertEqual($data, $expected);
|
||||
|
||||
$data = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
array(
|
||||
'Tag' => array(
|
||||
'id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Tag' => array(
|
||||
'id' => '2', 'tag' => 'Tag 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Tag' => array(
|
||||
'id' => '3', 'tag' => 'Tag 3', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Tag' => array('id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Tag', 'hasOne');
|
||||
$this->assertEqual($data, $expected);
|
||||
}
|
||||
$data = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
)
|
||||
);
|
||||
$merge = array(
|
||||
array(
|
||||
'Tag' => array(
|
||||
'id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Tag' => array(
|
||||
'id' => '2', 'tag' => 'Tag 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Tag' => array(
|
||||
'id' => '3', 'tag' => 'Tag 3', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
|
||||
)
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'Article' => array(
|
||||
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
|
||||
),
|
||||
'Tag' => array('id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')
|
||||
);
|
||||
$this->testDb->__mergeAssociation($data, $merge, 'Tag', 'hasOne');
|
||||
$this->assertEqual($data, $expected);
|
||||
}
|
||||
/**
|
||||
* testRenderStatement method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testRenderStatement() {
|
||||
function testRenderStatement() {
|
||||
$result = $this->testDb->renderStatement('select', array(
|
||||
'fields' => 'id', 'table' => 'table', 'conditions' => 'WHERE 1=1',
|
||||
'alias' => '', 'joins' => '', 'order' => '', 'limit' => '', 'group' => ''
|
||||
));
|
||||
$this->assertPattern('/^\s*SELECT\s+id\s+FROM\s+table\s+WHERE\s+1=1\s*$/', $result);
|
||||
$this->assertPattern('/^\s*SELECT\s+id\s+FROM\s+table\s+WHERE\s+1=1\s*$/', $result);
|
||||
|
||||
$result = $this->testDb->renderStatement('update', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => ''));
|
||||
$this->assertPattern('/^\s*UPDATE\s+table\s+SET\s+value=2\s+WHERE\s+1=1\s*$/', $result);
|
||||
$result = $this->testDb->renderStatement('update', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => ''));
|
||||
$this->assertPattern('/^\s*UPDATE\s+table\s+SET\s+value=2\s+WHERE\s+1=1\s*$/', $result);
|
||||
|
||||
$result = $this->testDb->renderStatement('update', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => 'alias', 'joins' => ''));
|
||||
$this->assertPattern('/^\s*UPDATE\s+table\s+AS\s+alias\s+SET\s+value=2\s+WHERE\s+1=1\s*$/', $result);
|
||||
$result = $this->testDb->renderStatement('update', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => 'alias', 'joins' => ''));
|
||||
$this->assertPattern('/^\s*UPDATE\s+table\s+AS\s+alias\s+SET\s+value=2\s+WHERE\s+1=1\s*$/', $result);
|
||||
|
||||
$result = $this->testDb->renderStatement('delete', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => ''));
|
||||
$this->assertPattern('/^\s*DELETE\s+FROM\s+table\s+WHERE\s+1=1\s*$/', $result);
|
||||
$result = $this->testDb->renderStatement('delete', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => ''));
|
||||
$this->assertPattern('/^\s*DELETE\s+FROM\s+table\s+WHERE\s+1=1\s*$/', $result);
|
||||
|
||||
$result = $this->testDb->renderStatement('delete', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => 'alias', 'joins' => ''));
|
||||
$this->assertPattern('/^\s*DELETE\s+alias\s+FROM\s+table\s+AS\s+alias\s+WHERE\s+1=1\s*$/', $result);
|
||||
}
|
||||
$result = $this->testDb->renderStatement('delete', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => 'alias', 'joins' => ''));
|
||||
$this->assertPattern('/^\s*DELETE\s+alias\s+FROM\s+table\s+AS\s+alias\s+WHERE\s+1=1\s*$/', $result);
|
||||
}
|
||||
/**
|
||||
* testStatements method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testStatements() {
|
||||
$Article =& ClassRegistry::init('Article');
|
||||
function testStatements() {
|
||||
$Article =& ClassRegistry::init('Article');
|
||||
|
||||
$result = $this->testDb->update($Article, array('field1'), array('value1'));
|
||||
$this->assertFalse($result);
|
||||
$result = $this->testDb->getLastQuery();
|
||||
$this->assertPattern('/^\s*UPDATE\s+' . $this->testDb->fullTableName('articles') . '\s+SET\s+`field1`\s*=\s*\'value1\'\s+WHERE\s+1 = 1\s*$/', $result);
|
||||
$result = $this->testDb->update($Article, array('field1'), array('value1'));
|
||||
$this->assertFalse($result);
|
||||
$result = $this->testDb->getLastQuery();
|
||||
$this->assertPattern('/^\s*UPDATE\s+' . $this->testDb->fullTableName('articles') . '\s+SET\s+`field1`\s*=\s*\'value1\'\s+WHERE\s+1 = 1\s*$/', $result);
|
||||
|
||||
$result = $this->testDb->update($Article, array('field1'), array('2'), '2=2');
|
||||
$this->assertFalse($result);
|
||||
$result = $this->testDb->getLastQuery();
|
||||
$this->assertPattern('/^\s*UPDATE\s+' . $this->testDb->fullTableName('articles') . ' AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+SET\s+`Article`\.`field1`\s*=\s*2\s+WHERE\s+2\s*=\s*2\s*$/', $result);
|
||||
$result = $this->testDb->update($Article, array('field1'), array('2'), '2=2');
|
||||
$this->assertFalse($result);
|
||||
$result = $this->testDb->getLastQuery();
|
||||
$this->assertPattern('/^\s*UPDATE\s+' . $this->testDb->fullTableName('articles') . ' AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+SET\s+`Article`\.`field1`\s*=\s*2\s+WHERE\s+2\s*=\s*2\s*$/', $result);
|
||||
|
||||
$result = $this->testDb->delete($Article);
|
||||
$this->assertTrue($result);
|
||||
$result = $this->testDb->getLastQuery();
|
||||
$this->assertPattern('/^\s*DELETE\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+WHERE\s+1 = 1\s*$/', $result);
|
||||
$result = $this->testDb->delete($Article);
|
||||
$this->assertTrue($result);
|
||||
$result = $this->testDb->getLastQuery();
|
||||
$this->assertPattern('/^\s*DELETE\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+WHERE\s+1 = 1\s*$/', $result);
|
||||
|
||||
$result = $this->testDb->delete($Article, true);
|
||||
$this->assertTrue($result);
|
||||
$result = $this->testDb->getLastQuery();
|
||||
$this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+1\s*=\s*1\s*$/', $result);
|
||||
$result = $this->testDb->delete($Article, true);
|
||||
$this->assertTrue($result);
|
||||
$result = $this->testDb->getLastQuery();
|
||||
$this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+1\s*=\s*1\s*$/', $result);
|
||||
|
||||
$result = $this->testDb->delete($Article, '2=2');
|
||||
$this->assertTrue($result);
|
||||
$result = $this->testDb->getLastQuery();
|
||||
$this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+2\s*=\s*2\s*$/', $result);
|
||||
$result = $this->testDb->delete($Article, '2=2');
|
||||
$this->assertTrue($result);
|
||||
$result = $this->testDb->getLastQuery();
|
||||
$this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+2\s*=\s*2\s*$/', $result);
|
||||
|
||||
$result = $this->testDb->hasAny($Article, '1=2');
|
||||
$this->assertFalse($result);
|
||||
$result = $this->testDb->hasAny($Article, '1=2');
|
||||
$this->assertFalse($result);
|
||||
|
||||
$result = $this->testDb->insertMulti('articles', array('field'), array('(1)', '(2)'));
|
||||
$this->assertFalse($result);
|
||||
$result = $this->testDb->getLastQuery();
|
||||
$this->assertPattern('/^\s*INSERT INTO\s+' . $this->testDb->fullTableName('articles') . '\s+\(`field`\)\s+VALUES\s+\(1\),\s*\(2\)\s*$/', $result);
|
||||
}
|
||||
$result = $this->testDb->insertMulti('articles', array('field'), array('(1)', '(2)'));
|
||||
$this->assertFalse($result);
|
||||
$result = $this->testDb->getLastQuery();
|
||||
$this->assertPattern('/^\s*INSERT INTO\s+' . $this->testDb->fullTableName('articles') . '\s+\(`field`\)\s+VALUES\s+\(1\),\s*\(2\)\s*$/', $result);
|
||||
}
|
||||
/**
|
||||
* testSchema method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testSchema() {
|
||||
$Schema =& new CakeSchema();
|
||||
$Schema->tables = array(
|
||||
'table' => array(),
|
||||
'anotherTable' => array()
|
||||
);
|
||||
function testSchema() {
|
||||
$Schema =& new CakeSchema();
|
||||
$Schema->tables = array('table' => array(), 'anotherTable' => array());
|
||||
|
||||
$this->expectError();
|
||||
$result = $this->testDb->dropSchema(null);
|
||||
$this->assertTrue($result === null);
|
||||
$this->expectError();
|
||||
$result = $this->testDb->dropSchema(null);
|
||||
$this->assertTrue($result === null);
|
||||
|
||||
$result = $this->testDb->dropSchema($Schema, 'non_existing');
|
||||
$this->assertTrue(empty($result));
|
||||
$result = $this->testDb->dropSchema($Schema, 'non_existing');
|
||||
$this->assertTrue(empty($result));
|
||||
|
||||
$result = $this->testDb->dropSchema($Schema, 'table');
|
||||
$this->assertPattern('/^\s*DROP TABLE IF EXISTS\s+' . $this->testDb->fullTableName('table') . ';\s*$/s', $result);
|
||||
}
|
||||
$result = $this->testDb->dropSchema($Schema, 'table');
|
||||
$this->assertPattern('/^\s*DROP TABLE IF EXISTS\s+' . $this->testDb->fullTableName('table') . ';\s*$/s', $result);
|
||||
}
|
||||
/**
|
||||
* testMagicMethodQuerying method
|
||||
*
|
||||
|
|
|
@ -268,7 +268,7 @@ class AclNodeTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testNode(){
|
||||
function testNode() {
|
||||
$Aco = new DbAcoTest();
|
||||
$result = Set::extract($Aco->node('Controller1'), '{n}.DbAcoTest.id');
|
||||
$expected = array(2, 1);
|
||||
|
|
|
@ -4721,7 +4721,7 @@ class ModelTest extends CakeTestCase {
|
|||
$this->assertEqual($currentCount, 3);
|
||||
$data = array('UnderscoreField' => array(
|
||||
'user_id' => '1',
|
||||
'my_model_has_a_field' => 'Content here',
|
||||
'my_model_has_a_field' => 'Content here',
|
||||
'body' => 'Body',
|
||||
'published' => 'Y',
|
||||
'another_field' => 4
|
||||
|
|
|
@ -80,28 +80,28 @@ class TestAlias extends Model {
|
|||
* @var bool false
|
||||
* @access public
|
||||
*/
|
||||
var $useTable = false;
|
||||
var $useTable = false;
|
||||
/**
|
||||
* name property
|
||||
*
|
||||
* @var string 'TestAlias'
|
||||
* @access public
|
||||
*/
|
||||
var $name = 'TestAlias';
|
||||
var $name = 'TestAlias';
|
||||
/**
|
||||
* alias property
|
||||
*
|
||||
* @var string 'TestAlias'
|
||||
* @access public
|
||||
*/
|
||||
var $alias = 'TestAlias';
|
||||
var $alias = 'TestAlias';
|
||||
/**
|
||||
* schema property
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
var $_schema = array(
|
||||
var $_schema = array(
|
||||
'id'=> array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key'=>'primary'),
|
||||
'name'=> array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
|
||||
'email'=> array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
|
||||
|
@ -1876,7 +1876,7 @@ class Product extends CakeTestModel {
|
|||
* @var string 'Product'
|
||||
* @access public
|
||||
*/
|
||||
var $name = 'Product';
|
||||
var $name = 'Product';
|
||||
}
|
||||
/**
|
||||
* Short description for class.
|
||||
|
|
|
@ -225,9 +225,9 @@ class ObjectTest extends UnitTestCase {
|
|||
$this->assertPattern('/^\)$/', $result[4]);
|
||||
unlink(LOGS . 'error.log');
|
||||
|
||||
@unlink(LOGS . 'error.log');
|
||||
$this->assertTrue($this->object->log('Test warning 1', LOG_WARNING));
|
||||
$this->assertTrue($this->object->log(array('Test' => 'warning 2'), LOG_WARNING));
|
||||
@unlink(LOGS . 'error.log');
|
||||
$this->assertTrue($this->object->log('Test warning 1', LOG_WARNING));
|
||||
$this->assertTrue($this->object->log(array('Test' => 'warning 2'), LOG_WARNING));
|
||||
$result = file(LOGS . 'error.log');
|
||||
$this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning 1$/', $result[0]);
|
||||
$this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Array$/', $result[1]);
|
||||
|
@ -235,45 +235,45 @@ class ObjectTest extends UnitTestCase {
|
|||
$this->assertPattern('/\[Test\] => warning 2$/', $result[3]);
|
||||
$this->assertPattern('/^\)$/', $result[4]);
|
||||
unlink(LOGS . 'error.log');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* testSet method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testSet() {
|
||||
$this->object->_set('a string');
|
||||
$this->assertEqual($this->object->firstName, 'Joel');
|
||||
function testSet() {
|
||||
$this->object->_set('a string');
|
||||
$this->assertEqual($this->object->firstName, 'Joel');
|
||||
|
||||
$this->object->_set(array('firstName'));
|
||||
$this->assertEqual($this->object->firstName, 'Joel');
|
||||
$this->object->_set(array('firstName'));
|
||||
$this->assertEqual($this->object->firstName, 'Joel');
|
||||
|
||||
$this->object->_set(array('firstName' => 'Ashley'));
|
||||
$this->assertEqual($this->object->firstName, 'Ashley');
|
||||
$this->object->_set(array('firstName' => 'Ashley'));
|
||||
$this->assertEqual($this->object->firstName, 'Ashley');
|
||||
|
||||
$this->object->_set(array('firstName' => 'Joel', 'lastName' => 'Moose'));
|
||||
$this->assertEqual($this->object->firstName, 'Joel');
|
||||
$this->assertEqual($this->object->lastName, 'Moose');
|
||||
}
|
||||
$this->object->_set(array('firstName' => 'Joel', 'lastName' => 'Moose'));
|
||||
$this->assertEqual($this->object->firstName, 'Joel');
|
||||
$this->assertEqual($this->object->lastName, 'Moose');
|
||||
}
|
||||
/**
|
||||
* testPersist method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testPersist() {
|
||||
@unlink(CACHE . 'persistent' . DS . 'testmodel.php');
|
||||
function testPersist() {
|
||||
@unlink(CACHE . 'persistent' . DS . 'testmodel.php');
|
||||
|
||||
$this->assertFalse($this->object->_persist('TestModel', null, $test));
|
||||
$this->assertFalse($this->object->_persist('TestModel', true, $test));
|
||||
$this->assertTrue($this->object->_persist('TestModel', null, $test));
|
||||
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'testmodel.php'));
|
||||
$this->assertTrue($this->object->_persist('TestModel', true, $test));
|
||||
$this->assertNull($this->object->TestModel);
|
||||
$this->assertFalse($this->object->_persist('TestModel', null, $test));
|
||||
$this->assertFalse($this->object->_persist('TestModel', true, $test));
|
||||
$this->assertTrue($this->object->_persist('TestModel', null, $test));
|
||||
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'testmodel.php'));
|
||||
$this->assertTrue($this->object->_persist('TestModel', true, $test));
|
||||
$this->assertNull($this->object->TestModel);
|
||||
|
||||
@unlink(CACHE . 'persistent' . DS . 'testmodel.php');
|
||||
}
|
||||
@unlink(CACHE . 'persistent' . DS . 'testmodel.php');
|
||||
}
|
||||
/**
|
||||
* testToString method
|
||||
*
|
||||
|
@ -356,7 +356,7 @@ class ObjectTest extends UnitTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testRequestAction(){
|
||||
function testRequestAction() {
|
||||
$result = $this->object->requestAction('');
|
||||
$this->assertFalse($result);
|
||||
|
||||
|
|
|
@ -420,10 +420,7 @@ class RouterTest extends UnitTestCase {
|
|||
|
||||
Router::reload();
|
||||
Router::connect('/:language/pages',
|
||||
array(
|
||||
'controller' => 'pages',
|
||||
'action' => 'index'
|
||||
),
|
||||
array('controller' => 'pages', 'action' => 'index'),
|
||||
array('language' => '[a-z]{3}')
|
||||
);
|
||||
|
||||
|
|
|
@ -339,9 +339,9 @@ class SanitizeTest extends CakeTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
|
||||
$string = '<img src="http://google.com/images/logo.gif" onload="window.location=\'http://sam.com/\'" />'."\n".
|
||||
"<p>This is ok \t\n text</p>\n".
|
||||
'<link rel="stylesheet" href="/css/master.css" type="text/css" media="screen" title="my sheet" charset="utf-8">'."\n".
|
||||
'<script src="xss.js" type="text/javascript" charset="utf-8"></script>';
|
||||
"<p>This is ok \t\n text</p>\n".
|
||||
'<link rel="stylesheet" href="/css/master.css" type="text/css" media="screen" title="my sheet" charset="utf-8">'."\n".
|
||||
'<script src="xss.js" type="text/javascript" charset="utf-8"></script>';
|
||||
$expected = '<p>This is ok text</p>';
|
||||
$result = Sanitize::stripAll($string);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
@ -388,36 +388,35 @@ class SanitizeTest extends CakeTestCase {
|
|||
);
|
||||
$this->DataTest->set($data);
|
||||
$expected = array('DataTest' => array(
|
||||
'id' => '0',
|
||||
'count' => '12',
|
||||
'float' => 2.31456,
|
||||
'updated' => '2008-01-01 00:00:00',
|
||||
)
|
||||
);
|
||||
Sanitize::formatColumns($this->DataTest);
|
||||
'id' => '0',
|
||||
'count' => '12',
|
||||
'float' => 2.31456,
|
||||
'updated' => '2008-01-01 00:00:00',
|
||||
));
|
||||
Sanitize::formatColumns($this->DataTest);
|
||||
$result = $this->DataTest->data;
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Article =& new Article();
|
||||
$data = array('Article' => array(
|
||||
'id' => 'ZB',
|
||||
'user_id' => '12',
|
||||
'title' => 'title of article',
|
||||
'body' => 'body text',
|
||||
'published' => 'QQQQQQQ',
|
||||
));
|
||||
'id' => 'ZB',
|
||||
'user_id' => '12',
|
||||
'title' => 'title of article',
|
||||
'body' => 'body text',
|
||||
'published' => 'QQQQQQQ',
|
||||
));
|
||||
$this->Article->set($data);
|
||||
$expected = array('Article' => array(
|
||||
'id' => '0',
|
||||
'user_id' => '12',
|
||||
'title' => 'title of article',
|
||||
'body' => 'body text',
|
||||
'published' => 'QQQQQQQ',
|
||||
));
|
||||
'id' => '0',
|
||||
'user_id' => '12',
|
||||
'title' => 'title of article',
|
||||
'body' => 'body text',
|
||||
'published' => 'QQQQQQQ',
|
||||
));
|
||||
Sanitize::formatColumns($this->Article);
|
||||
$result = $this->Article->data;
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -150,4 +150,5 @@ class SecurityTest extends UnitTestCase {
|
|||
$this->assertIdentical($result, '');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -698,7 +698,7 @@ class SetTest extends UnitTestCase {
|
|||
$expected = array('20 sales', '2 sales');
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
$a = array(
|
||||
$a = array(
|
||||
'pages' => array('name' => 'page'),
|
||||
'fruites' => array('name' => 'fruit'),
|
||||
0 => array('name' => 'zero')
|
||||
|
@ -731,7 +731,7 @@ class SetTest extends UnitTestCase {
|
|||
$this->assertIdentical($result, $expected);
|
||||
|
||||
$result = Set::extract($a,'{n}.{\w+}.name');
|
||||
$expected = array(array('pages' => 'page'), array('fruites' => 'fruit'));
|
||||
$expected = array(array('pages' => 'page'), array('fruites' => 'fruit'));
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
$result = Set::extract($a,'{s}.{\d+}.name');
|
||||
|
@ -793,10 +793,10 @@ class SetTest extends UnitTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testCombine() {
|
||||
$result = Set::combine(array(), '{n}.User.id', '{n}.User.Data');
|
||||
$this->assertFalse($result);
|
||||
$result = Set::combine('', '{n}.User.id', '{n}.User.Data');
|
||||
$this->assertFalse($result);
|
||||
$result = Set::combine(array(), '{n}.User.id', '{n}.User.Data');
|
||||
$this->assertFalse($result);
|
||||
$result = Set::combine('', '{n}.User.id', '{n}.User.Data');
|
||||
$this->assertFalse($result);
|
||||
|
||||
$a = array(
|
||||
array('User' => array('id' => 2, 'group_id' => 1,
|
||||
|
|
|
@ -1261,7 +1261,6 @@ class FormHelperTest extends CakeTestCase {
|
|||
'Badness!',
|
||||
'/span'
|
||||
);
|
||||
// debug($result);exit;
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('Model.field', array('div' => array('tag' => 'span'), 'error' => array('wrap' => false)));
|
||||
|
@ -4138,6 +4137,94 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
function testBrokenness() {
|
||||
/*
|
||||
* #4 This test has two parents and four children. By default (as of r7117) both
|
||||
* parents are show but the first parent is missing a child. This is the inconsistency in the
|
||||
* default behaviour - one parent has all children, the other does not - dependent on the data values.
|
||||
*/
|
||||
$result = $this->Form->select('Model.field', array(
|
||||
'Fred' => array(
|
||||
'freds_son_1' => 'Fred',
|
||||
'freds_son_2' => 'Freddie'
|
||||
),
|
||||
'Bert' => array(
|
||||
'berts_son_1' => 'Albert',
|
||||
'berts_son_2' => 'Bertie')
|
||||
),
|
||||
null,
|
||||
array(),
|
||||
false
|
||||
);
|
||||
|
||||
$expected = array(
|
||||
'select' => array('name' => 'data[Model][field]', 'id' => 'ModelField'),
|
||||
array('optgroup' => array('label' => 'Fred')),
|
||||
array('option' => array('value' => 'freds_son_1')),
|
||||
'Fred',
|
||||
'/option',
|
||||
array('option' => array('value' => 'freds_son_2')),
|
||||
'Freddie',
|
||||
'/option',
|
||||
'/optgroup',
|
||||
array('optgroup' => array('label' => 'Bert')),
|
||||
array('option' => array('value' => 'berts_son_1')),
|
||||
'Albert',
|
||||
'/option',
|
||||
array('option' => array('value' => 'berts_son_2')),
|
||||
'Bertie',
|
||||
'/option',
|
||||
'/optgroup',
|
||||
'/select'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
/*
|
||||
* #2 This is structurally identical to the test above (#1) - only the parent name has changed, so we
|
||||
* should expect the same select list data, just with a different name for the parent.
|
||||
* As of #7117, this test fails because option 3 => 'Three' disappears.
|
||||
* This is where data corruption can occur, because when a select value is missing from a list
|
||||
* a form will substitute the first value in the list - without the user knowing.
|
||||
* If the optgroup name 'Parent' (above) is updated to 'Three' (below), this should not affect
|
||||
* the availability of 3 => 'Three' as a valid option.
|
||||
*/
|
||||
$result = $this->Form->select('Model.field', array(
|
||||
1 => 'One',
|
||||
2 => 'Two',
|
||||
'Three' => array(
|
||||
3 => 'Three',
|
||||
4 => 'Four',
|
||||
5 => 'Five'
|
||||
)
|
||||
),
|
||||
null,
|
||||
array(),
|
||||
false
|
||||
);
|
||||
$expected = array(
|
||||
'select' => array('name' => 'data[Model][field]', 'id' => 'ModelField'),
|
||||
array('option' => array('value' => 1)),
|
||||
'One',
|
||||
'/option',
|
||||
array('option' => array('value' => 2)),
|
||||
'Two',
|
||||
'/option',
|
||||
array('optgroup' => array('label' => 'Three')),
|
||||
array('option' => array('value' => 3)),
|
||||
'Three',
|
||||
'/option',
|
||||
array('option' => array('value' => 4)),
|
||||
'Four',
|
||||
'/option',
|
||||
array('option' => array('value' => 5)),
|
||||
'Five',
|
||||
'/option',
|
||||
'/optgroup',
|
||||
'/select'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
|
|
|
@ -694,7 +694,7 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
$tr = array(
|
||||
'td content 1',
|
||||
array('td content 2', array("width" => "100px")),
|
||||
array('td content 3', "width=100px")
|
||||
array('td content 3', "width=100px")
|
||||
);
|
||||
$result = $this->Html->tableCells($tr);
|
||||
$expected = array(
|
||||
|
@ -729,31 +729,31 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
|
||||
$tr = array(
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3')
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3')
|
||||
);
|
||||
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'));
|
||||
$expected = "<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>";
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$tr = array(
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3')
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3')
|
||||
);
|
||||
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'));
|
||||
$expected = "<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>";
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$tr = array(
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3')
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3'),
|
||||
array('td content 1', 'td content 2', 'td content 3')
|
||||
);
|
||||
$this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'));
|
||||
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'), false, false);
|
||||
$this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'));
|
||||
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'), false, false);
|
||||
$expected = "<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>";
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
@ -763,9 +763,9 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testTag() {
|
||||
$result = $this->Html->tag('div');
|
||||
$this->assertTags($result, '<div');
|
||||
function testTag() {
|
||||
$result = $this->Html->tag('div');
|
||||
$this->assertTags($result, '<div');
|
||||
|
||||
$result = $this->Html->tag('div', 'text');
|
||||
$this->assertTags($result, '<div', 'text', '/div');
|
||||
|
@ -775,7 +775,7 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Html->tag('div', '<text>', 'class-name', true);
|
||||
$this->assertTags($result, array('div' => array('class' => 'class-name'), '<text>', '/div'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* testDiv method
|
||||
*
|
||||
|
|
|
@ -54,7 +54,7 @@ class PaginatorTest extends UnitTestCase {
|
|||
'order' => 'Article.date ASC',
|
||||
'limit' => 9,
|
||||
'conditions' => array()
|
||||
),
|
||||
),
|
||||
'options' => array(
|
||||
'order' => 'Article.date ASC',
|
||||
'limit' => 9,
|
||||
|
@ -324,20 +324,19 @@ class PaginatorTest extends UnitTestCase {
|
|||
$expected = '<span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span> | <span><a href="/index/page:13">13</a></span> | <span class="current">14</span> | <span><a href="/index/page:15">15</a></span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
'page' => 2, 'current' => 3, 'count' => 27, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 9,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
);
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
'page' => 2, 'current' => 3, 'count' => 27, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 9,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
);
|
||||
|
||||
$result = $this->Paginator->numbers(array('first' => 1));
|
||||
$expected = '<span><a href="/index/page:1">1</a></span> | <span class="current">2</span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Paginator->numbers(array('last' => 1));
|
||||
$expected = '<span><a href="/index/page:1">1</a></span> | <span class="current">2</span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
$result = $this->Paginator->numbers(array('first' => 1));
|
||||
$expected = '<span><a href="/index/page:1">1</a></span> | <span class="current">2</span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Paginator->numbers(array('last' => 1));
|
||||
$expected = '<span><a href="/index/page:1">1</a></span> | <span class="current">2</span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
|
@ -347,9 +346,7 @@ class PaginatorTest extends UnitTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 1));
|
||||
$expected = '<span><a href="/index/page:1">1</a></span>...<span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span> | <span><a href="/index/page:13">13</a></span> | <span><a href="/index/page:14">14</a></span> | <span class="current">15</span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
'page' => 10, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
|
@ -358,50 +355,50 @@ class PaginatorTest extends UnitTestCase {
|
|||
);
|
||||
|
||||
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
|
||||
$expected = '<span><a href="/index/page:1">1</a></span>...<span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span class="current">10</span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span> | <span><a href="/index/page:13">13</a></span> | <span><a href="/index/page:14">14</a></span> | <span><a href="/index/page:15">15</a></span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
$expected = '<span><a href="/index/page:1">1</a></span>...<span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span class="current">10</span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span> | <span><a href="/index/page:13">13</a></span> | <span><a href="/index/page:14">14</a></span> | <span><a href="/index/page:15">15</a></span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
'page' => 6, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42,
|
||||
'defaults' => array('limit' => 15, 'step' => 1, 'page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 6, 'limit' => 15, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
);
|
||||
'page' => 6, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42,
|
||||
'defaults' => array('limit' => 15, 'step' => 1, 'page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 6, 'limit' => 15, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
);
|
||||
|
||||
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
|
||||
$expected = '<span><a href="/index/page:1">1</a></span> | <span><a href="/index/page:2">2</a></span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span class="current">6</span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span>...<span><a href="/index/page:42">42</a></span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
|
||||
$expected = '<span><a href="/index/page:1">1</a></span> | <span><a href="/index/page:2">2</a></span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span class="current">6</span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span>...<span><a href="/index/page:42">42</a></span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
'page' => 37, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42,
|
||||
'defaults' => array('limit' => 15, 'step' => 1, 'page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 37, 'limit' => 15, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
);
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
'page' => 37, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42,
|
||||
'defaults' => array('limit' => 15, 'step' => 1, 'page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 37, 'limit' => 15, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
);
|
||||
|
||||
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
|
||||
$expected = '<span><a href="/index/page:1">1</a></span>...<span><a href="/index/page:33">33</a></span> | <span><a href="/index/page:34">34</a></span> | <span><a href="/index/page:35">35</a></span> | <span><a href="/index/page:36">36</a></span> | <span class="current">37</span> | <span><a href="/index/page:38">38</a></span> | <span><a href="/index/page:39">39</a></span> | <span><a href="/index/page:40">40</a></span> | <span><a href="/index/page:41">41</a></span> | <span><a href="/index/page:42">42</a></span>';
|
||||
|
||||
$this->assertEqual($result, $expected);
|
||||
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
|
||||
$expected = '<span><a href="/index/page:1">1</a></span>...<span><a href="/index/page:33">33</a></span> | <span><a href="/index/page:34">34</a></span> | <span><a href="/index/page:35">35</a></span> | <span><a href="/index/page:36">36</a></span> | <span class="current">37</span> | <span><a href="/index/page:38">38</a></span> | <span><a href="/index/page:39">39</a></span> | <span><a href="/index/page:40">40</a></span> | <span><a href="/index/page:41">41</a></span> | <span><a href="/index/page:42">42</a></span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array(
|
||||
'Client' => array(
|
||||
'Client' => array(
|
||||
'page' => 1,
|
||||
'current' => 10,
|
||||
'count' => 30,
|
||||
'prevPage' => false,
|
||||
'nextPage' => 2,
|
||||
'pageCount' => 3,
|
||||
'defaults' => array(
|
||||
'limit' => 3,
|
||||
'step' => 1,
|
||||
'order' => array('Client.name' => 'DESC'),
|
||||
'conditions' => array()
|
||||
),
|
||||
'options' => array(
|
||||
'page' => 1,
|
||||
'current' => 10,
|
||||
'count' => 30,
|
||||
'prevPage' => false,
|
||||
'nextPage' => 2,
|
||||
'pageCount' => 3,
|
||||
'defaults' => array(
|
||||
'limit' => 3,
|
||||
'step' => 1,
|
||||
'order' => array('Client.name' => 'DESC'),
|
||||
'conditions' => array()),
|
||||
'options' => array(
|
||||
'page' => 1,
|
||||
'limit' => 3,
|
||||
'order' => array('Client.name' => 'DESC'),
|
||||
'conditions' => array()
|
||||
)
|
||||
)
|
||||
'limit' => 3,
|
||||
'order' => array('Client.name' => 'DESC'),
|
||||
'conditions' => array()
|
||||
)
|
||||
)
|
||||
);
|
||||
$options = array('modulus' => 10);
|
||||
$result = $this->Paginator->numbers($options);
|
||||
|
@ -466,28 +463,28 @@ class PaginatorTest extends UnitTestCase {
|
|||
*/
|
||||
function testCounter() {
|
||||
$this->Paginator->params['paging'] = array(
|
||||
'Client' => array(
|
||||
'page' => 1,
|
||||
'current' => 3,
|
||||
'count' => 13,
|
||||
'prevPage' => false,
|
||||
'nextPage' => true,
|
||||
'pageCount' => 5,
|
||||
'defaults' => array(
|
||||
'limit' => 3,
|
||||
'step' => 1,
|
||||
'order' => array('Client.name' => 'DESC'),
|
||||
'conditions' => array()
|
||||
),
|
||||
'options' => array(
|
||||
'page' => 1,
|
||||
'limit' => 3,
|
||||
'order' => array('Client.name' => 'DESC'),
|
||||
'conditions' => array(),
|
||||
'separator' => 'of'
|
||||
),
|
||||
)
|
||||
);
|
||||
'Client' => array(
|
||||
'page' => 1,
|
||||
'current' => 3,
|
||||
'count' => 13,
|
||||
'prevPage' => false,
|
||||
'nextPage' => true,
|
||||
'pageCount' => 5,
|
||||
'defaults' => array(
|
||||
'limit' => 3,
|
||||
'step' => 1,
|
||||
'order' => array('Client.name' => 'DESC'),
|
||||
'conditions' => array()
|
||||
),
|
||||
'options' => array(
|
||||
'page' => 1,
|
||||
'limit' => 3,
|
||||
'order' => array('Client.name' => 'DESC'),
|
||||
'conditions' => array(),
|
||||
'separator' => 'of'
|
||||
),
|
||||
)
|
||||
);
|
||||
$input = 'Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%';
|
||||
$result = $this->Paginator->counter($input);
|
||||
$expected = 'Page 1 of 5, showing 3 records out of 13 total, starting on record 1, ending on 3';
|
||||
|
@ -511,7 +508,7 @@ class PaginatorTest extends UnitTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* testHasPage method
|
||||
*
|
||||
* @access public
|
||||
|
|
|
@ -199,7 +199,7 @@ class RssTest extends CakeTestCase {
|
|||
'description' => array(
|
||||
'value' => 'descriptive words',
|
||||
'cdata' => true,
|
||||
),
|
||||
),
|
||||
'pubDate' => '2008-05-31 12:00:00',
|
||||
'guid' => 'http://www.example.com/1'
|
||||
);
|
||||
|
|
|
@ -125,15 +125,15 @@ class TextTest extends UnitTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testHighlightConsiderHtml() {
|
||||
$text1 = '<p>strongbow isn’t real cider</p>';
|
||||
$text2 = '<p>strongbow <strong>isn’t</strong> real cider</p>';
|
||||
$text3 = '<img src="what-a-strong-mouse.png" alt="What a strong mouse!" />';
|
||||
function testHighlightConsiderHtml() {
|
||||
$text1 = '<p>strongbow isn’t real cider</p>';
|
||||
$text2 = '<p>strongbow <strong>isn’t</strong> real cider</p>';
|
||||
$text3 = '<img src="what-a-strong-mouse.png" alt="What a strong mouse!" />';
|
||||
|
||||
$this->assertEqual($this->Text->highlight($text1, 'strong', '<b>\1</b>', true), '<p><b>strong</b>bow isn’t real cider</p>');
|
||||
$this->assertEqual($this->Text->highlight($text2, 'strong', '<b>\1</b>', true), '<p><b>strong</b>bow <strong>isn’t</strong> real cider</p>');
|
||||
$this->assertEqual($this->Text->highlight($text3, 'strong', '<b>\1</b>', true), $text3);
|
||||
}
|
||||
$this->assertEqual($this->Text->highlight($text1, 'strong', '<b>\1</b>', true), '<p><b>strong</b>bow isn’t real cider</p>');
|
||||
$this->assertEqual($this->Text->highlight($text2, 'strong', '<b>\1</b>', true), '<p><b>strong</b>bow <strong>isn’t</strong> real cider</p>');
|
||||
$this->assertEqual($this->Text->highlight($text3, 'strong', '<b>\1</b>', true), $text3);
|
||||
}
|
||||
/**
|
||||
* testStripLinks method
|
||||
*
|
||||
|
|
|
@ -628,7 +628,7 @@ class ViewTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testEntityReference() {
|
||||
function testEntityReference() {
|
||||
$View = new TestView($this->PostsController);
|
||||
$View->model = 'Post';
|
||||
$View->field = 'title';
|
||||
|
@ -637,7 +637,7 @@ class ViewTest extends CakeTestCase {
|
|||
$View->association = 'Comment';
|
||||
$View->field = 'user_id';
|
||||
$this->assertEqual($View->entity(), array('Comment', 'user_id'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* testBadExt method
|
||||
*
|
||||
|
|
17
cake/tests/fixtures/aco_fixture.php
vendored
17
cake/tests/fixtures/aco_fixture.php
vendored
|
@ -63,14 +63,15 @@ class AcoFixture extends CakeTestFixture {
|
|||
*/
|
||||
var $records = array(
|
||||
array('parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT', 'lft' => 1, 'rght' => 18),
|
||||
array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Controller1', 'lft' => 2, 'rght' => 9),
|
||||
array('parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'action1', 'lft' => 3, 'rght' => 6),
|
||||
array('parent_id' => 3, 'model' => null, 'foreign_key' => null, 'alias' => 'record1', 'lft' => 4, 'rght' => 5),
|
||||
array('parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'action2', 'lft' => 7, 'rght' => 8),
|
||||
array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Controller2', 'lft' => 10, 'rght' => 17),
|
||||
array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'action1', 'lft' => 11, 'rght' => 14),
|
||||
array('parent_id' => 7, 'model' => null, 'foreign_key' => null, 'alias' => 'record1', 'lft' => 12, 'rght' => 13),
|
||||
array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'action2', 'lft' => 15, 'rght' => 16),
|
||||
array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Controller1', 'lft' => 2, 'rght' => 9),
|
||||
array('parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'action1', 'lft' => 3, 'rght' => 6),
|
||||
array('parent_id' => 3, 'model' => null, 'foreign_key' => null, 'alias' => 'record1', 'lft' => 4, 'rght' => 5),
|
||||
array('parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'action2', 'lft' => 7, 'rght' => 8),
|
||||
array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Controller2', 'lft' => 10, 'rght' => 17),
|
||||
array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'action1', 'lft' => 11, 'rght' => 14),
|
||||
array('parent_id' => 7, 'model' => null, 'foreign_key' => null, 'alias' => 'record1', 'lft' => 12, 'rght' => 13),
|
||||
array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'action2', 'lft' => 15, 'rght' => 16),
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
20
cake/tests/fixtures/aco_two_fixture.php
vendored
20
cake/tests/fixtures/aco_two_fixture.php
vendored
|
@ -62,16 +62,16 @@ class AcoTwoFixture extends CakeTestFixture {
|
|||
* @access public
|
||||
*/
|
||||
var $records = array(
|
||||
array('id' => 1, 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT', 'lft' => 1, 'rght' => 20),
|
||||
array('id' => 2, 'parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'tpsReports', 'lft' => 2, 'rght' => 9),
|
||||
array('id' => 3, 'parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'view', 'lft' => 3, 'rght' => 6),
|
||||
array('id' => 4, 'parent_id' => 3, 'model' => null, 'foreign_key' => null, 'alias' => 'current', 'lft' => 4, 'rght' => 5),
|
||||
array('id' => 5, 'parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'update', 'lft' => 7, 'rght' => 8),
|
||||
array('id' => 6, 'parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'printers', 'lft' => 10, 'rght' => 19),
|
||||
array('id' => 7, 'parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'print', 'lft' => 11, 'rght' => 14),
|
||||
array('id' => 8, 'parent_id' => 7, 'model' => null, 'foreign_key' => null, 'alias' => 'lettersize','lft' => 12, 'rght' => 13),
|
||||
array('id' => 9, 'parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'refill', 'lft' => 15, 'rght' => 16),
|
||||
array('id' => 10, 'parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'smash', 'lft' => 17, 'rght' => 18),
|
||||
array('parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT', 'lft' => 1, 'rght' => 20),
|
||||
array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'tpsReports', 'lft' => 2, 'rght' => 9),
|
||||
array('parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'view', 'lft' => 3, 'rght' => 6),
|
||||
array('parent_id' => 3, 'model' => null, 'foreign_key' => null, 'alias' => 'current', 'lft' => 4, 'rght' => 5),
|
||||
array('parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'update', 'lft' => 7, 'rght' => 8),
|
||||
array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'printers', 'lft' => 10, 'rght' => 19),
|
||||
array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'print', 'lft' => 11, 'rght' => 14),
|
||||
array('parent_id' => 7, 'model' => null, 'foreign_key' => null, 'alias' => 'lettersize','lft' => 12, 'rght' => 13),
|
||||
array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'refill', 'lft' => 15, 'rght' => 16),
|
||||
array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'smash', 'lft' => 17, 'rght' => 18),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
37
cake/tests/fixtures/ad_fixture.php
vendored
37
cake/tests/fixtures/ad_fixture.php
vendored
|
@ -36,35 +36,36 @@ class AdFixture extends CakeTestFixture {
|
|||
* @var string 'Ad'
|
||||
* @access public
|
||||
*/
|
||||
var $name = 'Ad';
|
||||
var $name = 'Ad';
|
||||
/**
|
||||
* fields property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $fields = array(
|
||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||
'campaign_id' => array('type' => 'integer'),
|
||||
'parent_id' => array('type' => 'integer'),
|
||||
'lft' => array('type' => 'integer'),
|
||||
'rght' => array('type' => 'integer'),
|
||||
'name' => array('type' => 'string', 'length' => 255, 'null' => false),
|
||||
);
|
||||
var $fields = array(
|
||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||
'campaign_id' => array('type' => 'integer'),
|
||||
'parent_id' => array('type' => 'integer'),
|
||||
'lft' => array('type' => 'integer'),
|
||||
'rght' => array('type' => 'integer'),
|
||||
'name' => array('type' => 'string', 'length' => 255, 'null' => false)
|
||||
);
|
||||
/**
|
||||
* records property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $records = array(
|
||||
array( 'id' => 1, 'parent_id' => NULL, 'lft' => 1, 'rght' => 2, 'campaign_id' => 1, 'name' => 'Nordover' ),
|
||||
array( 'id' => 2, 'parent_id' => NULL, 'lft' => 3, 'rght' => 4, 'campaign_id' => 1, 'name' => 'Statbergen' ),
|
||||
array( 'id' => 3, 'parent_id' => NULL, 'lft' => 5, 'rght' => 6, 'campaign_id' => 1, 'name' => 'Feroy' ),
|
||||
array( 'id' => 4, 'parent_id' => NULL, 'lft' => 7, 'rght' => 12, 'campaign_id' => 2, 'name' => 'Newcastle' ),
|
||||
array( 'id' => 5, 'parent_id' => NULL, 'lft' => 8, 'rght' => 9, 'campaign_id' => 2, 'name' => 'Dublin' ),
|
||||
array( 'id' => 6, 'parent_id' => NULL, 'lft' => 10, 'rght' => 11, 'campaign_id' => 2, 'name' => 'Alborg' ),
|
||||
array( 'id' => 7, 'parent_id' => NULL, 'lft' => 13, 'rght' => 14, 'campaign_id' => 3, 'name' => 'New York' ),
|
||||
);
|
||||
var $records = array(
|
||||
array('parent_id' => null, 'lft' => 1, 'rght' => 2, 'campaign_id' => 1, 'name' => 'Nordover'),
|
||||
array('parent_id' => null, 'lft' => 3, 'rght' => 4, 'campaign_id' => 1, 'name' => 'Statbergen'),
|
||||
array('parent_id' => null, 'lft' => 5, 'rght' => 6, 'campaign_id' => 1, 'name' => 'Feroy'),
|
||||
array('parent_id' => null, 'lft' => 7, 'rght' => 12, 'campaign_id' => 2, 'name' => 'Newcastle'),
|
||||
array('parent_id' => null, 'lft' => 8, 'rght' => 9, 'campaign_id' => 2, 'name' => 'Dublin'),
|
||||
array('parent_id' => null, 'lft' => 10, 'rght' => 11, 'campaign_id' => 2, 'name' => 'Alborg'),
|
||||
array('parent_id' => null, 'lft' => 13, 'rght' => 14, 'campaign_id' => 3, 'name' => 'New York')
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
21
cake/tests/fixtures/campaign_fixture.php
vendored
21
cake/tests/fixtures/campaign_fixture.php
vendored
|
@ -36,27 +36,28 @@ class CampaignFixture extends CakeTestFixture {
|
|||
* @var string 'Campaign'
|
||||
* @access public
|
||||
*/
|
||||
var $name = 'Campaign';
|
||||
var $name = 'Campaign';
|
||||
/**
|
||||
* fields property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $fields = array(
|
||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||
'name' => array('type' => 'string', 'length' => 255, 'null' => false),
|
||||
);
|
||||
var $fields = array(
|
||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||
'name' => array('type' => 'string', 'length' => 255, 'null' => false),
|
||||
);
|
||||
/**
|
||||
* records property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $records = array(
|
||||
array( 'id' => 1 , 'name' => 'Hurtigruten' ),
|
||||
array( 'id' => 2 , 'name' => 'Colorline' ),
|
||||
array( 'id' => 3 , 'name' => 'Queen of Scandinavia' )
|
||||
);
|
||||
var $records = array(
|
||||
array('name' => 'Hurtigruten'),
|
||||
array('name' => 'Colorline'),
|
||||
array('name' => 'Queen of Scandinavia')
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
35
cake/tests/fixtures/product_fixture.php
vendored
35
cake/tests/fixtures/product_fixture.php
vendored
|
@ -39,34 +39,35 @@ class ProductFixture extends CakeTestFixture {
|
|||
* @var string 'Product'
|
||||
* @access public
|
||||
*/
|
||||
var $name = 'Product';
|
||||
var $name = 'Product';
|
||||
/**
|
||||
* fields property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $fields = array(
|
||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||
'name' => array('type' => 'string', 'length' => 255, 'null' => false),
|
||||
'type' => array('type' => 'string', 'length' => 255, 'null' => false),
|
||||
'price' => array('type' => 'integer', 'null' => false),
|
||||
);
|
||||
var $fields = array(
|
||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||
'name' => array('type' => 'string', 'length' => 255, 'null' => false),
|
||||
'type' => array('type' => 'string', 'length' => 255, 'null' => false),
|
||||
'price' => array('type' => 'integer', 'null' => false)
|
||||
);
|
||||
/**
|
||||
* records property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $records = array(
|
||||
array( 'id' => 1 , 'name' => 'Park\'s Great Hits', 'type' => 'Music', 'price' => 19 ),
|
||||
array( 'id' => 2 , 'name' => 'Silly Puddy', 'type' => 'Toy', 'price' => 3 ),
|
||||
array( 'id' => 3 , 'name' => 'Playstation', 'type' => 'Toy', 'price' => 89 ),
|
||||
array( 'id' => 4 , 'name' => 'Men\'s T-Shirt', 'type' => 'Clothing', 'price' => 32 ),
|
||||
array( 'id' => 5 , 'name' => 'Blouse', 'type' => 'Clothing', 'price' => 34 ),
|
||||
array( 'id' => 6 , 'name' => 'Electronica 2002', 'type' => 'Music', 'price' => 4 ),
|
||||
array( 'id' => 7 , 'name' => 'Country Tunes', 'type' => 'Music', 'price' => 21 ),
|
||||
array( 'id' => 8 , 'name' => 'Watermelon', 'type' => 'Food', 'price' => 9 ),
|
||||
);
|
||||
var $records = array(
|
||||
array('name' => 'Park\'s Great Hits', 'type' => 'Music', 'price' => 19),
|
||||
array('name' => 'Silly Puddy', 'type' => 'Toy', 'price' => 3),
|
||||
array('name' => 'Playstation', 'type' => 'Toy', 'price' => 89),
|
||||
array('name' => 'Men\'s T-Shirt', 'type' => 'Clothing', 'price' => 32),
|
||||
array('name' => 'Blouse', 'type' => 'Clothing', 'price' => 34),
|
||||
array('name' => 'Electronica 2002', 'type' => 'Music', 'price' => 4),
|
||||
array('name' => 'Country Tunes', 'type' => 'Music', 'price' => 21),
|
||||
array('name' => 'Watermelon', 'type' => 'Food', 'price' => 9)
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
38
cake/tests/fixtures/translate_fixture.php
vendored
38
cake/tests/fixtures/translate_fixture.php
vendored
|
@ -68,23 +68,25 @@ class TranslateFixture extends CakeTestFixture {
|
|||
* @access public
|
||||
*/
|
||||
var $records = array(
|
||||
array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Title #1'),
|
||||
array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Content #1'),
|
||||
array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titel #1'),
|
||||
array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Inhalt #1'),
|
||||
array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titulek #1'),
|
||||
array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Obsah #1'),
|
||||
array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Title #2'),
|
||||
array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'content', 'content' => 'Content #2'),
|
||||
array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Titel #2'),
|
||||
array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'content', 'content' => 'Inhalt #2'),
|
||||
array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Titulek #2'),
|
||||
array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'content', 'content' => 'Obsah #2'),
|
||||
array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'title', 'content' => 'Title #3'),
|
||||
array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'content', 'content' => 'Content #3'),
|
||||
array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'title', 'content' => 'Titel #3'),
|
||||
array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'content', 'content' => 'Inhalt #3'),
|
||||
array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'title', 'content' => 'Titulek #3'),
|
||||
array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'content', 'content' => 'Obsah #3'));
|
||||
array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Title #1'),
|
||||
array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Content #1'),
|
||||
array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titel #1'),
|
||||
array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Inhalt #1'),
|
||||
array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titulek #1'),
|
||||
array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Obsah #1'),
|
||||
array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Title #2'),
|
||||
array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'content', 'content' => 'Content #2'),
|
||||
array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Titel #2'),
|
||||
array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'content', 'content' => 'Inhalt #2'),
|
||||
array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Titulek #2'),
|
||||
array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'content', 'content' => 'Obsah #2'),
|
||||
array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'title', 'content' => 'Title #3'),
|
||||
array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'content', 'content' => 'Content #3'),
|
||||
array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'title', 'content' => 'Titel #3'),
|
||||
array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'content', 'content' => 'Inhalt #3'),
|
||||
array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'title', 'content' => 'Titulek #3'),
|
||||
array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'content', 'content' => 'Obsah #3')
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -27,15 +27,14 @@
|
|||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
if (! defined('ST_FAILDETAIL_SEPARATOR')) {
|
||||
define('ST_FAILDETAIL_SEPARATOR', "->");
|
||||
define('ST_FAILDETAIL_SEPARATOR', "->");
|
||||
}
|
||||
|
||||
if (version_compare(phpversion(), '4.4.4', '<=') ||
|
||||
php_sapi_name() == 'cgi') {
|
||||
define('STDOUT', fopen('php://stdout', 'w'));
|
||||
define('STDERR', fopen('php://stderr', 'w'));
|
||||
register_shutdown_function(
|
||||
create_function('', 'fclose(STDOUT); fclose(STDERR); return true;'));
|
||||
php_sapi_name() == 'cgi') {
|
||||
define('STDOUT', fopen('php://stdout', 'w'));
|
||||
define('STDERR', fopen('php://stderr', 'w'));
|
||||
register_shutdown_function(create_function('', 'fclose(STDOUT); fclose(STDERR); return true;'));
|
||||
}
|
||||
/**
|
||||
* Minimal command line test displayer. Writes fail details to STDERR. Returns 0
|
||||
|
|
|
@ -30,7 +30,7 @@ class TestsAppsController extends AppController {
|
|||
var $name = 'TestsApps';
|
||||
var $uses = array();
|
||||
|
||||
function index(){
|
||||
function index() {
|
||||
}
|
||||
|
||||
function some_method() {
|
||||
|
|
|
@ -30,7 +30,7 @@ class TestsPluginsTestsController extends AppController {
|
|||
var $name = 'TestsPluginsTests';
|
||||
var $uses = array();
|
||||
|
||||
function index(){
|
||||
function index() {
|
||||
}
|
||||
|
||||
function some_method() {
|
||||
|
|
Loading…
Reference in a new issue