public function testGetParent() { Table9Peer::doDeleteAll(); $t0 = new Table9(); $this->assertFalse($t0->hasParent(), 'empty node has no parent'); $t1 = new Table9(); $t1->setTitle('t1')->setLeftValue(1)->setRightValue(8)->setLevel(0)->save(); $t2 = new Table9(); $t2->setTitle('t2')->setLeftValue(2)->setRightValue(7)->setLevel(1)->save(); $t3 = new Table9(); $t3->setTitle('t3')->setLeftValue(3)->setRightValue(4)->setLevel(2)->save(); $t4 = new Table9(); $t4->setTitle('t4')->setLeftValue(5)->setRightValue(6)->setLevel(2)->save(); $this->assertNull($t1->getParent($this->con), 'getParent() return null for root nodes'); $this->assertEquals($t2->getParent($this->con), $t1, 'getParent() correctly retrieves parent for nodes'); $this->assertEquals($t3->getParent($this->con), $t2, 'getParent() correctly retrieves parent for leafs'); $this->assertEquals($t4->getParent($this->con), $t2, 'getParent() retrieves the same parent for two siblings'); }