5 require_once(__DIR__ .
"/mocks.php");
21 PHPUnit_Framework_Error_Deprecated::$enabled =
false;
23 require_once(
"./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
25 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
26 ilUnitUtil::performInitialisation();
29 $this->root->putInTree(ROOT_FOLDER_ID);
38 $this->root->addNode($this->node1);
39 $this->root->addNode($this->node2);
40 $this->node1->addLeaf($this->leaf1);
41 $this->node2->addLeaf($this->leaf2);
51 $this->root->delete();
70 $this->root->assignUser(
$user->getId());
82 $this->root->assignUser(
$user->getId());
92 $prg->assignUser(
$user->getId());
99 $ass = $this->root->assignUser($user1->getId());
100 $this->assertEquals($user1->getId(), $ass->getUserId());
110 $this->root->assignUser($user1->getId());
111 $this->assertTrue($this->root->hasAssignmentOf($user1->getId()));
112 $this->assertTrue($this->node1->hasAssignmentOf($user1->getId()));
113 $this->assertTrue($this->node2->hasAssignmentOf($user1->getId()));
115 $this->assertFalse($this->root->hasAssignmentOf($user2->getId()));
116 $this->assertFalse($this->node1->hasAssignmentOf($user2->getId()));
117 $this->assertFalse($this->node2->hasAssignmentOf($user2->getId()));
131 $this->assertEquals(0, $this->root->getAmountOfAssignmentsOf($user1->getId()));
133 $this->root->assignUser($user2->getId());
134 $this->assertEquals(1, $this->root->getAmountOfAssignmentsOf($user2->getId()));
135 $this->assertEquals(1, $this->node1->getAmountOfAssignmentsOf($user2->getId()));
136 $this->assertEquals(1, $this->node2->getAmountOfAssignmentsOf($user2->getId()));
138 $this->root->assignUser($user3->getId());
139 $this->root->assignUser($user3->getId());
140 $this->assertEquals(2, $this->root->getAmountOfAssignmentsOf($user3->getId()));
141 $this->assertEquals(2, $this->node1->getAmountOfAssignmentsOf($user3->getId()));
142 $this->assertEquals(2, $this->node2->getAmountOfAssignmentsOf($user3->getId()));
144 $this->root->assignUser($user4->getId());
145 $this->node1->assignUser($user4->getId());
146 $this->assertEquals(1, $this->root->getAmountOfAssignmentsOf($user4->getId()));
147 $this->assertEquals(2, $this->node1->getAmountOfAssignmentsOf($user4->getId()));
148 $this->assertEquals(1, $this->node2->getAmountOfAssignmentsOf($user4->getId()));
159 $this->assertEquals(0, count($this->root->getAssignmentsOf($user1->getId())));
160 $this->assertEquals(0, count($this->node1->getAssignmentsOf($user1->getId())));
161 $this->assertEquals(0, count($this->node2->getAssignmentsOf($user1->getId())));
163 $this->root->assignUser($user2->getId());
164 $this->node1->assignUser($user2->getId());
166 $root_ass = $this->root->getAssignmentsOf($user2->getId());
167 $node1_ass = $this->node1->getAssignmentsOf($user2->getId());
168 $node2_ass = $this->node2->getAssignmentsOf($user2->getId());
170 $this->assertEquals(1, count($root_ass));
171 $this->assertEquals(2, count($node1_ass));
172 $this->assertEquals(1, count($node2_ass));
174 $this->assertEquals($this->root->getId(), $root_ass[0]->getStudyProgramme()->getId());
175 $this->assertEquals($this->root->getId(), $node2_ass[0]->getStudyProgramme()->getId());
177 $node1_ass_prg_ids = array_map(
function ($ass) {
178 return $ass->getStudyProgramme()->getId();
180 $this->assertContains($this->root->getId(), $node1_ass_prg_ids);
181 $this->assertContains($this->node1->getId(), $node1_ass_prg_ids);
193 $ass1 = $this->root->assignUser(
$user->getId());
194 $this->node1->removeAssignment($ass1);
206 $ass1 = $this->node1->assignUser(
$user->getId());
207 $this->root->removeAssignment($ass1);
216 $ass1 = $this->root->assignUser(
$user->getId());
217 $this->root->removeAssignment($ass1);
218 $this->assertFalse($this->root->hasAssignmentOf(
$user->getId()));
227 $ass1 = $this->root->assignUser(
$user->getId());
229 $this->assertFalse($this->root->hasAssignmentOf(
$user->getId()));
240 $ass1 = $this->root->assignUser($user1->getId());
241 $ass2 = $this->node1->assignUser($user2->getId());
243 $asses = $this->node1->getAssignments();
244 $ass_ids = array_map(
function ($ass) {
245 return $ass->getId();
247 $this->assertContains($ass1->getId(), $ass_ids);
248 $this->assertContains($ass2->getId(), $ass_ids);
255 $ass = $this->root->assignUser($user1->getId());
257 $root_id = $this->root->getId();
258 $this->root->delete();
262 $ilDB = $DIC[
'ilDB'];
264 "SELECT COUNT(*) cnt " 266 .
" WHERE root_prg_id = " . $root_id
269 $this->assertEquals(0, $rec[
"cnt"]);
276 $ass1 = $this->root->assignUser(
$user->getId());
280 $ilDB = $DIC[
'ilDB'];
282 "SELECT COUNT(*) cnt " 284 .
" WHERE id = " . $ass1->getId()
287 $this->assertEquals(0, $rec[
"cnt"]);
testGetAmountOfAssignments()
testDeassignRemovesEntriesInPrgUsrAssignment()
foreach($_POST as $key=> $value) $res
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