public function testParameters()
 {
     $table10 = Table10Peer::getTableMap();
     $this->assertEquals(count($table10->getColumns()), 6, 'nested_set does not add columns when they already exist');
     $this->assertTrue(method_exists('Table10', 'getLeftValue'), 'nested_set maps the left_value getter with the tree_left column');
     $this->assertTrue(method_exists('Table10', 'getRightValue'), 'nested_set maps the right_value getter with the tree_right column');
     $this->assertTrue(method_exists('Table10', 'getLevel'), 'nested_set maps the level getter with the tree_level column');
     $this->assertTrue(method_exists('Table10', 'getScopeValue'), 'nested_set maps the scope_value getter with the tree_scope column when the use_scope parameter is true');
 }
 public function testSaveRootInTreeWithExistingRootWithDifferentScope()
 {
     Table10Peer::doDeleteAll();
     $t1 = new Table10();
     $t1->setScopeValue(1);
     $t1->makeRoot();
     $t1->save();
     $t2 = new Table10();
     $t2->setScopeValue(2);
     $t2->makeRoot();
     $t2->save();
     $this->assertTrue(!$t2->isNew());
 }
 public function testMakeRoomForLeaf()
 {
     $this->assertTrue(method_exists('Table10Peer', 'makeRoomForLeaf'), 'nested_set adds a makeRoomForLeaf() method');
     $fixtures = $this->initTreeWithScope();
     /* Tree used for tests
     		 Scope 1
     		 t1
     		 |  \
     		 t2 t3
     		    |  \
     		    t4 t5
     		       |  \
     		       t6 t7
     		 Scope 2
     		 t8
     		 | \
     		 t9 t10
     		*/
     $t = Table10Peer::makeRoomForLeaf(5, 1);
     // first child of t3
     $expected = array('t1' => array(1, 16, 0), 't2' => array(2, 3, 1), 't3' => array(4, 15, 1), 't4' => array(7, 8, 2), 't5' => array(9, 14, 2), 't6' => array(10, 11, 3), 't7' => array(12, 13, 3));
     $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'makeRoomForLeaf() shifts the other nodes correctly');
     $expected = array('t8' => array(1, 6, 0), 't9' => array(2, 3, 1), 't10' => array(4, 5, 1));
     $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'makeRoomForLeaf() does not shift anything out of the scope');
 }
Exemplo n.º 4
0
 protected function dumpTreeWithScope($scope)
 {
     $c = new Criteria();
     $c->add(Table10Peer::SCOPE_COL, $scope);
     $c->addAscendingOrderBycolumn(Table10Peer::TITLE);
     return $this->dumpNodes(Table10Peer::doSelect($c));
 }