Merge branch 'master' into 2.6

This commit is contained in:
mark_story 2014-11-14 21:25:09 -05:00
commit decce4daf2
6 changed files with 140 additions and 91 deletions

View file

@ -129,6 +129,7 @@ class TreeBehavior extends ModelBehavior {
$data = $Model->find('first', array( $data = $Model->find('first', array(
'conditions' => array($Model->escapeField($Model->primaryKey) => $Model->id), 'conditions' => array($Model->escapeField($Model->primaryKey) => $Model->id),
'fields' => array($Model->escapeField($left), $Model->escapeField($right)), 'fields' => array($Model->escapeField($left), $Model->escapeField($right)),
'order' => false,
'recursive' => -1)); 'recursive' => -1));
if ($data) { if ($data) {
$this->_deletedRow[$Model->alias] = current($data); $this->_deletedRow[$Model->alias] = current($data);
@ -185,7 +186,9 @@ class TreeBehavior extends ModelBehavior {
if (array_key_exists($parent, $Model->data[$Model->alias]) && $Model->data[$Model->alias][$parent]) { if (array_key_exists($parent, $Model->data[$Model->alias]) && $Model->data[$Model->alias][$parent]) {
$parentNode = $Model->find('first', array( $parentNode = $Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]), 'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]),
'fields' => array($Model->primaryKey, $right), 'recursive' => $recursive 'fields' => array($Model->primaryKey, $right),
'recursive' => $recursive,
'order' => false,
)); ));
if (!$parentNode) { if (!$parentNode) {
return false; return false;
@ -208,7 +211,9 @@ class TreeBehavior extends ModelBehavior {
} else { } else {
$values = $Model->find('first', array( $values = $Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $Model->id), 'conditions' => array($scope, $Model->escapeField() => $Model->id),
'fields' => array($Model->primaryKey, $parent, $left, $right), 'recursive' => $recursive) 'fields' => array($Model->primaryKey, $parent, $left, $right),
'order' => false,
'recursive' => $recursive)
); );
if (empty($values)) { if (empty($values)) {
@ -218,7 +223,9 @@ class TreeBehavior extends ModelBehavior {
$parentNode = $Model->find('first', array( $parentNode = $Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]), 'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]),
'fields' => array($Model->primaryKey, $left, $right), 'recursive' => $recursive 'fields' => array($Model->primaryKey, $left, $right),
'order' => false,
'recursive' => $recursive
)); ));
if (!$parentNode) { if (!$parentNode) {
return false; return false;
@ -268,7 +275,11 @@ class TreeBehavior extends ModelBehavior {
} elseif ($Model->id === $id && isset($Model->data[$Model->alias][$left]) && isset($Model->data[$Model->alias][$right])) { } elseif ($Model->id === $id && isset($Model->data[$Model->alias][$left]) && isset($Model->data[$Model->alias][$right])) {
$data = $Model->data[$Model->alias]; $data = $Model->data[$Model->alias];
} else { } else {
$data = $Model->find('first', array('conditions' => array($scope, $Model->escapeField() => $id), 'recursive' => $recursive)); $data = $Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $id),
'order' => false,
'recursive' => $recursive
));
if (!$data) { if (!$data) {
return 0; return 0;
} }
@ -325,7 +336,8 @@ class TreeBehavior extends ModelBehavior {
$result = array_values((array)$Model->find('first', array( $result = array_values((array)$Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $id), 'conditions' => array($scope, $Model->escapeField() => $id),
'fields' => array($left, $right), 'fields' => array($left, $right),
'recursive' => $recursive 'recursive' => $recursive,
'order' => false,
))); )));
if (empty($result) || !isset($result[0])) { if (empty($result) || !isset($result[0])) {
@ -425,11 +437,21 @@ class TreeBehavior extends ModelBehavior {
if ($overrideRecursive !== null) { if ($overrideRecursive !== null) {
$recursive = $overrideRecursive; $recursive = $overrideRecursive;
} }
$parentId = $Model->find('first', array('conditions' => array($Model->primaryKey => $id), 'fields' => array($parent), 'recursive' => -1)); $parentId = $Model->find('first', array(
'conditions' => array($Model->primaryKey => $id),
'fields' => array($parent),
'order' => false,
'recursive' => -1
));
if ($parentId) { if ($parentId) {
$parentId = $parentId[$Model->alias][$parent]; $parentId = $parentId[$Model->alias][$parent];
$parent = $Model->find('first', array('conditions' => array($Model->escapeField() => $parentId), 'fields' => $fields, 'recursive' => $recursive)); $parent = $Model->find('first', array(
'conditions' => array($Model->escapeField() => $parentId),
'fields' => $fields,
'order' => false,
'recursive' => $recursive
));
return $parent; return $parent;
} }
@ -458,7 +480,12 @@ class TreeBehavior extends ModelBehavior {
if ($overrideRecursive !== null) { if ($overrideRecursive !== null) {
$recursive = $overrideRecursive; $recursive = $overrideRecursive;
} }
$result = $Model->find('first', array('conditions' => array($Model->escapeField() => $id), 'fields' => array($left, $right), 'recursive' => $recursive)); $result = $Model->find('first', array(
'conditions' => array($Model->escapeField() => $id),
'fields' => array($left, $right),
'order' => false,
'recursive' => $recursive
));
if ($result) { if ($result) {
$result = array_values($result); $result = array_values($result);
} else { } else {
@ -467,7 +494,9 @@ class TreeBehavior extends ModelBehavior {
$item = $result[0]; $item = $result[0];
$results = $Model->find('all', array( $results = $Model->find('all', array(
'conditions' => array($scope, $Model->escapeField($left) . ' <=' => $item[$left], $Model->escapeField($right) . ' >=' => $item[$right]), 'conditions' => array($scope, $Model->escapeField($left) . ' <=' => $item[$left], $Model->escapeField($right) . ' >=' => $item[$right]),
'fields' => $fields, 'order' => array($Model->escapeField($left) => 'asc'), 'recursive' => $recursive 'fields' => $fields, 'order' => array($Model->escapeField($left) => 'asc'),
'order' => false,
'recursive' => $recursive
)); ));
return $results; return $results;
} }
@ -496,12 +525,16 @@ class TreeBehavior extends ModelBehavior {
extract($this->settings[$Model->alias]); extract($this->settings[$Model->alias]);
list($node) = array_values($Model->find('first', array( list($node) = array_values($Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $id), 'conditions' => array($scope, $Model->escapeField() => $id),
'fields' => array($Model->primaryKey, $left, $right, $parent), 'recursive' => $recursive 'fields' => array($Model->primaryKey, $left, $right, $parent),
'order' => false,
'recursive' => $recursive
))); )));
if ($node[$parent]) { if ($node[$parent]) {
list($parentNode) = array_values($Model->find('first', array( list($parentNode) = array_values($Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $node[$parent]), 'conditions' => array($scope, $Model->escapeField() => $node[$parent]),
'fields' => array($Model->primaryKey, $left, $right), 'recursive' => $recursive 'fields' => array($Model->primaryKey, $left, $right),
'order' => false,
'recursive' => $recursive
))); )));
if (($node[$right] + 1) == $parentNode[$right]) { if (($node[$right] + 1) == $parentNode[$right]) {
return false; return false;
@ -509,7 +542,9 @@ class TreeBehavior extends ModelBehavior {
} }
$nextNode = $Model->find('first', array( $nextNode = $Model->find('first', array(
'conditions' => array($scope, $Model->escapeField($left) => ($node[$right] + 1)), 'conditions' => array($scope, $Model->escapeField($left) => ($node[$right] + 1)),
'fields' => array($Model->primaryKey, $left, $right), 'recursive' => $recursive) 'fields' => array($Model->primaryKey, $left, $right),
'order' => false,
'recursive' => $recursive)
); );
if ($nextNode) { if ($nextNode) {
list($nextNode) = array_values($nextNode); list($nextNode) = array_values($nextNode);
@ -554,12 +589,16 @@ class TreeBehavior extends ModelBehavior {
extract($this->settings[$Model->alias]); extract($this->settings[$Model->alias]);
list($node) = array_values($Model->find('first', array( list($node) = array_values($Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $id), 'conditions' => array($scope, $Model->escapeField() => $id),
'fields' => array($Model->primaryKey, $left, $right, $parent), 'recursive' => $recursive 'fields' => array($Model->primaryKey, $left, $right, $parent),
'order' => false,
'recursive' => $recursive
))); )));
if ($node[$parent]) { if ($node[$parent]) {
list($parentNode) = array_values($Model->find('first', array( list($parentNode) = array_values($Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $node[$parent]), 'conditions' => array($scope, $Model->escapeField() => $node[$parent]),
'fields' => array($Model->primaryKey, $left, $right), 'recursive' => $recursive 'fields' => array($Model->primaryKey, $left, $right),
'order' => false,
'recursive' => $recursive
))); )));
if (($node[$left] - 1) == $parentNode[$left]) { if (($node[$left] - 1) == $parentNode[$left]) {
return false; return false;
@ -568,6 +607,7 @@ class TreeBehavior extends ModelBehavior {
$previousNode = $Model->find('first', array( $previousNode = $Model->find('first', array(
'conditions' => array($scope, $Model->escapeField($right) => ($node[$left] - 1)), 'conditions' => array($scope, $Model->escapeField($right) => ($node[$left] - 1)),
'fields' => array($Model->primaryKey, $left, $right), 'fields' => array($Model->primaryKey, $left, $right),
'order' => false,
'recursive' => $recursive 'recursive' => $recursive
)); ));
@ -620,7 +660,8 @@ class TreeBehavior extends ModelBehavior {
'recursive' => 0, 'recursive' => 0,
'conditions' => array($scope, array( 'conditions' => array($scope, array(
'NOT' => array($Model->escapeField($parent) => null), $Model->VerifyParent->escapeField() => null 'NOT' => array($Model->escapeField($parent) => null), $Model->VerifyParent->escapeField() => null
)) )),
'order' => false,
)); ));
$Model->unbindModel(array('belongsTo' => array('VerifyParent'))); $Model->unbindModel(array('belongsTo' => array('VerifyParent')));
if ($missingParents) { if ($missingParents) {
@ -790,6 +831,7 @@ class TreeBehavior extends ModelBehavior {
list($node) = array_values($Model->find('first', array( list($node) = array_values($Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $id), 'conditions' => array($scope, $Model->escapeField() => $id),
'fields' => array($Model->primaryKey, $left, $right, $parent), 'fields' => array($Model->primaryKey, $left, $right, $parent),
'order' => false,
'recursive' => $recursive 'recursive' => $recursive
))); )));
@ -803,6 +845,7 @@ class TreeBehavior extends ModelBehavior {
list($parentNode) = array_values($Model->find('first', array( list($parentNode) = array_values($Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $node[$parent]), 'conditions' => array($scope, $Model->escapeField() => $node[$parent]),
'fields' => array($Model->primaryKey, $left, $right), 'fields' => array($Model->primaryKey, $left, $right),
'order' => false,
'recursive' => $recursive 'recursive' => $recursive
))); )));
} else { } else {
@ -871,7 +914,11 @@ class TreeBehavior extends ModelBehavior {
} }
} }
} }
$node = $Model->find('first', array('conditions' => array($scope, $Model->escapeField($right) . '< ' . $Model->escapeField($left)), 'recursive' => 0)); $node = $Model->find('first', array(
'conditions' => array($scope, $Model->escapeField($right) . '< ' . $Model->escapeField($left)),
'order' => false,
'recursive' => 0
));
if ($node) { if ($node) {
$errors[] = array('node', $node[$Model->alias][$Model->primaryKey], 'left greater than right.'); $errors[] = array('node', $node[$Model->alias][$Model->primaryKey], 'left greater than right.');
} }
@ -882,7 +929,8 @@ class TreeBehavior extends ModelBehavior {
'fields' => array($Model->primaryKey, $left, $right, $parent) 'fields' => array($Model->primaryKey, $left, $right, $parent)
)))); ))));
foreach ($Model->find('all', array('conditions' => $scope, 'recursive' => 0)) as $instance) { $rows = $Model->find('all', array('conditions' => $scope, 'recursive' => 0));
foreach ($rows as $instance) {
if ($instance[$Model->alias][$left] === null || $instance[$Model->alias][$right] === null) { if ($instance[$Model->alias][$left] === null || $instance[$Model->alias][$right] === null) {
$errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey],
'has invalid left or right values'); 'has invalid left or right values');
@ -927,6 +975,7 @@ class TreeBehavior extends ModelBehavior {
list($node) = array_values($Model->find('first', array( list($node) = array_values($Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $Model->id), 'conditions' => array($scope, $Model->escapeField() => $Model->id),
'fields' => array($Model->primaryKey, $parent, $left, $right), 'fields' => array($Model->primaryKey, $parent, $left, $right),
'order' => false,
'recursive' => $recursive 'recursive' => $recursive
))); )));
$edge = $this->_getMax($Model, $scope, $right, $recursive, $created); $edge = $this->_getMax($Model, $scope, $right, $recursive, $created);
@ -938,6 +987,7 @@ class TreeBehavior extends ModelBehavior {
$values = $Model->find('first', array( $values = $Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $parentId), 'conditions' => array($scope, $Model->escapeField() => $parentId),
'fields' => array($Model->primaryKey, $left, $right), 'fields' => array($Model->primaryKey, $left, $right),
'order' => false,
'recursive' => $recursive 'recursive' => $recursive
)); ));
@ -1009,6 +1059,7 @@ class TreeBehavior extends ModelBehavior {
'conditions' => $scope, 'conditions' => $scope,
'fields' => $db->calculate($Model, 'max', array($name, $right)), 'fields' => $db->calculate($Model, 'max', array($name, $right)),
'recursive' => $recursive, 'recursive' => $recursive,
'order' => false,
'callbacks' => false 'callbacks' => false
))); )));
return (empty($edge[$right])) ? 0 : $edge[$right]; return (empty($edge[$right])) ? 0 : $edge[$right];
@ -1030,6 +1081,7 @@ class TreeBehavior extends ModelBehavior {
'conditions' => $scope, 'conditions' => $scope,
'fields' => $db->calculate($Model, 'min', array($name, $left)), 'fields' => $db->calculate($Model, 'min', array($name, $left)),
'recursive' => $recursive, 'recursive' => $recursive,
'order' => false,
'callbacks' => false 'callbacks' => false
))); )));
return (empty($edge[$left])) ? 0 : $edge[$left]; return (empty($edge[$left])) ? 0 : $edge[$left];

View file

@ -300,11 +300,16 @@ class Sqlite extends DboSource {
// PDO::getColumnMeta is experimental and does not work with sqlite3, // PDO::getColumnMeta is experimental and does not work with sqlite3,
// so try to figure it out based on the querystring // so try to figure it out based on the querystring
$querystring = $results->queryString; $querystring = $results->queryString;
if (stripos($querystring, 'SELECT') === 0) { if (stripos($querystring, 'SELECT') === 0 && stripos($querystring, 'FROM') > 0) {
$last = strripos($querystring, 'FROM'); $selectpart = substr($querystring, 7);
if ($last !== false) { $selects = array();
$selectpart = substr($querystring, 7, $last - 8); foreach (String::tokenize($selectpart, ',', '(', ')') as $part) {
$selects = String::tokenize($selectpart, ',', '(', ')'); $fromPos = stripos($part, ' FROM ');
if ($fromPos !== false) {
$selects[] = trim(substr($part, 0, $fromPos));
break;
}
$selects[] = $part;
} }
} elseif (strpos($querystring, 'PRAGMA table_info') === 0) { } elseif (strpos($querystring, 'PRAGMA table_info') === 0) {
$selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk'); $selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk');

View file

@ -3383,9 +3383,10 @@ class Model extends Object implements CakeEventListener {
} }
if (!is_array($fields)) { if (!is_array($fields)) {
$fields = func_get_args(); $fields = func_get_args();
if (is_bool($fields[count($fields) - 1])) { $fieldCount = count($fields) - 1;
$or = $fields[count($fields) - 1]; if (is_bool($fields[$fieldCount])) {
unset($fields[count($fields) - 1]); $or = $fields[$fieldCount];
unset($fields[$fieldCount]);
} }
} }

View file

@ -64,7 +64,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testInitialize() { public function testInitialize() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$result = $this->Tree->find('count'); $result = $this->Tree->find('count');
@ -82,7 +81,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testDetectInvalidLeft() { public function testDetectInvalidLeft() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$result = $this->Tree->findByName('1.1'); $result = $this->Tree->findByName('1.1');
@ -93,7 +91,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->create(); $this->Tree->create();
$this->Tree->save($save); $this->Tree->save($save);
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$result = $this->Tree->recover(); $result = $this->Tree->recover();
$this->assertTrue($result); $this->assertTrue($result);
@ -110,7 +108,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testDetectInvalidRight() { public function testDetectInvalidRight() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$result = $this->Tree->findByName('1.1'); $result = $this->Tree->findByName('1.1');
@ -121,7 +118,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->create(); $this->Tree->create();
$this->Tree->save($save); $this->Tree->save($save);
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$result = $this->Tree->recover(); $result = $this->Tree->recover();
$this->assertTrue($result); $this->assertTrue($result);
@ -138,7 +135,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testDetectInvalidParent() { public function testDetectInvalidParent() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$result = $this->Tree->findByName('1.1'); $result = $this->Tree->findByName('1.1');
@ -147,7 +143,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->updateAll(array($parentField => null), array('id' => $result[$modelClass]['id'])); $this->Tree->updateAll(array($parentField => null), array('id' => $result[$modelClass]['id']));
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$result = $this->Tree->recover(); $result = $this->Tree->recover();
$this->assertTrue($result); $this->assertTrue($result);
@ -164,14 +160,13 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testDetectNoneExistentParent() { public function testDetectNoneExistentParent() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$result = $this->Tree->findByName('1.1'); $result = $this->Tree->findByName('1.1');
$this->Tree->updateAll(array($parentField => 999999), array('id' => $result[$modelClass]['id'])); $this->Tree->updateAll(array($parentField => 999999), array('id' => $result[$modelClass]['id']));
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$result = $this->Tree->recover('MPTT'); $result = $this->Tree->recover('MPTT');
$this->assertTrue($result); $this->assertTrue($result);
@ -188,7 +183,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testRecoverUsingParentMode() { public function testRecoverUsingParentMode() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->Behaviors->disable('Tree'); $this->Tree->Behaviors->disable('Tree');
$this->Tree->create(); $this->Tree->create();
@ -212,7 +206,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->Behaviors->enable('Tree'); $this->Tree->Behaviors->enable('Tree');
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$result = $this->Tree->recover(); $result = $this->Tree->recover();
$this->assertTrue($result); $this->assertTrue($result);
@ -244,7 +238,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testRecoverUsingParentModeAndDelete() { public function testRecoverUsingParentModeAndDelete() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->Behaviors->disable('Tree'); $this->Tree->Behaviors->disable('Tree');
$this->Tree->create(); $this->Tree->create();
@ -280,7 +273,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
)))); ))));
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$count = $this->Tree->find('count'); $count = $this->Tree->find('count');
$this->assertEquals(6, $count); $this->assertEquals(6, $count);
@ -318,14 +311,13 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testRecoverFromMissingParent() { public function testRecoverFromMissingParent() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$result = $this->Tree->findByName('1.1'); $result = $this->Tree->findByName('1.1');
$this->Tree->updateAll(array($parentField => 999999), array('id' => $result[$modelClass]['id'])); $this->Tree->updateAll(array($parentField => 999999), array('id' => $result[$modelClass]['id']));
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$result = $this->Tree->recover(); $result = $this->Tree->recover();
$this->assertTrue($result); $this->assertTrue($result);
@ -342,13 +334,12 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testDetectInvalidParents() { public function testDetectInvalidParents() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->updateAll(array($parentField => null)); $this->Tree->updateAll(array($parentField => null));
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$result = $this->Tree->recover(); $result = $this->Tree->recover();
$this->assertTrue($result); $this->assertTrue($result);
@ -365,13 +356,12 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testDetectInvalidLftsRghts() { public function testDetectInvalidLftsRghts() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->updateAll(array($leftField => 0, $rightField => 0)); $this->Tree->updateAll(array($leftField => 0, $rightField => 0));
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$this->Tree->recover(); $this->Tree->recover();
@ -387,7 +377,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testDetectEqualLftsRghts() { public function testDetectEqualLftsRghts() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(1, 3); $this->Tree->initialize(1, 3);
$result = $this->Tree->findByName('1.1'); $result = $this->Tree->findByName('1.1');
@ -398,7 +387,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
array($rightField . ' >' => $result[$modelClass][$leftField])); array($rightField . ' >' => $result[$modelClass][$leftField]));
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$result = $this->Tree->recover(); $result = $this->Tree->recover();
$this->assertTrue($result); $this->assertTrue($result);
@ -415,7 +404,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testAddOrphan() { public function testAddOrphan() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->create(); $this->Tree->create();
@ -436,7 +424,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testAddMiddle() { public function testAddMiddle() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
@ -468,7 +455,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testAddWithPreSpecifiedId() { public function testAddWithPreSpecifiedId() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array( $data = $this->Tree->find('first', array(
@ -499,7 +485,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testAddInvalid() { public function testAddInvalid() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $this->Tree->id = null;
@ -525,7 +510,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testAddNotIndexedByModel() { public function testAddNotIndexedByModel() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->create(); $this->Tree->create();
@ -546,7 +530,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMovePromote() { public function testMovePromote() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $this->Tree->id = null;
@ -573,7 +556,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveWithWhitelist() { public function testMoveWithWhitelist() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $this->Tree->id = null;
@ -601,7 +583,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testInsertWithWhitelist() { public function testInsertWithWhitelist() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->whitelist = array('name', $parentField); $this->Tree->whitelist = array('name', $parentField);
@ -621,7 +602,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveBefore() { public function testMoveBefore() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $this->Tree->id = null;
@ -650,7 +630,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveAfter() { public function testMoveAfter() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $this->Tree->id = null;
@ -679,7 +658,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveDemoteInvalid() { public function testMoveDemoteInvalid() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $this->Tree->id = null;
@ -712,7 +690,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveInvalid() { public function testMoveInvalid() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $this->Tree->id = null;
@ -737,7 +714,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveSelfInvalid() { public function testMoveSelfInvalid() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $this->Tree->id = null;
@ -763,7 +739,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveUpSuccess() { public function testMoveUpSuccess() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2')));
@ -785,7 +760,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveUpFail() { public function testMoveUpFail() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1'))); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1')));
@ -808,7 +782,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveUp2() { public function testMoveUp2() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(1, 10); $this->Tree->initialize(1, 10);
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
@ -839,7 +812,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveUpFirst() { public function testMoveUpFirst() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(1, 10); $this->Tree->initialize(1, 10);
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
@ -870,7 +842,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveDownSuccess() { public function testMoveDownSuccess() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
@ -892,7 +863,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveDownFail() { public function testMoveDownFail() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2'))); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2')));
@ -914,7 +884,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveDownLast() { public function testMoveDownLast() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(1, 10); $this->Tree->initialize(1, 10);
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
@ -945,7 +914,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveDown2() { public function testMoveDown2() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(1, 10); $this->Tree->initialize(1, 10);
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
@ -976,7 +944,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testSaveNoMove() { public function testSaveNoMove() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(1, 10); $this->Tree->initialize(1, 10);
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
@ -1007,7 +974,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testMoveToRootAndMoveUp() { public function testMoveToRootAndMoveUp() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(1, 1); $this->Tree->initialize(1, 1);
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
$this->Tree->id = $data[$modelClass]['id']; $this->Tree->id = $data[$modelClass]['id'];
@ -1032,7 +998,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testDelete() { public function testDelete() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$initialCount = $this->Tree->find('count'); $initialCount = $this->Tree->find('count');
@ -1068,7 +1033,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testDeleteDoesNotExist() { public function testDeleteDoesNotExist() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->delete(99999); $this->Tree->delete(99999);
} }
@ -1081,7 +1045,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testRemove() { public function testRemove() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$initialCount = $this->Tree->find('count'); $initialCount = $this->Tree->find('count');
$result = $this->Tree->findByName('1.1'); $result = $this->Tree->findByName('1.1');
@ -1114,7 +1077,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testRemoveLastTopParent() { public function testRemoveLastTopParent() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$initialCount = $this->Tree->find('count'); $initialCount = $this->Tree->find('count');
@ -1148,7 +1110,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testRemoveNoChildren() { public function testRemoveNoChildren() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$initialCount = $this->Tree->find('count'); $initialCount = $this->Tree->find('count');
@ -1183,7 +1144,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testRemoveAndDelete() { public function testRemoveAndDelete() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$initialCount = $this->Tree->find('count'); $initialCount = $this->Tree->find('count');
@ -1218,7 +1178,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testRemoveAndDeleteNoChildren() { public function testRemoveAndDeleteNoChildren() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$initialCount = $this->Tree->find('count'); $initialCount = $this->Tree->find('count');
@ -1251,7 +1210,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testChildren() { public function testChildren() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
@ -1282,7 +1240,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testCountChildren() { public function testCountChildren() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
@ -1308,7 +1265,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testGetParentNode() { public function testGetParentNode() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2'))); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2')));
@ -1327,7 +1283,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testGetPath() { public function testGetPath() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2'))); $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2')));
@ -1348,7 +1303,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testNoAmbiguousColumn() { public function testNoAmbiguousColumn() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->bindModel(array('belongsTo' => array('Dummy' => $this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false); array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
@ -1381,7 +1335,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testReorderTree() { public function testReorderTree() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(3, 3); $this->Tree->initialize(3, 3);
$nodes = $this->Tree->find('list', array('order' => $leftField)); $nodes = $this->Tree->find('list', array('order' => $leftField));
@ -1413,7 +1366,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testReorderBigTreeWithQueryCaching() { public function testReorderBigTreeWithQueryCaching() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 10); $this->Tree->initialize(2, 10);
$original = $this->Tree->cacheQueries; $original = $this->Tree->cacheQueries;
@ -1431,7 +1383,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testGenerateTreeListWithSelfJoin() { public function testGenerateTreeListWithSelfJoin() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->bindModel(array('belongsTo' => array('Dummy' => $this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false); array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
@ -1449,7 +1400,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testGenerateTreeListFormatting() { public function testGenerateTreeListFormatting() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$result = $this->Tree->generateTreeList( $result = $this->Tree->generateTreeList(
@ -1470,7 +1420,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
public function testArraySyntax() { public function testArraySyntax() {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(3, 3); $this->Tree->initialize(3, 3);
$this->assertSame($this->Tree->childCount(2), $this->Tree->childCount(array('id' => 2))); $this->assertSame($this->Tree->childCount(2), $this->Tree->childCount(array('id' => 2)));
$this->assertSame($this->Tree->getParentNode(2), $this->Tree->getParentNode(array('id' => 2))); $this->assertSame($this->Tree->getParentNode(2), $this->Tree->getParentNode(array('id' => 2)));

View file

@ -438,7 +438,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
$this->Tree->Behaviors->enable('Tree'); $this->Tree->Behaviors->enable('Tree');
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$result = $this->Tree->recover(); $result = $this->Tree->recover();
$this->assertTrue($result); $this->assertTrue($result);
@ -485,7 +485,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
$this->Tree->updateAll(array($parentField => 999999), array('id' => $result[$modelClass]['id'])); $this->Tree->updateAll(array($parentField => 999999), array('id' => $result[$modelClass]['id']));
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$result = $this->Tree->recover(); $result = $this->Tree->recover();
$this->assertTrue($result); $this->assertTrue($result);
@ -515,7 +515,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
$this->Tree->updateAll(array($parentField => null)); $this->Tree->updateAll(array($parentField => null));
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$result = $this->Tree->recover(); $result = $this->Tree->recover();
$this->assertTrue($result); $this->assertTrue($result);
@ -545,7 +545,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
$this->Tree->updateAll(array($leftField => 0, $rightField => 0)); $this->Tree->updateAll(array($leftField => 0, $rightField => 0));
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$this->Tree->recover(); $this->Tree->recover();
@ -579,7 +579,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
array($rightField . ' >' => $result[$modelClass][$leftField])); array($rightField . ' >' => $result[$modelClass][$leftField]));
$result = $this->Tree->verify(); $result = $this->Tree->verify();
$this->assertNotSame($result, true); $this->assertNotSame(true, $result);
$result = $this->Tree->recover(); $result = $this->Tree->recover();
$this->assertTrue($result); $this->assertTrue($result);

View file

@ -518,4 +518,46 @@ class SqliteTest extends CakeTestCase {
$this->assertNotContains($scientificNotation, $result); $this->assertNotContains($scientificNotation, $result);
} }
/**
* Test that fields are parsed out in a reasonable fashion.
*
* @return void
*/
public function testFetchRowColumnParsing() {
$this->loadFixtures('User');
$sql = 'SELECT "User"."id", "User"."user", "User"."password", "User"."created", (1 + 1) AS "two" ' .
'FROM "users" AS "User" WHERE ' .
'"User"."id" IN (SELECT MAX("id") FROM "users") ' .
'OR "User.id" IN (5, 6, 7, 8)';
$result = $this->Dbo->fetchRow($sql);
$expected = array(
'User' => array(
'id' => 4,
'user' => 'garrett',
'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
'created' => '2007-03-17 01:22:23'
),
0 => array(
'two' => 2
)
);
$this->assertEquals($expected, $result);
$sql = 'SELECT "User"."id", "User"."user" ' .
'FROM "users" AS "User" WHERE "User"."id" = 4 ' .
'UNION ' .
'SELECT "User"."id", "User"."user" ' .
'FROM "users" AS "User" WHERE "User"."id" = 3';
$result = $this->Dbo->fetchRow($sql);
$expected = array(
'User' => array(
'id' => 3,
'user' => 'larry',
),
);
$this->assertEquals($expected, $result);
}
} }