public function testGetIterator() { $fixtures = $this->initTree(); $this->assertTrue(method_exists('NestedSetTable9', 'getIterator'), 'nested_set adds a getIterator() method'); $root = \NestedSetTable9Query::retrieveRoot(); $iterator = $root->getIterator(); $this->assertTrue($iterator instanceof NestedSetRecursiveIterator, 'getIterator() returns a NestedSetRecursiveIterator'); foreach ($iterator as $node) { $expected = array_shift($fixtures); $this->assertEquals($expected, $node, 'getIterator returns an iterator parsing the tree order by left column'); } }
public function testRetrieveRoot() { $this->assertTrue(method_exists('NestedSetTable9Query', 'retrieveRoot'), 'nested_set adds a retrieveRoot() method'); \Map\NestedSetTable9TableMap::doDeleteAll(); $this->assertNull(\NestedSetTable9Query::retrieveRoot(), 'retrieveRoot() returns null as long as no root node is defined'); $t1 = new \NestedSetTable9(); $t1->setLeftValue(123); $t1->setRightValue(456); $t1->save(); $this->assertNull(\NestedSetTable9Query::retrieveRoot(), 'retrieveRoot() returns null as long as no root node is defined'); $t2 = new \NestedSetTable9(); $t2->setLeftValue(1); $t2->setRightValue(2); $t2->save(); $this->assertEquals(\NestedSetTable9Query::retrieveRoot(), $t2, 'retrieveRoot() retrieves the root node'); }