public function testSaveOutOfTree()
 {
     Table9Peer::doDeleteAll();
     $t1 = new Table9();
     $t1->setTitle('t1');
     try {
         $t1->save();
         $this->assertTrue(true, 'A node can be saved without valid tree information');
     } catch (Exception $e) {
         $this->fail('A node can be saved without valid tree information');
     }
     try {
         $t1->makeRoot();
         $this->assertTrue(true, 'A saved node can be turned into root');
     } catch (Exception $e) {
         $this->fail('A saved node can be turned into root');
     }
     $t1->save();
     $t2 = new Table9();
     $t2->setTitle('t1');
     $t2->save();
     try {
         $t2->insertAsFirstChildOf($t1);
         $this->assertTrue(true, 'A saved node can be inserted into the tree');
     } catch (Exception $e) {
         $this->fail('A saved node can be inserted into the tree');
     }
     try {
         $t2->save();
         $this->assertTrue(true, 'A saved node can be inserted into the tree');
     } catch (Exception $e) {
         $this->fail('A saved node can be inserted into the tree');
     }
 }
 public function testInsertAsNextSiblingOfExistingObject()
 {
     Table9Query::create()->deleteAll();
     $t = new Table9();
     $t->makeRoot();
     $t->save();
     $t1 = new Table9();
     $t1->insertAsFirstChildOf($t);
     $t1->save();
     $this->assertEquals(1, $t->getLeftValue());
     $this->assertEquals(4, $t->getRightValue());
     $this->assertEquals(0, $t->getLevel());
     $this->assertEquals(2, $t1->getLeftValue());
     $this->assertEquals(3, $t1->getRightValue());
     $this->assertEquals(1, $t1->getLevel());
     $t2 = new Table9();
     $t2->save();
     $t2->insertAsNextSiblingOf($t1);
     $this->assertEquals(4, $t2->getLeftValue());
     $this->assertEquals(5, $t2->getRightValue());
     $this->assertEquals(1, $t2->getLevel());
     $t2->save();
     $this->assertEquals(1, $t->getLeftValue());
     $this->assertEquals(6, $t->getRightValue());
     $this->assertEquals(0, $t->getLevel());
     $this->assertEquals(2, $t1->getLeftValue());
     $this->assertEquals(3, $t1->getRightValue());
     $this->assertEquals(1, $t1->getLevel());
     $this->assertEquals(4, $t2->getLeftValue());
     $this->assertEquals(5, $t2->getRightValue());
     $this->assertEquals(1, $t2->getLevel());
 }