ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilStudyProgrammeUserAssignmentTest Class Reference

TestCase for the assignment of users to a programme. More...

+ Inheritance diagram for ilStudyProgrammeUserAssignmentTest:
+ Collaboration diagram for ilStudyProgrammeUserAssignmentTest:

Public Member Functions

 testNoAssignmentWhenDraft ()
 @expectedException ilException More...
 
 testNoAssignmentWhenOutdated ()
 @expectedException ilException More...
 
 testNoAssignementWhenNotCreated ()
 @expectedException ilException More...
 
 testUserId ()
 
 testHasAssignmentOf ()
 
 testGetAmountOfAssignments ()
 
 testGetAssignmentsOf ()
 
 testRemoveOnRootNodeOnly1 ()
 @expectedException ilException More...
 
 testRemoveOnRootNodeOnly2 ()
 @expectedException ilException More...
 
 testRemoveAssignment1 ()
 
 testRemoveAssignment2 ()
 
 testGetAssignments ()
 
 testDeleteOfProgrammeRemovesEntriesInPrgUsrAssignment ()
 
 testDeassignRemovesEntriesInPrgUsrAssignment ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 
 newUser ()
 

Protected Attributes

 $backupGlobals = false
 

Detailed Description

TestCase for the assignment of users to a programme.

@group needsInstalledILIAS

Author
Michael Herren mh@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Richard Klees richa.nosp@m.rd.k.nosp@m.lees@.nosp@m.conc.nosp@m.epts-.nosp@m.and-.nosp@m.train.nosp@m.ing..nosp@m.de
Version
1.0.0

Definition at line 15 of file ilStudyProgrammeUserAssignmentTest.php.

Member Function Documentation

◆ newUser()

◆ setUp()

ilStudyProgrammeUserAssignmentTest::setUp ( )
protected

Definition at line 19 of file ilStudyProgrammeUserAssignmentTest.php.

20 {
21 PHPUnit_Framework_Error_Deprecated::$enabled = false;
22
23 require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
24
25 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
26 ilUnitUtil::performInitialisation();
27
29 $this->root->putInTree(ROOT_FOLDER_ID);
30 $this->root->object_factory = new ilObjectFactoryWrapperMock();
31
34
35 $this->leaf1 = new ilStudyProgrammeLeafMock();
36 $this->leaf2 = new ilStudyProgrammeLeafMock();
37
38 $this->root->addNode($this->node1);
39 $this->root->addNode($this->node2);
40 $this->node1->addLeaf($this->leaf1);
41 $this->node2->addLeaf($this->leaf2);
42
43 global $DIC;
44 $tree = $DIC['tree'];
45 $this->tree = $tree;
46 }
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
Mock for object factory.
Definition: mocks.php:69
Mock classes for tests.
Definition: mocks.php:21
global $DIC
Definition: saml.php:7

References $DIC, and ilObjStudyProgramme\createInstance().

+ Here is the call graph for this function:

◆ tearDown()

ilStudyProgrammeUserAssignmentTest::tearDown ( )
protected

Definition at line 48 of file ilStudyProgrammeUserAssignmentTest.php.

49 {
50 if ($this->root) {
51 $this->root->delete();
52 }
53 }

◆ testDeassignRemovesEntriesInPrgUsrAssignment()

ilStudyProgrammeUserAssignmentTest::testDeassignRemovesEntriesInPrgUsrAssignment ( )

Definition at line 272 of file ilStudyProgrammeUserAssignmentTest.php.

273 {
274 $user = $this->newUser();
275 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
276 $ass1 = $this->root->assignUser($user->getId());
277 $ass1->deassign();
278
279 global $DIC;
280 $ilDB = $DIC['ilDB'];
281 $res = $ilDB->query(
282 "SELECT COUNT(*) cnt "
284 . " WHERE id = " . $ass1->getId()
285 );
286 $rec = $ilDB->fetchAssoc($res);
287 $this->assertEquals(0, $rec["cnt"]);
288 }
foreach($_POST as $key=> $value) $res
global $ilDB

References $DIC, $ilDB, $res, newUser(), ilStudyProgrammeAssignment\returnDbTableName(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testDeleteOfProgrammeRemovesEntriesInPrgUsrAssignment()

ilStudyProgrammeUserAssignmentTest::testDeleteOfProgrammeRemovesEntriesInPrgUsrAssignment ( )

Definition at line 251 of file ilStudyProgrammeUserAssignmentTest.php.

252 {
253 $user1 = $this->newUser();
254 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
255 $ass = $this->root->assignUser($user1->getId());
256
257 $root_id = $this->root->getId();
258 $this->root->delete();
259 $this->root = null;
260
261 global $DIC;
262 $ilDB = $DIC['ilDB'];
263 $res = $ilDB->query(
264 "SELECT COUNT(*) cnt "
266 . " WHERE root_prg_id = " . $root_id
267 );
268 $rec = $ilDB->fetchAssoc($res);
269 $this->assertEquals(0, $rec["cnt"]);
270 }

References $DIC, $ilDB, $res, newUser(), ilStudyProgrammeAssignment\returnDbTableName(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testGetAmountOfAssignments()

ilStudyProgrammeUserAssignmentTest::testGetAmountOfAssignments ( )

Definition at line 120 of file ilStudyProgrammeUserAssignmentTest.php.

121 {
122 $user1 = $this->newUser();
123 $user2 = $this->newUser();
124 $user3 = $this->newUser();
125 $user4 = $this->newUser();
126
127 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
128 $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE);
129 $this->node2->setStatus(ilStudyProgramme::STATUS_ACTIVE);
130
131 $this->assertEquals(0, $this->root->getAmountOfAssignmentsOf($user1->getId()));
132
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()));
137
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()));
143
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()));
149 }

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testGetAssignments()

ilStudyProgrammeUserAssignmentTest::testGetAssignments ( )

Definition at line 232 of file ilStudyProgrammeUserAssignmentTest.php.

233 {
234 $user1 = $this->newUser();
235 $user2 = $this->newUser();
236
237 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
238 $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE);
239
240 $ass1 = $this->root->assignUser($user1->getId());
241 $ass2 = $this->node1->assignUser($user2->getId());
242
243 $asses = $this->node1->getAssignments();
244 $ass_ids = array_map(function ($ass) {
245 return $ass->getId();
246 }, $asses);
247 $this->assertContains($ass1->getId(), $ass_ids);
248 $this->assertContains($ass2->getId(), $ass_ids);
249 }

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testGetAssignmentsOf()

ilStudyProgrammeUserAssignmentTest::testGetAssignmentsOf ( )

Definition at line 151 of file ilStudyProgrammeUserAssignmentTest.php.

152 {
153 $user1 = $this->newUser();
154 $user2 = $this->newUser();
155
156 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
157 $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE);
158
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())));
162
163 $this->root->assignUser($user2->getId());
164 $this->node1->assignUser($user2->getId());
165
166 $root_ass = $this->root->getAssignmentsOf($user2->getId());
167 $node1_ass = $this->node1->getAssignmentsOf($user2->getId());
168 $node2_ass = $this->node2->getAssignmentsOf($user2->getId());
169
170 $this->assertEquals(1, count($root_ass));
171 $this->assertEquals(2, count($node1_ass));
172 $this->assertEquals(1, count($node2_ass));
173
174 $this->assertEquals($this->root->getId(), $root_ass[0]->getStudyProgramme()->getId());
175 $this->assertEquals($this->root->getId(), $node2_ass[0]->getStudyProgramme()->getId());
176
177 $node1_ass_prg_ids = array_map(function ($ass) {
178 return $ass->getStudyProgramme()->getId();
179 }, $node1_ass);
180 $this->assertContains($this->root->getId(), $node1_ass_prg_ids);
181 $this->assertContains($this->node1->getId(), $node1_ass_prg_ids);
182 }

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testHasAssignmentOf()

ilStudyProgrammeUserAssignmentTest::testHasAssignmentOf ( )

Definition at line 103 of file ilStudyProgrammeUserAssignmentTest.php.

104 {
105 $user1 = $this->newUser();
106 $user2 = $this->newUser();
107
108 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
109
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()));
114
115 $this->assertFalse($this->root->hasAssignmentOf($user2->getId()));
116 $this->assertFalse($this->node1->hasAssignmentOf($user2->getId()));
117 $this->assertFalse($this->node2->hasAssignmentOf($user2->getId()));
118 }

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testNoAssignementWhenNotCreated()

ilStudyProgrammeUserAssignmentTest::testNoAssignementWhenNotCreated ( )

@expectedException ilException

Definition at line 88 of file ilStudyProgrammeUserAssignmentTest.php.

89 {
90 $user = $this->newUser();
91 $prg = new ilObjStudyProgramme();
92 $prg->assignUser($user->getId());
93 }
Class ilObjStudyProgramme.

References newUser().

+ Here is the call graph for this function:

◆ testNoAssignmentWhenDraft()

ilStudyProgrammeUserAssignmentTest::testNoAssignmentWhenDraft ( )

@expectedException ilException

Definition at line 66 of file ilStudyProgrammeUserAssignmentTest.php.

67 {
68 $user = $this->newUser();
69 $this->assertEquals(ilStudyProgramme::STATUS_DRAFT, $this->root->getStatus());
70 $this->root->assignUser($user->getId());
71 }

References newUser(), and ilStudyProgramme\STATUS_DRAFT.

+ Here is the call graph for this function:

◆ testNoAssignmentWhenOutdated()

ilStudyProgrammeUserAssignmentTest::testNoAssignmentWhenOutdated ( )

@expectedException ilException

Definition at line 76 of file ilStudyProgrammeUserAssignmentTest.php.

77 {
78 $user = $this->newUser();
79
80 $this->root->setStatus(ilStudyProgramme::STATUS_OUTDATED);
81 $this->assertEquals(ilStudyProgramme::STATUS_OUTDATED, $this->root->getStatus());
82 $this->root->assignUser($user->getId());
83 }

References newUser(), and ilStudyProgramme\STATUS_OUTDATED.

+ Here is the call graph for this function:

◆ testRemoveAssignment1()

ilStudyProgrammeUserAssignmentTest::testRemoveAssignment1 ( )

Definition at line 210 of file ilStudyProgrammeUserAssignmentTest.php.

211 {
212 $user = $this->newUser();
213
214 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
215
216 $ass1 = $this->root->assignUser($user->getId());
217 $this->root->removeAssignment($ass1);
218 $this->assertFalse($this->root->hasAssignmentOf($user->getId()));
219 }

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testRemoveAssignment2()

ilStudyProgrammeUserAssignmentTest::testRemoveAssignment2 ( )

Definition at line 221 of file ilStudyProgrammeUserAssignmentTest.php.

222 {
223 $user = $this->newUser();
224
225 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
226
227 $ass1 = $this->root->assignUser($user->getId());
228 $ass1->deassign();
229 $this->assertFalse($this->root->hasAssignmentOf($user->getId()));
230 }

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testRemoveOnRootNodeOnly1()

ilStudyProgrammeUserAssignmentTest::testRemoveOnRootNodeOnly1 ( )

@expectedException ilException

Definition at line 187 of file ilStudyProgrammeUserAssignmentTest.php.

188 {
189 $user = $this->newUser();
190
191 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
192
193 $ass1 = $this->root->assignUser($user->getId());
194 $this->node1->removeAssignment($ass1);
195 }

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testRemoveOnRootNodeOnly2()

ilStudyProgrammeUserAssignmentTest::testRemoveOnRootNodeOnly2 ( )

@expectedException ilException

Definition at line 200 of file ilStudyProgrammeUserAssignmentTest.php.

201 {
202 $user = $this->newUser();
203
204 $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE);
205
206 $ass1 = $this->node1->assignUser($user->getId());
207 $this->root->removeAssignment($ass1);
208 }

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testUserId()

ilStudyProgrammeUserAssignmentTest::testUserId ( )

Definition at line 95 of file ilStudyProgrammeUserAssignmentTest.php.

96 {
97 $user1 = $this->newUser();
98 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
99 $ass = $this->root->assignUser($user1->getId());
100 $this->assertEquals($user1->getId(), $ass->getUserId());
101 }

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilStudyProgrammeUserAssignmentTest::$backupGlobals = false
protected

Definition at line 17 of file ilStudyProgrammeUserAssignmentTest.php.


The documentation for this class was generated from the following file: