mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix coding standards in Case/Model/Behavior.
This commit is contained in:
parent
346e048371
commit
fc234d82f1
7 changed files with 68 additions and 67 deletions
|
@ -27,10 +27,10 @@ App::uses('DbAcl', 'Model');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Person class - self joined model
|
* Test Person class - self joined model
|
||||||
*
|
*
|
||||||
* @package Cake.Test.Case.Model.Behavior
|
* @package Cake.Test.Case.Model.Behavior
|
||||||
*/
|
*/
|
||||||
class AclPerson extends CakeTestModel {
|
class AclPerson extends CakeTestModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,13 +98,14 @@ class AclPerson extends CakeTestModel {
|
||||||
return array('AclPerson' => array('id' => $motherId));
|
return array('AclPerson' => array('id' => $motherId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AclUser class
|
* AclUser class
|
||||||
*
|
*
|
||||||
* @package Cake.Test.Case.Model.Behavior
|
* @package Cake.Test.Case.Model.Behavior
|
||||||
*/
|
*/
|
||||||
class AclUser extends CakeTestModel {
|
class AclUser extends CakeTestModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,13 +136,14 @@ class AclUser extends CakeTestModel {
|
||||||
public function parentNode() {
|
public function parentNode() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AclPost class
|
* AclPost class
|
||||||
*
|
*
|
||||||
* @package Cake.Test.Case.Model.Behavior
|
* @package Cake.Test.Case.Model.Behavior
|
||||||
*/
|
*/
|
||||||
class AclPost extends CakeTestModel {
|
class AclPost extends CakeTestModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,13 +174,14 @@ class AclPost extends CakeTestModel {
|
||||||
public function parentNode() {
|
public function parentNode() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AclBehaviorTest class
|
* AclBehaviorTest class
|
||||||
*
|
*
|
||||||
* @package Cake.Test.Case.Model.Behavior
|
* @package Cake.Test.Case.Model.Behavior
|
||||||
*/
|
*/
|
||||||
class AclBehaviorTest extends CakeTestCase {
|
class AclBehaviorTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -342,7 +345,7 @@ class AclBehaviorTest extends CakeTestCase {
|
||||||
$this->assertEquals($result['Aro']['parent_id'], 7);
|
$this->assertEquals($result['Aro']['parent_id'], 7);
|
||||||
|
|
||||||
$node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8), 'Aro');
|
$node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8), 'Aro');
|
||||||
$this->assertEquals(sizeof($node), 2);
|
$this->assertEquals(count($node), 2);
|
||||||
$this->assertEquals($node[0]['Aro']['parent_id'], 7);
|
$this->assertEquals($node[0]['Aro']['parent_id'], 7);
|
||||||
$this->assertEquals($node[1]['Aro']['parent_id'], null);
|
$this->assertEquals($node[1]['Aro']['parent_id'], null);
|
||||||
}
|
}
|
||||||
|
@ -362,7 +365,6 @@ class AclBehaviorTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->Aro->save($aroData);
|
$this->Aro->save($aroData);
|
||||||
|
|
||||||
|
|
||||||
$acoData = array(
|
$acoData = array(
|
||||||
'Aco' => array(
|
'Aco' => array(
|
||||||
'model' => 'AclPerson',
|
'model' => 'AclPerson',
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
App::uses('Model', 'Model');
|
App::uses('Model', 'Model');
|
||||||
App::uses('AppModel', 'Model');
|
App::uses('AppModel', 'Model');
|
||||||
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
|
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ContainableTest class
|
* ContainableTest class
|
||||||
|
@ -3553,8 +3553,10 @@ class ContainableBehaviorTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->skipIf(
|
$this->skipIf(
|
||||||
!isset($config->test) || !isset($config->test2),
|
!isset($config->test) || !isset($config->test2),
|
||||||
'Primary and secondary test databases not configured, skipping cross-database join tests.'
|
'Primary and secondary test databases not configured, ' .
|
||||||
. ' To run these tests, you must define $test and $test2 in your database configuration.'
|
'skipping cross-database join tests. ' .
|
||||||
|
' To run these tests, you must define $test and $test2 ' .
|
||||||
|
'in your database configuration.'
|
||||||
);
|
);
|
||||||
|
|
||||||
$db = ConnectionManager::getDataSource('test2');
|
$db = ConnectionManager::getDataSource('test2');
|
||||||
|
|
|
@ -22,7 +22,7 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
|
|
||||||
App::uses('Model', 'Model');
|
App::uses('Model', 'Model');
|
||||||
App::uses('AppModel', 'Model');
|
App::uses('AppModel', 'Model');
|
||||||
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
|
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TranslateBehaviorTest class
|
* TranslateBehaviorTest class
|
||||||
|
@ -351,7 +351,6 @@ class TranslateBehaviorTest extends CakeTestCase {
|
||||||
$TestModel = new TranslatedItem();
|
$TestModel = new TranslatedItem();
|
||||||
$TestModel->locale = array('deu', 'eng', 'cze');
|
$TestModel->locale = array('deu', 'eng', 'cze');
|
||||||
|
|
||||||
|
|
||||||
$result = $TestModel->read(null, 1);
|
$result = $TestModel->read(null, 1);
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'TranslatedItem' => array(
|
'TranslatedItem' => array(
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
App::uses('Model', 'Model');
|
App::uses('Model', 'Model');
|
||||||
App::uses('AppModel', 'Model');
|
App::uses('AppModel', 'Model');
|
||||||
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
|
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
App::uses('Model', 'Model');
|
App::uses('Model', 'Model');
|
||||||
App::uses('AppModel', 'Model');
|
App::uses('AppModel', 'Model');
|
||||||
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
|
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TreeBehaviorNumberTest class
|
* TreeBehaviorNumberTest class
|
||||||
|
@ -42,7 +42,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $settings = array(
|
public $settings = array(
|
||||||
'modelClass' => 'NumberTree',
|
'modelClass' => 'NumberTree',
|
||||||
'leftField' => 'lft',
|
'leftField' => 'lft',
|
||||||
'rightField' => 'rght',
|
'rightField' => 'rght',
|
||||||
|
@ -410,7 +410,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
|
|
||||||
$validTree = $this->Tree->verify();
|
$validTree = $this->Tree->verify();
|
||||||
$this->assertSame($validTree, true);
|
$this->assertSame($validTree, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testMovePromote method
|
* testMovePromote method
|
||||||
|
@ -424,12 +424,12 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parentId = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
||||||
$this->Tree->id= $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$this->Tree->saveField($parentField, $parent_id);
|
$this->Tree->saveField($parentField, $parentId);
|
||||||
$direct = $this->Tree->children($parent_id, true, array('id', 'name', $parentField, $leftField, $rightField));
|
$direct = $this->Tree->children($parentId, true, array('id', 'name', $parentField, $leftField, $rightField));
|
||||||
$expects = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)),
|
$expects = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)),
|
||||||
array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)),
|
array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)),
|
||||||
array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13)));
|
array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13)));
|
||||||
|
@ -450,14 +450,14 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parentId = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$this->Tree->whitelist = array($parentField, 'name', 'description');
|
$this->Tree->whitelist = array($parentField, 'name', 'description');
|
||||||
$this->Tree->saveField($parentField, $parent_id);
|
$this->Tree->saveField($parentField, $parentId);
|
||||||
|
|
||||||
$result = $this->Tree->children($parent_id, true, array('id', 'name', $parentField, $leftField, $rightField));
|
$result = $this->Tree->children($parentId, true, array('id', 'name', $parentField, $leftField, $rightField));
|
||||||
$expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)),
|
$expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)),
|
||||||
array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)),
|
array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)),
|
||||||
array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13)));
|
array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13)));
|
||||||
|
@ -495,13 +495,13 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1')));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parentId = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$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')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$this->Tree->saveField($parentField, $parent_id);
|
$this->Tree->saveField($parentField, $parentId);
|
||||||
|
|
||||||
$result = $this->Tree->children($parent_id, true, array('name'));
|
$result = $this->Tree->children($parentId, true, array('name'));
|
||||||
$expects = array(array($modelClass => array('name' => '1.1.1')),
|
$expects = array(array($modelClass => array('name' => '1.1.1')),
|
||||||
array($modelClass => array('name' => '1.1.2')),
|
array($modelClass => array('name' => '1.1.2')),
|
||||||
array($modelClass => array('name' => '1.2')));
|
array($modelClass => array('name' => '1.2')));
|
||||||
|
@ -523,13 +523,13 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2')));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parentId = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$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'];
|
||||||
$this->Tree->saveField($parentField, $parent_id);
|
$this->Tree->saveField($parentField, $parentId);
|
||||||
|
|
||||||
$result = $this->Tree->children($parent_id, true, array('name'));
|
$result = $this->Tree->children($parentId, true, array('name'));
|
||||||
$expects = array(array($modelClass => array('name' => '1.2.1')),
|
$expects = array(array($modelClass => array('name' => '1.2.1')),
|
||||||
array($modelClass => array('name' => '1.2.2')),
|
array($modelClass => array('name' => '1.2.2')),
|
||||||
array($modelClass => array('name' => '1.1')));
|
array($modelClass => array('name' => '1.1')));
|
||||||
|
@ -551,15 +551,14 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parentId = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
||||||
|
|
||||||
$expects = $this->Tree->find('all');
|
$expects = $this->Tree->find('all');
|
||||||
$before = $this->Tree->read(null, $data[$modelClass]['id']);
|
$before = $this->Tree->read(null, $data[$modelClass]['id']);
|
||||||
|
|
||||||
$this->Tree->id = $parent_id;
|
$this->Tree->id = $parentId;
|
||||||
//$this->expectError('Trying to save a node under itself in TreeBehavior::beforeSave');
|
|
||||||
$this->Tree->saveField($parentField, $data[$modelClass]['id']);
|
$this->Tree->saveField($parentField, $data[$modelClass]['id']);
|
||||||
|
|
||||||
$results = $this->Tree->find('all');
|
$results = $this->Tree->find('all');
|
||||||
|
@ -584,13 +583,11 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$initialCount = $this->Tree->find('count');
|
$initialCount = $this->Tree->find('count');
|
||||||
$data= $this->Tree->findByName('1.1');
|
$data = $this->Tree->findByName('1.1');
|
||||||
|
|
||||||
//$this->expectError('Trying to save a node under a none-existant node in TreeBehavior::beforeSave');
|
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$this->Tree->saveField($parentField, 999999);
|
$this->Tree->saveField($parentField, 999999);
|
||||||
|
|
||||||
//$this->assertSame($saveSuccess, false);
|
|
||||||
$laterCount = $this->Tree->find('count');
|
$laterCount = $this->Tree->find('count');
|
||||||
$this->assertSame($initialCount, $laterCount);
|
$this->assertSame($initialCount, $laterCount);
|
||||||
|
|
||||||
|
@ -610,9 +607,8 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$initialCount = $this->Tree->find('count');
|
$initialCount = $this->Tree->find('count');
|
||||||
$data= $this->Tree->findByName('1.1');
|
$data = $this->Tree->findByName('1.1');
|
||||||
|
|
||||||
//$this->expectError('Trying to set a node to be the parent of itself in TreeBehavior::beforeSave');
|
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$saveSuccess = $this->Tree->saveField($parentField, $this->Tree->id);
|
$saveSuccess = $this->Tree->saveField($parentField, $this->Tree->id);
|
||||||
|
|
||||||
|
@ -902,11 +898,11 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$laterCount = $this->Tree->find('count');
|
$laterCount = $this->Tree->find('count');
|
||||||
$this->assertEquals($initialCount - 1, $laterCount);
|
$this->assertEquals($initialCount - 1, $laterCount);
|
||||||
|
|
||||||
$validTree= $this->Tree->verify();
|
$validTree = $this->Tree->verify();
|
||||||
$this->assertSame($validTree, true);
|
$this->assertSame($validTree, true);
|
||||||
|
|
||||||
$initialCount = $this->Tree->find('count');
|
$initialCount = $this->Tree->find('count');
|
||||||
$result= $this->Tree->findByName('1.1');
|
$result = $this->Tree->findByName('1.1');
|
||||||
|
|
||||||
$return = $this->Tree->delete($result[$modelClass]['id']);
|
$return = $this->Tree->delete($result[$modelClass]['id']);
|
||||||
$this->assertEquals($return, true);
|
$this->assertEquals($return, true);
|
||||||
|
@ -1033,12 +1029,14 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$this->Tree->removeFromTree($result[$modelClass]['id'], true);
|
$this->Tree->removeFromTree($result[$modelClass]['id'], true);
|
||||||
|
|
||||||
$laterCount = $this->Tree->find('count');
|
$laterCount = $this->Tree->find('count');
|
||||||
$this->assertEquals($initialCount-1, $laterCount);
|
$this->assertEquals($initialCount - 1, $laterCount);
|
||||||
|
|
||||||
$children = $this->Tree->children($result[$modelClass][$parentField], true, array('name'), $leftField . ' asc');
|
$children = $this->Tree->children($result[$modelClass][$parentField], true, array('name'), $leftField . ' asc');
|
||||||
$expects= array(array($modelClass => array('name' => '1.1.1')),
|
$expects = array(
|
||||||
|
array($modelClass => array('name' => '1.1.1')),
|
||||||
array($modelClass => array('name' => '1.1.2')),
|
array($modelClass => array('name' => '1.1.2')),
|
||||||
array($modelClass => array('name' => '1.2')));
|
array($modelClass => array('name' => '1.2'))
|
||||||
|
);
|
||||||
$this->assertEquals($children, $expects);
|
$this->assertEquals($children, $expects);
|
||||||
|
|
||||||
$topNodes = $this->Tree->children(false, true,array('name'));
|
$topNodes = $this->Tree->children(false, true,array('name'));
|
||||||
|
@ -1092,7 +1090,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$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')));
|
||||||
$this->Tree->id= $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
|
|
||||||
$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
|
$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
|
||||||
$expects = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)),
|
$expects = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)),
|
||||||
|
@ -1147,7 +1145,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$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')));
|
||||||
$this->Tree->id= $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
|
|
||||||
$result = $this->Tree->getParentNode(null, array('name'));
|
$result = $this->Tree->getParentNode(null, array('name'));
|
||||||
$expects = array($modelClass => array('name' => '1.2'));
|
$expects = array($modelClass => array('name' => '1.2'));
|
||||||
|
@ -1165,7 +1163,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$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')));
|
||||||
$this->Tree->id= $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
|
|
||||||
$result = $this->Tree->getPath(null, array('name'));
|
$result = $this->Tree->getPath(null, array('name'));
|
||||||
$expects = array(array($modelClass => array('name' => '1. Root')),
|
$expects = array(array($modelClass => array('name' => '1. Root')),
|
||||||
|
@ -1187,7 +1185,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
$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')));
|
||||||
$this->Tree->id= $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
|
|
||||||
$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
|
$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
|
||||||
$expects = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)),
|
$expects = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)),
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
App::uses('Model', 'Model');
|
App::uses('Model', 'Model');
|
||||||
App::uses('AppModel', 'Model');
|
App::uses('AppModel', 'Model');
|
||||||
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
|
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TreeBehaviorScopedTest class
|
* TreeBehaviorScopedTest class
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
App::uses('Model', 'Model');
|
App::uses('Model', 'Model');
|
||||||
App::uses('AppModel', 'Model');
|
App::uses('AppModel', 'Model');
|
||||||
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
|
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TreeBehaviorUuidTest class
|
* TreeBehaviorUuidTest class
|
||||||
|
@ -68,12 +68,12 @@ class TreeBehaviorUuidTest extends CakeTestCase {
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parentId = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
||||||
$this->Tree->id= $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$this->Tree->saveField($parentField, $parent_id);
|
$this->Tree->saveField($parentField, $parentId);
|
||||||
$direct = $this->Tree->children($parent_id, true, array('name', $leftField, $rightField));
|
$direct = $this->Tree->children($parentId, true, array('name', $leftField, $rightField));
|
||||||
$expects = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)),
|
$expects = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)),
|
||||||
array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)),
|
array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)),
|
||||||
array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13)));
|
array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13)));
|
||||||
|
@ -94,14 +94,14 @@ class TreeBehaviorUuidTest extends CakeTestCase {
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parentId = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$this->Tree->whitelist = array($parentField, 'name', 'description');
|
$this->Tree->whitelist = array($parentField, 'name', 'description');
|
||||||
$this->Tree->saveField($parentField, $parent_id);
|
$this->Tree->saveField($parentField, $parentId);
|
||||||
|
|
||||||
$result = $this->Tree->children($parent_id, true, array('name', $leftField, $rightField));
|
$result = $this->Tree->children($parentId, true, array('name', $leftField, $rightField));
|
||||||
$expected = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)),
|
$expected = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)),
|
||||||
array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)),
|
array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)),
|
||||||
array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13)));
|
array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13)));
|
||||||
|
|
Loading…
Reference in a new issue