mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing TreeBehavior so tests will work on php 4.
Removing _ _METHOD_ _ from files since it is not valid on php 4 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5337 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
15c8d5012e
commit
b7ba57c8b1
3 changed files with 15 additions and 57 deletions
|
@ -128,7 +128,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
$parentNode = $model->find(array($scope, $model->escapeField() => $model->data[$model->name][$parent]),
|
$parentNode = $model->find(array($scope, $model->escapeField() => $model->data[$model->name][$parent]),
|
||||||
array($model->primaryKey), null, -1);
|
array($model->primaryKey), null, -1);
|
||||||
if (!$parentNode) {
|
if (!$parentNode) {
|
||||||
trigger_error(__('Trying to save a node under a none-existant node in ' . __METHOD__, E_USER_WARNING));
|
trigger_error(__('Trying to save a node under a none-existant node in TreeBehavior::beforeSave', E_USER_WARNING));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,16 +142,16 @@ class TreeBehavior extends ModelBehavior {
|
||||||
$parentNode = $model->find(array($scope, $model->escapeField() => $model->data[$model->name][$parent]),
|
$parentNode = $model->find(array($scope, $model->escapeField() => $model->data[$model->name][$parent]),
|
||||||
array($model->primaryKey, $left, $right), null, -1);
|
array($model->primaryKey, $left, $right), null, -1);
|
||||||
if (!$parentNode) {
|
if (!$parentNode) {
|
||||||
trigger_error(__('Trying to save a node under a none-existant node in ' . __METHOD__, E_USER_WARNING));
|
trigger_error(__('Trying to save a node under a none-existant node in TreeBehavior::beforeSave', E_USER_WARNING));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
list($parentNode) = array_values($parentNode);
|
list($parentNode) = array_values($parentNode);
|
||||||
if (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) {
|
if (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) {
|
||||||
trigger_error(__('Trying to save a node under itself in ' . __METHOD__, E_USER_WARNING));
|
trigger_error(__('Trying to save a node under itself in TreeBehavior::beforeSave', E_USER_WARNING));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
elseif ($node[$model->primaryKey] == $parentNode[$model->primaryKey]) {
|
elseif ($node[$model->primaryKey] == $parentNode[$model->primaryKey]) {
|
||||||
trigger_error(__('Trying to set a node to be the parent of itself in ' . __METHOD__, E_USER_WARNING));
|
trigger_error(__('Trying to set a node to be the parent of itself in TreeBehavior::beforeSave', E_USER_WARNING));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,8 @@ class TreeBehavior extends ModelBehavior {
|
||||||
|
|
||||||
if ($parentId) {
|
if ($parentId) {
|
||||||
$parentId = $parentId[$model->name][$parent];
|
$parentId = $parentId[$model->name][$parent];
|
||||||
$parent = $model->findById($parentId, $fields, null, $recursive);
|
$parent = $model->find(array($model->name . '.' . $model->primaryKey => $parentId), $fields, null, $recursive);
|
||||||
|
|
||||||
return $parent;
|
return $parent;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -342,7 +343,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
$id = $model->id;
|
$id = $model->id;
|
||||||
}
|
}
|
||||||
extract($this->settings[$model->name]);
|
extract($this->settings[$model->name]);
|
||||||
@list($item) = array_values($model->findById($id, array($left, $right)));
|
@list($item) = array_values($model->find(array($model->name . '.' . $model->primaryKey => $id), array($left, $right)));
|
||||||
|
|
||||||
if (empty ($item)) {
|
if (empty ($item)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -626,15 +627,15 @@ class TreeBehavior extends ModelBehavior {
|
||||||
list($parentNode)= array_values($model->find(array($scope, $model->escapeField() => $parentId),
|
list($parentNode)= array_values($model->find(array($scope, $model->escapeField() => $parentId),
|
||||||
array($model->primaryKey, $left, $right), null, -1));
|
array($model->primaryKey, $left, $right), null, -1));
|
||||||
if (empty ($parentNode)) {
|
if (empty ($parentNode)) {
|
||||||
trigger_error(__('Trying to move a node under a none-existant node in ' . __METHOD__, true), E_USER_WARNING);
|
trigger_error(__('Trying to move a node under a none-existant node in TreeBehavior::_setParent', true), E_USER_WARNING);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
elseif (($model->id == $parentId)) {
|
elseif (($model->id == $parentId)) {
|
||||||
trigger_error(__('Trying to set a node to be the parent of itself in ' . __METHOD__, E_USER_WARNING));
|
trigger_error(__('Trying to set a node to be the parent of itself in TreeBehavior::_setParent', E_USER_WARNING));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
elseif (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) {
|
elseif (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) {
|
||||||
trigger_error(__('Trying to move a node under itself in ' . __METHOD__, E_USER_WARNING));
|
trigger_error(__('Trying to move a node under itself in TreeBehavior::_setParent', E_USER_WARNING));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (empty ($node[$left]) && empty ($node[$right])) {
|
if (empty ($node[$left]) && empty ($node[$right])) {
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
* Included libs
|
* Included libs
|
||||||
*/
|
*/
|
||||||
uses('class_registry', 'validation', 'overloadable', 'model' . DS . 'behavior', 'model' . DS . 'connection_manager', 'set');
|
uses('class_registry', 'validation', 'overloadable', 'model' . DS . 'behavior', 'model' . DS . 'connection_manager', 'set');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object-relational mapper.
|
* Object-relational mapper.
|
||||||
*
|
*
|
||||||
|
@ -46,7 +45,6 @@ uses('class_registry', 'validation', 'overloadable', 'model' . DS . 'behavior',
|
||||||
* @subpackage cake.cake.libs.model
|
* @subpackage cake.cake.libs.model
|
||||||
*/
|
*/
|
||||||
class Model extends Overloadable {
|
class Model extends Overloadable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the DataSource connection that this Model uses
|
* The name of the DataSource connection that this Model uses
|
||||||
*
|
*
|
||||||
|
@ -54,7 +52,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $useDbConfig = 'default';
|
var $useDbConfig = 'default';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here... Still used?
|
* Enter description here... Still used?
|
||||||
*
|
*
|
||||||
|
@ -63,7 +60,6 @@ class Model extends Overloadable {
|
||||||
* @todo Is this still used? -OJ 22 nov 2006
|
* @todo Is this still used? -OJ 22 nov 2006
|
||||||
*/
|
*/
|
||||||
var $parent = false;
|
var $parent = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom database table name.
|
* Custom database table name.
|
||||||
*
|
*
|
||||||
|
@ -71,7 +67,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $useTable = null;
|
var $useTable = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom display field name. Display fields are used by Scaffold, in SELECT boxes' OPTION elements.
|
* Custom display field name. Display fields are used by Scaffold, in SELECT boxes' OPTION elements.
|
||||||
*
|
*
|
||||||
|
@ -79,7 +74,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $displayField = null;
|
var $displayField = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value of the primary key ID of the record that this model is currently pointing to
|
* Value of the primary key ID of the record that this model is currently pointing to
|
||||||
*
|
*
|
||||||
|
@ -87,7 +81,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $id = false;
|
var $id = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for the data that this model gets from persistent storage (the database).
|
* Container for the data that this model gets from persistent storage (the database).
|
||||||
*
|
*
|
||||||
|
@ -95,7 +88,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $data = array();
|
var $data = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table name for this Model.
|
* Table name for this Model.
|
||||||
*
|
*
|
||||||
|
@ -103,7 +95,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $table = false;
|
var $table = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the ID field for this Model.
|
* The name of the ID field for this Model.
|
||||||
*
|
*
|
||||||
|
@ -111,7 +102,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $primaryKey = null;
|
var $primaryKey = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table metadata
|
* Table metadata
|
||||||
*
|
*
|
||||||
|
@ -119,7 +109,6 @@ class Model extends Overloadable {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_tableInfo = null;
|
var $_tableInfo = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of validation rules. Append entries for validation as ('field_name' => '/^perl_compat_regexp$/')
|
* List of validation rules. Append entries for validation as ('field_name' => '/^perl_compat_regexp$/')
|
||||||
* that have to match with preg_match(). Use these rules with Model::validate()
|
* that have to match with preg_match(). Use these rules with Model::validate()
|
||||||
|
@ -128,14 +117,12 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $validate = array();
|
var $validate = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Errors in validation
|
* Errors in validation
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $validationErrors = array();
|
var $validationErrors = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database table prefix for tables in model.
|
* Database table prefix for tables in model.
|
||||||
*
|
*
|
||||||
|
@ -143,21 +130,18 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $tablePrefix = null;
|
var $tablePrefix = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the model.
|
* Name of the model.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $name = null;
|
var $name = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the current model.
|
* Name of the current model.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $currentModel = null;
|
var $currentModel = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of table names included in the Model description. Used for associations.
|
* List of table names included in the Model description. Used for associations.
|
||||||
*
|
*
|
||||||
|
@ -165,7 +149,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $tableToModel = array();
|
var $tableToModel = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of Model names by used tables. Used for associations.
|
* List of Model names by used tables. Used for associations.
|
||||||
*
|
*
|
||||||
|
@ -173,7 +156,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $modelToTable = array();
|
var $modelToTable = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of Foreign Key names to used tables. Used for associations.
|
* List of Foreign Key names to used tables. Used for associations.
|
||||||
*
|
*
|
||||||
|
@ -181,7 +163,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $keyToTable = array();
|
var $keyToTable = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias table names for model, for use in SQL JOIN statements.
|
* Alias table names for model, for use in SQL JOIN statements.
|
||||||
*
|
*
|
||||||
|
@ -189,7 +170,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $alias = array();
|
var $alias = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not transactions for this model should be logged
|
* Whether or not transactions for this model should be logged
|
||||||
*
|
*
|
||||||
|
@ -197,7 +177,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $logTransactions = false;
|
var $logTransactions = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not to enable transactions for this model (i.e. BEGIN/COMMIT/ROLLBACK)
|
* Whether or not to enable transactions for this model (i.e. BEGIN/COMMIT/ROLLBACK)
|
||||||
*
|
*
|
||||||
|
@ -205,7 +184,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $transactional = false;
|
var $transactional = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not to cache queries for this model. This enables in-memory
|
* Whether or not to cache queries for this model. This enables in-memory
|
||||||
* caching only, the results are not stored beyond this execution.
|
* caching only, the results are not stored beyond this execution.
|
||||||
|
@ -214,7 +192,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $cacheQueries = false;
|
var $cacheQueries = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* belongsTo association
|
* belongsTo association
|
||||||
*
|
*
|
||||||
|
@ -222,7 +199,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $belongsTo = array();
|
var $belongsTo = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hasOne association
|
* hasOne association
|
||||||
*
|
*
|
||||||
|
@ -230,7 +206,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $hasOne = array();
|
var $hasOne = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hasMany association
|
* hasMany association
|
||||||
*
|
*
|
||||||
|
@ -238,7 +213,6 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $hasMany = array();
|
var $hasMany = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hasAndBelongsToMany association
|
* hasAndBelongsToMany association
|
||||||
*
|
*
|
||||||
|
@ -246,14 +220,12 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $hasAndBelongsToMany = array();
|
var $hasAndBelongsToMany = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of behaviors to use
|
* List of behaviors to use
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $actsAs = null;
|
var $actsAs = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Behavior objects
|
* Behavior objects
|
||||||
*
|
*
|
||||||
|
@ -266,7 +238,6 @@ class Model extends Overloadable {
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
var $cacheSources = true;
|
var $cacheSources = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapped behavior methods
|
* Mapped behavior methods
|
||||||
*
|
*
|
||||||
|
@ -274,7 +245,6 @@ class Model extends Overloadable {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $__behaviorMethods = array();
|
var $__behaviorMethods = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Depth of recursive association
|
* Depth of recursive association
|
||||||
*
|
*
|
||||||
|
@ -282,14 +252,12 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $recursive = 1;
|
var $recursive = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default ordering of model records
|
* Default ordering of model records
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var mixed
|
||||||
*/
|
*/
|
||||||
var $order = null;
|
var $order = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default association keys
|
* Default association keys
|
||||||
*
|
*
|
||||||
|
@ -302,7 +270,6 @@ class Model extends Overloadable {
|
||||||
'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'),
|
'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'),
|
||||||
'hasAndBelongsToMany' => array('className', 'joinTable', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery')
|
'hasAndBelongsToMany' => array('className', 'joinTable', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery')
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds provided/generated association key names and other data for all associations
|
* Holds provided/generated association key names and other data for all associations
|
||||||
*
|
*
|
||||||
|
@ -310,7 +277,6 @@ class Model extends Overloadable {
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
var $__associations = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
var $__associations = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds model associations temporarily to allow for dynamic (un)binding
|
* Holds model associations temporarily to allow for dynamic (un)binding
|
||||||
*
|
*
|
||||||
|
@ -318,7 +284,6 @@ class Model extends Overloadable {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $__backAssociation = array();
|
var $__backAssociation = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last inserted ID of the data that this model created
|
* The last inserted ID of the data that this model created
|
||||||
*
|
*
|
||||||
|
@ -326,7 +291,6 @@ class Model extends Overloadable {
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
var $__insertID = null;
|
var $__insertID = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of records returned by the last query
|
* The number of records returned by the last query
|
||||||
*
|
*
|
||||||
|
@ -334,7 +298,6 @@ class Model extends Overloadable {
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
var $__numRows = null;
|
var $__numRows = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of records affected by the last query
|
* The number of records affected by the last query
|
||||||
*
|
*
|
||||||
|
@ -342,7 +305,6 @@ class Model extends Overloadable {
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
var $__affectedRows = null;
|
var $__affectedRows = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Binds the Model's database table to the object.
|
* Constructor. Binds the Model's database table to the object.
|
||||||
*
|
*
|
||||||
|
@ -952,7 +914,6 @@ class Model extends Overloadable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns contents of a field in a query matching given conditions.
|
* Returns contents of a field in a query matching given conditions.
|
||||||
*
|
*
|
||||||
|
@ -990,7 +951,6 @@ class Model extends Overloadable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a single field to the database.
|
* Saves a single field to the database.
|
||||||
*
|
*
|
||||||
|
@ -1002,7 +962,6 @@ class Model extends Overloadable {
|
||||||
function saveField($name, $value, $validate = false) {
|
function saveField($name, $value, $validate = false) {
|
||||||
return $this->save(array($this->name => array($name => $value)), $validate, array($name));
|
return $this->save(array($this->name => array($name => $value)), $validate, array($name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves model data to the database.
|
* Saves model data to the database.
|
||||||
* By default, validation occurs before save.
|
* By default, validation occurs before save.
|
||||||
|
@ -2138,9 +2097,7 @@ class Model extends Overloadable {
|
||||||
function __wakeup() {
|
function __wakeup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
Overloadable::overload('Model');
|
Overloadable::overload('Model');
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -186,9 +186,9 @@ class NumberTreeCase extends CakeTestCase {
|
||||||
$this->NumberTree = & new NumberTree();
|
$this->NumberTree = & new NumberTree();
|
||||||
$this->NumberTree->__initialize(2, 2);
|
$this->NumberTree->__initialize(2, 2);
|
||||||
|
|
||||||
$this->NumberTree->save(array('NumberTree' => array('name' => __METHOD__,'parent_id' => null)));
|
$this->NumberTree->save(array('NumberTree' => array('name' => 'testAddOrphan', 'parent_id' => null)));
|
||||||
$result = $this->NumberTree->find(null, array('name', 'parent_id'), 'NumberTree.lft desc');
|
$result = $this->NumberTree->find(null, array('name', 'parent_id'), 'NumberTree.lft desc');
|
||||||
$expected = array('NumberTree' => array('name' => __METHOD__, 'parent_id' => null));
|
$expected = array('NumberTree' => array('name' => 'testAddOrphan', 'parent_id' => null));
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$validTree = $this->NumberTree->verify();
|
$validTree = $this->NumberTree->verify();
|
||||||
|
@ -203,7 +203,7 @@ class NumberTreeCase extends CakeTestCase {
|
||||||
$initialCount = $this->NumberTree->findCount();
|
$initialCount = $this->NumberTree->findCount();
|
||||||
|
|
||||||
$this->NumberTree->create();
|
$this->NumberTree->create();
|
||||||
$saveSuccess = $this->NumberTree->save(array('NumberTree' => array('name' => __METHOD__, 'parent_id' => $data['NumberTree']['id'])));
|
$saveSuccess = $this->NumberTree->save(array('NumberTree' => array('name' => 'testAddMiddle', 'parent_id' => $data['NumberTree']['id'])));
|
||||||
$this->assertIdentical($saveSuccess, true);
|
$this->assertIdentical($saveSuccess, true);
|
||||||
|
|
||||||
$laterCount = $this->NumberTree->findCount();
|
$laterCount = $this->NumberTree->findCount();
|
||||||
|
@ -214,7 +214,7 @@ class NumberTreeCase extends CakeTestCase {
|
||||||
$children = $this->NumberTree->children($data['NumberTree']['id'], true, array('name'));
|
$children = $this->NumberTree->children($data['NumberTree']['id'], true, array('name'));
|
||||||
$expects = array(array('NumberTree' => array('name' => '1.1.1')),
|
$expects = array(array('NumberTree' => array('name' => '1.1.1')),
|
||||||
array('NumberTree' => array('name' => '1.1.2')),
|
array('NumberTree' => array('name' => '1.1.2')),
|
||||||
array('NumberTree' => array('name' => __METHOD__)));
|
array('NumberTree' => array('name' => 'testAddMiddle')));
|
||||||
$this->assertIdentical($children, $expects);
|
$this->assertIdentical($children, $expects);
|
||||||
|
|
||||||
$validTree = $this->NumberTree->verify();
|
$validTree = $this->NumberTree->verify();
|
||||||
|
@ -229,7 +229,7 @@ class NumberTreeCase extends CakeTestCase {
|
||||||
$initialCount = $this->NumberTree->findCount();
|
$initialCount = $this->NumberTree->findCount();
|
||||||
$this->expectError('Trying to save a node under a none-existant node in TreeBehavior::beforeSave');
|
$this->expectError('Trying to save a node under a none-existant node in TreeBehavior::beforeSave');
|
||||||
|
|
||||||
$saveSuccess = $this->NumberTree->save(array('NumberTree' => array('name' => __METHOD__, 'parent_id' => 99999)));
|
$saveSuccess = $this->NumberTree->save(array('NumberTree' => array('name' => 'testAddInvalid', 'parent_id' => 99999)));
|
||||||
$this->assertIdentical($saveSuccess, false);
|
$this->assertIdentical($saveSuccess, false);
|
||||||
|
|
||||||
$laterCount = $this->NumberTree->findCount();
|
$laterCount = $this->NumberTree->findCount();
|
||||||
|
|
Loading…
Reference in a new issue