Esempio n. 1
0
 public function testMoveAsLast()
 {
     // single root
     $array = NestedSet::model()->findAll();
     $nestedSet = NestedSet::model()->findByPk(3);
     $this->assertTrue($nestedSet instanceof NestedSet);
     $target = NestedSet::model()->findByPk(5);
     $this->assertTrue($target instanceof NestedSet);
     $this->assertTrue($nestedSet->moveAsLast($target));
     $this->assertTrue($this->checkTree());
     $this->assertTrue($this->checkArray($array));
     $nestedSet = NestedSet::model()->findByPk(2);
     $this->assertTrue($nestedSet instanceof NestedSet);
     $this->assertTrue($nestedSet->moveAsLast($target));
     $this->assertTrue($this->checkTree());
     $this->assertTrue($this->checkArray($array));
     // many roots
     $array = NestedSetWithManyRoots::model()->findAll();
     $nestedSet = NestedSetWithManyRoots::model()->findByPk(3);
     $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots);
     $target = NestedSetWithManyRoots::model()->findByPk(5);
     $this->assertTrue($target instanceof NestedSetWithManyRoots);
     $this->assertTrue($nestedSet->moveAsLast($target));
     $this->assertTrue($this->checkTreeWithManyRoots());
     $this->assertTrue($this->checkArrayWithManyRoots($array));
     $nestedSet = NestedSetWithManyRoots::model()->findByPk(2);
     $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots);
     $this->assertTrue($nestedSet->moveAsLast($target));
     $this->assertTrue($this->checkTreeWithManyRoots());
     $this->assertTrue($this->checkArrayWithManyRoots($array));
     $nestedSet = NestedSetWithManyRoots::model()->findByPk(3);
     $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots);
     $target = NestedSetWithManyRoots::model()->findByPk(12);
     $this->assertTrue($target instanceof NestedSetWithManyRoots);
     $this->assertTrue($nestedSet->moveAsLast($target));
     $this->assertTrue($this->checkTreeWithManyRoots());
     $this->assertTrue($this->checkArrayWithManyRoots($array));
     $nestedSet = NestedSetWithManyRoots::model()->findByPk(2);
     $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots);
     $this->assertTrue($nestedSet->moveAsLast($target));
     $this->assertTrue($this->checkTreeWithManyRoots());
     $this->assertTrue($this->checkArrayWithManyRoots($array));
 }