public function testRetrieveRoot() { $this->assertTrue(method_exists('Table9Peer', 'retrieveRoot'), 'nested_set adds a retrieveRoot() method'); Table9Peer::doDeleteAll(); $this->assertNull(Table9Peer::retrieveRoot(), 'retrieveRoot() returns null as long as no root node is defined'); $t1 = new Table9(); $t1->setLeftValue(123); $t1->setRightValue(456); $t1->save(); $this->assertNull(Table9Peer::retrieveRoot(), 'retrieveRoot() returns null as long as no root node is defined'); $t2 = new Table9(); $t2->setLeftValue(1); $t2->setRightValue(2); $t2->save(); $this->assertEquals(Table9Peer::retrieveRoot(), $t2, 'retrieveRoot() retrieves the root node'); }
public function testFindRoot() { $this->assertTrue(method_exists('Table9Query', 'findRoot'), 'nested_set adds a findRoot() method'); Table9Query::create()->deleteAll(); $this->assertNull(Table9Query::create()->findRoot(), 'findRoot() returns null as long as no root node is defined'); $t1 = new Table9(); $t1->setLeftValue(123); $t1->setRightValue(456); $t1->save(); $this->assertNull(Table9Query::create()->findRoot(), 'findRoot() returns null as long as no root node is defined'); $t2 = new Table9(); $t2->setLeftValue(1); $t2->setRightValue(2); $t2->save(); $this->assertEquals(Table9Query::create()->findRoot(), $t2, 'findRoot() retrieves the root node'); }