Exemplo n.º 1
0
 /**
  * Test resolving sortorder when we delete competency.
  */
 public function test_fix_sortorder_when_delete_competency()
 {
     $this->resetAfterTest(true);
     $this->setUser($this->creator);
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $framework = $lpg->create_framework();
     $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     $c2a = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id(), 'parentid' => $c2->get_id()));
     $c2b = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id(), 'parentid' => $c2->get_id()));
     $c2c = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id(), 'parentid' => $c2->get_id()));
     $c2d = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id(), 'parentid' => $c2->get_id()));
     $this->assertEquals(0, $c1->get_sortorder());
     $this->assertEquals(1, $c2->get_sortorder());
     $this->assertEquals(0, $c2a->get_sortorder());
     $this->assertEquals(1, $c2b->get_sortorder());
     $this->assertEquals(2, $c2c->get_sortorder());
     $this->assertEquals(3, $c2d->get_sortorder());
     $result = external::delete_competency($c1->get_id());
     $result = external_api::clean_returnvalue(external::delete_competency_returns(), $result);
     $c2->read();
     $c2a->read();
     $c2b->read();
     $c2c->read();
     $c2d->read();
     $this->assertEquals(0, $c2->get_sortorder());
     $this->assertEquals(0, $c2a->get_sortorder());
     $this->assertEquals(1, $c2b->get_sortorder());
     $this->assertEquals(2, $c2c->get_sortorder());
     $this->assertEquals(3, $c2d->get_sortorder());
     $result = external::delete_competency($c2b->get_id());
     $result = external_api::clean_returnvalue(external::delete_competency_returns(), $result);
     $c2->read();
     $c2a->read();
     $c2c->read();
     $c2d->read();
     $this->assertEquals(0, $c2->get_sortorder());
     $this->assertEquals(0, $c2a->get_sortorder());
     $this->assertEquals(1, $c2c->get_sortorder());
     $this->assertEquals(2, $c2d->get_sortorder());
 }