Ejemplo n.º 1
0
 public function testInsertAfter()
 {
     // single root
     $array = NestedSet::model()->findAll();
     $target = NestedSet::model()->findByPk(2);
     $this->assertTrue($target instanceof NestedSet);
     $nestedSet1 = new NestedSet();
     $this->assertFalse($nestedSet1->insertAfter($target));
     $nestedSet1->name = 'test';
     $this->assertTrue($nestedSet1->insertAfter($target));
     $this->assertTrue($this->checkTree());
     $array[] = $nestedSet1;
     $nestedSet2 = new NestedSet();
     $nestedSet2->name = 'test';
     $this->assertTrue($nestedSet2->insertAfter($target));
     $this->assertTrue($this->checkTree());
     $array[] = $nestedSet2;
     $this->assertTrue($this->checkArray($array));
     // many roots
     $array = NestedSetWithManyRoots::model()->findAll();
     $target = NestedSetWithManyRoots::model()->findByPk(2);
     $this->assertTrue($target instanceof NestedSetWithManyRoots);
     $nestedSet1 = new NestedSetWithManyRoots();
     $this->assertFalse($nestedSet1->insertAfter($target));
     $nestedSet1->name = 'test';
     $this->assertTrue($nestedSet1->insertAfter($target));
     $this->assertTrue($this->checkTreeWithManyRoots());
     $array[] = $nestedSet1;
     $nestedSet2 = new NestedSetWithManyRoots();
     $nestedSet2->name = 'test';
     $this->assertTrue($nestedSet2->insertAfter($target));
     $this->assertTrue($this->checkTreeWithManyRoots());
     $array[] = $nestedSet2;
     $this->assertTrue($this->checkArrayWithManyRoots($array));
 }