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 testRetrieveRoot() { $this->assertTrue(method_exists('Table10Peer', 'retrieveRoot'), 'nested_set adds a retrieveRoot() method'); Table10Peer::doDeleteAll(); $t1 = new Table10(); $t1->setLeftValue(1); $t1->setRightValue(2); $t1->setScopeValue(2); $t1->save(); $this->assertNull(Table10Peer::retrieveRoot(1), 'retrieveRoot() returns null as long as no root node is defined in the required scope'); $t2 = new Table10(); $t2->setLeftValue(1); $t2->setRightValue(2); $t2->setScopeValue(1); $t2->save(); $this->assertEquals(Table10Peer::retrieveRoot(1), $t2, 'retrieveRoot() retrieves the root node in the required scope'); }
/** * Tree used for tests * Scope 1 * t1 * | \ * t2 t3 * | \ * t4 t5 * | \ * t6 t7 * Scope 2 * t8 * | \ * t9 t10 */ protected function initTreeWithScope() { Table10Peer::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 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; }