5 require_once(__DIR__.
"/mocks.php");
19 PHPUnit_Framework_Error_Deprecated::$enabled = FALSE;
21 require_once(
"./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
23 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
24 ilUnitUtil::performInitialisation();
27 $this->root->putInTree(ROOT_FOLDER_ID);
36 $this->root->addNode($this->node1);
37 $this->root->addNode($this->node2);
38 $this->node1->addLeaf($this->leaf1);
39 $this->node2->addLeaf($this->leaf2);
48 $this->root->delete();
65 $this->root->assignUser($user->getId());
76 $this->root->assignUser($user->getId());
85 $prg->assignUser($user->getId());
91 $ass = $this->root->assignUser($user1->getId());
92 $this->assertEquals($user1->getId(), $ass->getUserId());
101 $this->root->assignUser($user1->getId());
102 $this->assertTrue($this->root->hasAssignmentOf($user1->getId()));
103 $this->assertTrue($this->node1->hasAssignmentOf($user1->getId()));
104 $this->assertTrue($this->node2->hasAssignmentOf($user1->getId()));
106 $this->assertFalse($this->root->hasAssignmentOf($user2->getId()));
107 $this->assertFalse($this->node1->hasAssignmentOf($user2->getId()));
108 $this->assertFalse($this->node2->hasAssignmentOf($user2->getId()));
121 $this->assertEquals(0, $this->root->getAmountOfAssignmentsOf($user1->getId()));
123 $this->root->assignUser($user2->getId());
124 $this->assertEquals(1, $this->root->getAmountOfAssignmentsOf($user2->getId()));
125 $this->assertEquals(1, $this->node1->getAmountOfAssignmentsOf($user2->getId()));
126 $this->assertEquals(1, $this->node2->getAmountOfAssignmentsOf($user2->getId()));
128 $this->root->assignUser($user3->getId());
129 $this->root->assignUser($user3->getId());
130 $this->assertEquals(2, $this->root->getAmountOfAssignmentsOf($user3->getId()));
131 $this->assertEquals(2, $this->node1->getAmountOfAssignmentsOf($user3->getId()));
132 $this->assertEquals(2, $this->node2->getAmountOfAssignmentsOf($user3->getId()));
134 $this->root->assignUser($user4->getId());
135 $this->node1->assignUser($user4->getId());
136 $this->assertEquals(1, $this->root->getAmountOfAssignmentsOf($user4->getId()));
137 $this->assertEquals(2, $this->node1->getAmountOfAssignmentsOf($user4->getId()));
138 $this->assertEquals(1, $this->node2->getAmountOfAssignmentsOf($user4->getId()));
148 $this->assertEquals(0, count($this->root->getAssignmentsOf($user1->getId())));
149 $this->assertEquals(0, count($this->node1->getAssignmentsOf($user1->getId())));
150 $this->assertEquals(0, count($this->node2->getAssignmentsOf($user1->getId())));
152 $this->root->assignUser($user2->getId());
153 $this->node1->assignUser($user2->getId());
155 $root_ass = $this->root->getAssignmentsOf($user2->getId());
156 $node1_ass = $this->node1->getAssignmentsOf($user2->getId());
157 $node2_ass = $this->node2->getAssignmentsOf($user2->getId());
159 $this->assertEquals(1, count($root_ass));
160 $this->assertEquals(2, count($node1_ass));
161 $this->assertEquals(1, count($node2_ass));
163 $this->assertEquals($this->root->getId(), $root_ass[0]->getStudyProgramme()->getId());
164 $this->assertEquals($this->root->getId(), $node2_ass[0]->getStudyProgramme()->getId());
166 $node1_ass_prg_ids = array_map(
function($ass) {
167 return $ass->getStudyProgramme()->getId();
169 $this->assertContains($this->root->getId(), $node1_ass_prg_ids);
170 $this->assertContains($this->node1->getId(), $node1_ass_prg_ids);
181 $ass1 = $this->root->assignUser($user->getId());
182 $this->node1->removeAssignment($ass1);
193 $ass1 = $this->node1->assignUser($user->getId());
194 $this->root->removeAssignment($ass1);
202 $ass1 = $this->root->assignUser($user->getId());
203 $this->root->removeAssignment($ass1);
204 $this->assertFalse($this->root->hasAssignmentOf($user->getId()));
212 $ass1 = $this->root->assignUser($user->getId());
214 $this->assertFalse($this->root->hasAssignmentOf($user->getId()));
224 $ass1 = $this->root->assignUser($user1->getId());
225 $ass2 = $this->node1->assignUser($user2->getId());
227 $asses = $this->node1->getAssignments();
228 $ass_ids = array_map(
function($ass) {
229 return $ass->getId();
231 $this->assertContains($ass1->getId(), $ass_ids);
232 $this->assertContains($ass2->getId(), $ass_ids);
238 $ass = $this->root->assignUser($user1->getId());
240 $root_id = $this->root->getId();
241 $this->root->delete();
245 $ilDB = $DIC[
'ilDB'];
246 $res =
$ilDB->query(
"SELECT COUNT(*) cnt " 248 .
" WHERE root_prg_id = ".$root_id
251 $this->assertEquals(0, $rec[
"cnt"]);
257 $ass1 = $this->root->assignUser($user->getId());
261 $ilDB = $DIC[
'ilDB'];
262 $res =
$ilDB->query(
"SELECT COUNT(*) cnt " 264 .
" WHERE id = ".$ass1->getId()
267 $this->assertEquals(0, $rec[
"cnt"]);
testGetAmountOfAssignments()
testDeassignRemovesEntriesInPrgUsrAssignment()
testRemoveOnRootNodeOnly1()
ilException
Class ilObjStudyProgramme.
testNoAssignmentWhenOutdated()
ilException
TestCase for the assignment of users to a programme.
static returnDbTableName()
testRemoveOnRootNodeOnly2()
ilException
testNoAssignmentWhenDraft()
ilException
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
testDeleteOfProgrammeRemovesEntriesInPrgUsrAssignment()
testNoAssignementWhenNotCreated()
ilException