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());
 }
Esempio n. 2
0
 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 testRetrieveRoot()
 {
     $this->assertTrue(method_exists('NestedSetTable10Query', 'retrieveRoot'), 'nested_set adds a retrieveRoot() method');
     \Map\NestedSetTable10TableMap::doDeleteAll();
     $t1 = new \NestedSetTable10();
     $t1->setLeftValue(1);
     $t1->setRightValue(2);
     $t1->setScopeValue(2);
     $t1->save();
     $this->assertNull(\NestedSetTable10Query::retrieveRoot(1), 'retrieveRoot() returns null as long as no root node is defined in the required scope');
     $t2 = new \NestedSetTable10();
     $t2->setLeftValue(1);
     $t2->setRightValue(2);
     $t2->setScopeValue(1);
     $t2->save();
     $this->assertEquals(\NestedSetTable10Query::retrieveRoot(1), $t2, 'retrieveRoot() retrieves the root node in the required scope');
 }