Permalink
Browse files

add missing create() for creating a new record.

  • Loading branch information...
1 parent 17bd465 commit f62f46562c73b893f06726d267e8010f48a114cc @dereuromark dereuromark committed Sep 18, 2013
@@ -91,6 +91,7 @@ public function testDetectInvalidLeft() {
$save[$modelClass]['id'] = $result[$modelClass]['id'];
$save[$modelClass][$leftField] = 0;
+ $this->Tree->create();
$this->Tree->save($save);
$result = $this->Tree->verify();
$this->assertNotSame($result, true);
@@ -118,6 +119,7 @@ public function testDetectInvalidRight() {
$save[$modelClass]['id'] = $result[$modelClass]['id'];
$save[$modelClass][$rightField] = 0;
+ $this->Tree->create();
$this->Tree->save($save);
$result = $this->Tree->verify();
$this->assertNotSame($result, true);
@@ -190,17 +192,21 @@ public function testRecoverUsingParentMode() {
$this->Tree->order = null;
$this->Tree->Behaviors->disable('Tree');
+ $this->Tree->create();
$this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
$node1 = $this->Tree->id;
$this->Tree->create();
$this->Tree->save(array('name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0));
$node11 = $this->Tree->id;
+
$this->Tree->create();
$this->Tree->save(array('name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0));
$node12 = $this->Tree->id;
+
$this->Tree->create();
$this->Tree->save(array('name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0));
+
$this->Tree->create();
$this->Tree->save(array('name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0));
@@ -242,19 +248,24 @@ public function testRecoverUsingParentModeAndDelete() {
$this->Tree->order = null;
$this->Tree->Behaviors->disable('Tree');
+ $this->Tree->create();
$this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
$node1 = $this->Tree->id;
$this->Tree->create();
$this->Tree->save(array('name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0));
$node11 = $this->Tree->id;
+
$this->Tree->create();
$this->Tree->save(array('name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0));
$node12 = $this->Tree->id;
+
$this->Tree->create();
$this->Tree->save(array('name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0));
+
$this->Tree->create();
$this->Tree->save(array('name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0));
+
$this->Tree->create();
$this->Tree->save(array('name' => 'Lost', $parentField => 9, $leftField => 0, $rightField => 0));
@@ -408,6 +419,7 @@ public function testAddOrphan() {
$this->Tree->order = null;
$this->Tree->initialize(2, 2);
+ $this->Tree->create();
$this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null)));
$result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc'));
$expected = array($modelClass => array('name' => 'testAddOrphan', $parentField => null));
@@ -495,6 +507,7 @@ public function testAddInvalid() {
$initialCount = $this->Tree->find('count');
//$this->expectError('Trying to save a node under a none-existant node in TreeBehavior::beforeSave');
+ $this->Tree->create();
$saveSuccess = $this->Tree->save(array($modelClass => array('name' => 'testAddInvalid', $parentField => 99999)));
$this->assertFalse($saveSuccess);
@@ -516,6 +529,7 @@ public function testAddNotIndexedByModel() {
$this->Tree->order = null;
$this->Tree->initialize(2, 2);
+ $this->Tree->create();
$this->Tree->save(array('name' => 'testAddNotIndexed', $parentField => null));
$result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc'));
$expected = array($modelClass => array('name' => 'testAddNotIndexed', $parentField => null));
@@ -592,6 +606,7 @@ public function testInsertWithWhitelist() {
$this->Tree->initialize(2, 2);
$this->Tree->whitelist = array('name', $parentField);
+ $this->Tree->create();
$this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null)));
$result = $this->Tree->findByName('testAddOrphan', array('name', $parentField, $leftField, $rightField));
$expected = array('name' => 'testAddOrphan', $parentField => null, $leftField => '15', $rightField => 16);
@@ -178,6 +178,7 @@ public function testTranslatingTree() {
$this->Tree->Behaviors->attach('Translate', array('title'));
//Save
+ $this->Tree->create();
$this->Tree->locale = 'eng';
$data = array('FlagTree' => array(
'title' => 'name #1',
@@ -394,17 +395,21 @@ public function testRecoverUsingParentMode() {
$this->Tree->Behaviors->attach('Tree', array('scope' => 'FlagTree.flag = 1'));
$this->Tree->Behaviors->disable('Tree');
+ $this->Tree->create();
$this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0, 'flag' => 1));
$node1 = $this->Tree->id;
$this->Tree->create();
$this->Tree->save(array('name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0, 'flag' => 1));
$node11 = $this->Tree->id;
+
$this->Tree->create();
$this->Tree->save(array('name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0, 'flag' => 1));
$node12 = $this->Tree->id;
+
$this->Tree->create();
$this->Tree->save(array('name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0, 'flag' => 1));
+
$this->Tree->create();
$this->Tree->save(array('name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0, 'flag' => 1));

0 comments on commit f62f465

Please sign in to comment.