7 require_once(__DIR__ .
"/mocks.php");
21 protected function setUp() : void
23 require_once(
"./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
24 PHPUnit\Framework\Error\Deprecated::$enabled =
false;
28 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
30 ilUnitUtil::performInitialisation();
45 $this->root->addNode($this->node1);
46 $this->root->addNode($this->node2);
47 $this->node1->addLeaf($this->leaf1);
48 $this->node2->addLeaf($this->leaf2);
58 $this->root->delete();
77 $this->root->assignUser($user->getId(), 6);
89 $this->root->assignUser($user->getId(), 6);
99 $prg->assignUser($user->getId(), 6);
106 $ass = $this->root->assignUser($user1->getId(), 6);
107 $this->assertEquals($user1->getId(), $ass->getUserId());
117 $this->root->assignUser($user1->getId(), 6);
118 $this->assertTrue($this->root->hasAssignmentOf($user1->getId()));
119 $this->assertTrue($this->node1->hasAssignmentOf($user1->getId()));
120 $this->assertTrue($this->node2->hasAssignmentOf($user1->getId()));
122 $this->assertFalse($this->root->hasAssignmentOf($user2->getId()));
123 $this->assertFalse($this->node1->hasAssignmentOf($user2->getId()));
124 $this->assertFalse($this->node2->hasAssignmentOf($user2->getId()));
138 $this->assertEquals(0, $this->root->getAmountOfAssignmentsOf($user1->getId()));
140 $this->root->assignUser($user2->getId(), 6);
141 $this->assertEquals(1, $this->root->getAmountOfAssignmentsOf($user2->getId()));
142 $this->assertEquals(1, $this->node1->getAmountOfAssignmentsOf($user2->getId()));
143 $this->assertEquals(1, $this->node2->getAmountOfAssignmentsOf($user2->getId()));
145 $this->root->assignUser($user3->getId(), 6);
146 $this->root->assignUser($user3->getId(), 6);
147 $this->assertEquals(2, $this->root->getAmountOfAssignmentsOf($user3->getId()));
148 $this->assertEquals(2, $this->node1->getAmountOfAssignmentsOf($user3->getId()));
149 $this->assertEquals(2, $this->node2->getAmountOfAssignmentsOf($user3->getId()));
151 $this->root->assignUser($user4->getId(), 6);
152 $this->node1->assignUser($user4->getId(), 6);
153 $this->assertEquals(1, $this->root->getAmountOfAssignmentsOf($user4->getId()));
154 $this->assertEquals(2, $this->node1->getAmountOfAssignmentsOf($user4->getId()));
155 $this->assertEquals(1, $this->node2->getAmountOfAssignmentsOf($user4->getId()));
166 $this->assertEquals(0, count($this->root->getAssignmentsOf($user1->getId())));
167 $this->assertEquals(0, count($this->node1->getAssignmentsOf($user1->getId())));
168 $this->assertEquals(0, count($this->node2->getAssignmentsOf($user1->getId())));
170 $this->root->assignUser($user2->getId(), 6);
171 $this->node1->assignUser($user2->getId(), 6);
173 $root_ass = $this->root->getAssignmentsOf($user2->getId());
174 $node1_ass = $this->node1->getAssignmentsOf($user2->getId());
175 $node2_ass = $this->node2->getAssignmentsOf($user2->getId());
177 $this->assertEquals(1, count($root_ass));
178 $this->assertEquals(2, count($node1_ass));
179 $this->assertEquals(1, count($node2_ass));
181 $this->assertEquals($this->root->getId(), $root_ass[0]->getStudyProgramme()->getId());
182 $this->assertEquals($this->root->getId(), $node2_ass[0]->getStudyProgramme()->getId());
184 $node1_ass_prg_ids = array_map(
function ($ass) {
185 return $ass->getStudyProgramme()->getId();
187 $this->assertContains($this->root->getId(), $node1_ass_prg_ids);
188 $this->assertContains($this->node1->getId(), $node1_ass_prg_ids);
200 $ass1 = $this->root->assignUser($user->getId(), 6);
201 $this->node1->removeAssignment($ass1);
213 $ass1 = $this->node1->assignUser($user->getId(), 6);
214 $this->root->removeAssignment($ass1);
223 $ass1 = $this->root->assignUser($user->getId(), 6);
224 $this->root->removeAssignment($ass1);
225 $this->assertFalse($this->root->hasAssignmentOf($user->getId()));
234 $ass1 = $this->root->assignUser($user->getId(), 6);
236 $this->assertFalse($this->root->hasAssignmentOf($user->getId()));
247 $ass1 = $this->root->assignUser($user1->getId(), 6);
248 $ass2 = $this->node1->assignUser($user2->getId(), 6);
250 $asses = $this->node1->getAssignments();
251 $ass_ids = array_map(
function ($ass) {
252 return $ass->getId();
255 $this->assertContains($ass2->getId(), $ass_ids);
266 $prg1->addNode($prg2);
267 $prg1->setValidityOfQualificationPeriod(110);
273 $ass1 = $prg1->assignUser($user1->getId(), 6);
274 $progress2 = $prg2->getProgressForAssignment($ass1->getId());
275 $progress2->markAccredited(6);
276 $progress1 = $prg1->getProgressForAssignment($ass1->getId());
277 $this->assertTrue($progress1->isSuccessful());
279 $ass1_new = array_shift($prg1->getAssignmentsOf($user1->getId()));
280 $this->assertNull($ass1_new->getRestartDate());
291 $prg1->addNode($prg2);
292 $prg1->setValidityOfQualificationPeriod(110);
293 $prg1->setRestartPeriod(10);
299 $ass1 = $prg1->assignUser($user1->getId(), 6);
300 $progress2 = $prg2->getProgressForAssignment($ass1->getId());
301 $progress2->markAccredited(6);
302 $progress1 = $prg1->getProgressForAssignment($ass1->getId());
303 $this->assertTrue($progress1->isSuccessful());
305 $ass1_new = array_shift($prg1->getAssignmentsOf($user1->getId()));
306 $val_date =
new DateTime();
307 $val_date->add(
new DateInterval(
'P100D'));
309 $val_date->format(
'Ymd'),
310 $ass1_new->getRestartDate()->format(
'Ymd')
319 $ass = $this->root->assignUser($user1->getId(), 6);
321 $root_id = $this->root->getId();
322 $this->root->delete();
326 $ilDB = $DIC[
'ilDB'];
328 "SELECT COUNT(*) cnt " 330 .
" WHERE root_prg_id = " . $root_id
333 $this->assertEquals(0, $rec[
"cnt"]);
340 $ass1 = $this->root->assignUser($user->getId(), 6);
344 $ilDB = $DIC[
'ilDB'];
346 "SELECT COUNT(*) cnt " 348 .
" WHERE id = " . $ass1->getId()
351 $this->assertEquals(0, $rec[
"cnt"]);
362 $prg1->addNode($prg2);
367 $ass1 = $prg1->assignUser($user1->getId(), 6);
369 $progress1 = $prg1->getProgressForAssignment($ass1->getId());
370 $progress1->markFailed(6);
373 $prg1->getProgressForAssignment($ass1->getId())->getStatus(),
377 $prg2->getProgressForAssignment($ass1->getId())->getStatus(),
381 $ass2 = $ass1->restartAssignment();
383 $prg1->getProgressForAssignment($ass2->getId())->getStatus(),
387 $prg2->getProgressForAssignment($ass2->getId())->getStatus(),
391 $this->assertNotEquals($ass2->getId(), $ass1->getId());
392 $this->assertNotEquals(
393 $prg1->getProgressForAssignment($ass2->getId()),
394 $prg1->getProgressForAssignment($ass1->getId())
396 $this->assertNotEquals(
397 $prg2->getProgressForAssignment($ass2->getId()),
398 $prg2->getProgressForAssignment($ass1->getId())
401 $assignments = $prg1->getAssignmentsOf($user1->getId());
402 $this->assertCount(2, $assignments);
403 foreach ($assignments as $ass) {
404 if ($ass->getId() === $ass1->getId()) {
406 $ass->getRestartedAssignmentId(),
409 } elseif ($ass->getId() === $ass2->getId()) {
411 $ass->getRestartedAssignmentId(),
415 $this->assertFalse(
'there are more assignments than expected');
testGetAmountOfAssignments()
testDeassignRemovesEntriesInPrgUsrAssignment()
const NO_RESTARTED_ASSIGNMENT
foreach($_POST as $key=> $value) $res
testRemoveOnRootNodeOnly1()
ilException
testNoAssignmentWhenOutdated()
ilException
TestCase for the assignment of users to a programme.
testRemoveOnRootNodeOnly2()
ilException
testNoAssignmentWhenDraft()
ilException
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
testDeleteOfProgrammeRemovesEntriesInPrgUsrAssignment()
testNoAssignementWhenNotCreated()
ilException