public function testParameters() { $table10 = \Map\NestedSetTable10TableMap::getTableMap(); $this->assertEquals(count($table10->getColumns()), 6, 'nested_set does not add columns when they already exist'); $this->assertTrue(method_exists('NestedSetTable10', 'getLeftValue'), 'nested_set maps the left_value getter with the tree_left column'); $this->assertTrue(method_exists('NestedSetTable10', 'getRightValue'), 'nested_set maps the right_value getter with the tree_right column'); $this->assertTrue(method_exists('NestedSetTable10', 'getLevel'), 'nested_set maps the level getter with the tree_level column'); $this->assertTrue(method_exists('NestedSetTable10', 'getScopeValue'), 'nested_set maps the scope_value getter with the tree_scope column when the use_scope parameter is true'); }
public function testSaveRootInTreeWithExistingRootWithDifferentScope() { \Map\NestedSetTable10TableMap::doDeleteAll(); $t1 = new \NestedSetTable10(); $t1->setScopeValue(1); $t1->makeRoot(); $t1->save(); $t2 = new \NestedSetTable10(); $t2->setScopeValue(2); $t2->makeRoot(); $t2->save(); $this->assertTrue(!$t2->isNew()); }
protected function initTreeWithScope() { \Map\NestedSetTable10TableMap::doDeleteAll(); $ret = array(); $fixtures = array('t1' => array(1, 14, 0, 1), 't2' => array(2, 3, 1, 1), 't3' => array(4, 13, 1, 1), 't4' => array(5, 6, 2, 1), 't5' => array(7, 12, 2, 1), 't6' => array(8, 9, 3, 1), 't7' => array(10, 11, 3, 1), 't8' => array(1, 6, 0, 2), 't9' => array(2, 3, 1, 2), 't10' => array(4, 5, 1, 2)); foreach ($fixtures as $key => $data) { $t = new Fixtures\PublicTable10(); $t->setTitle($key); $t->setLeftValue($data[0]); $t->setRightValue($data[1]); $t->setLevel($data[2]); $t->setScopeValue($data[3]); $t->save(); $ret[] = $t; } return $ret; }
public function testShiftLevel() { $this->initTreeWithScope(); \NestedSetTable10Query::shiftLevel($delta = 1, $first = 7, $last = 12, $scope = 1); \Map\NestedSetTable10TableMap::clearInstancePool(); $expected = ['t1' => [1, 14, 0], 't2' => [2, 3, 1], 't3' => [4, 13, 1], 't4' => [5, 6, 2], 't5' => [7, 12, 3], 't6' => [8, 9, 4], 't7' => [10, 11, 4]]; $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'shiftLevel can shift level with a scope'); $expected = ['t8' => [1, 6, 0], 't9' => [2, 3, 1], 't10' => [4, 5, 1]]; $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'shiftLevel does not shift anything out of the scope'); }