public function testFixLevels()
 {
     $fixtures = $this->initTree();
     // reset the levels
     foreach ($fixtures as $node) {
         $node->setLevel(null)->save();
     }
     // fix the levels
     \NestedSetTable9Query::fixLevels();
     $expected = array('t1' => array(1, 14, 0), 't2' => array(2, 3, 1), 't3' => array(4, 13, 1), 't4' => array(5, 6, 2), 't5' => array(7, 12, 2), 't6' => array(8, 9, 3), 't7' => array(10, 11, 3));
     $this->assertEquals($expected, $this->dumpTree(), 'fixLevels() fixes the levels correctly');
     \NestedSetTable9Query::fixLevels();
     $this->assertEquals($expected, $this->dumpTree(), 'fixLevels() can be called several times');
 }
 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');
     }
 }
 protected function dumpTree()
 {
     return $this->dumpNodes(\NestedSetTable9Query::create()->orderByTitle()->find());
 }