コード例 #1
0
 public function testParameters()
 {
     $t = new Table10();
     $t->setMyLeftColumn('123');
     $this->assertEquals($t->getLeftValue(), '123', 'nested_set adds a getLeftValue() method');
     $t->setMyRightColumn('456');
     $this->assertEquals($t->getRightValue(), '456', 'nested_set adds a getRightValue() method');
     $t->setMyLevelColumn('789');
     $this->assertEquals($t->getLevel(), '789', 'nested_set adds a getLevel() method');
     $t->setMyScopeColumn('012');
     $this->assertEquals($t->getScopeValue(), '012', 'nested_set adds a getScopeValue() method');
 }
 public function testInsertAsNextSiblingOfExistingObject()
 {
     Table10Query::create()->deleteAll();
     $t = new Table10();
     $t->setScopeValue(34);
     $t->makeRoot();
     $t->save();
     $t1 = new Table10();
     $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(34, $t1->getScopeValue());
     $this->assertEquals(1, $t1->getLevel());
     $t2 = new Table10();
     $t2->save();
     $t2->insertAsNextSiblingOf($t1);
     $this->assertEquals(4, $t2->getLeftValue());
     $this->assertEquals(5, $t2->getRightValue());
     $this->assertEquals(34, $t2->getScopeValue());
     $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(34, $t1->getScopeValue());
     $this->assertEquals(1, $t1->getLevel());
     $this->assertEquals(4, $t2->getLeftValue());
     $this->assertEquals(5, $t2->getRightValue());
     $this->assertEquals(34, $t2->getScopeValue());
     $this->assertEquals(1, $t2->getLevel());
 }