コード例 #1
0
 public function testDefault()
 {
     $table9 = Table9Peer::getTableMap();
     $this->assertEquals(count($table9->getColumns()), 5, 'nested_set adds three column by default');
     $this->assertTrue(method_exists('Table9', 'getTreeLeft'), 'nested_set adds a tree_left column by default');
     $this->assertTrue(method_exists('Table9', 'getLeftValue'), 'nested_set maps the left_value getter with the tree_left column');
     $this->assertTrue(method_exists('Table9', 'getTreeRight'), 'nested_set adds a tree_right column by default');
     $this->assertTrue(method_exists('Table9', 'getRightValue'), 'nested_set maps the right_value getter with the tree_right column');
     $this->assertTrue(method_exists('Table9', 'getTreeLevel'), 'nested_set adds a tree_level column by default');
     $this->assertTrue(method_exists('Table9', 'getLevel'), 'nested_set maps the level getter with the tree_level column');
     $this->assertFalse(method_exists('Table9', 'getTreeScope'), 'nested_set does not add a tree_scope column by default');
     $this->assertFalse(method_exists('Table9', 'getScopeValue'), 'nested_set does not map the scope_value getter with the tree_scope column by default');
 }
 public function testGetIterator()
 {
     $fixtures = $this->initTree();
     $this->assertTrue(method_exists('Table9', 'getIterator'), 'nested_set adds a getIterator() method');
     $root = Table9Peer::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 testFixLevels()
 {
     $fixtures = $this->initTree();
     // reset the levels
     foreach ($fixtures as $node) {
         $node->setLevel(null)->save();
     }
     // fix the levels
     Table9Peer::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');
     Table9Peer::fixLevels();
     $this->assertEquals($expected, $this->dumpTree(), 'fixLevels() can be called several times');
 }
コード例 #4
0
 protected function dumpTree()
 {
     $c = new Criteria();
     $c->addAscendingOrderBycolumn(Table9Peer::TITLE);
     return $this->dumpNodes(Table9Peer::doSelect($c));
 }