ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ()
 ilException More...
 
 testNoAssignmentWhenOutdated ()
 ilException More...
 
 testNoAssignementWhenNotCreated ()
 ilException More...
 
 testUserId ()
 
 testHasAssignmentOf ()
 
 testGetAmountOfAssignments ()
 
 testGetAssignmentsOf ()
 
 testRemoveOnRootNodeOnly1 ()
 ilException More...
 
 testRemoveOnRootNodeOnly2 ()
 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.

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 18 of file ilStudyProgrammeUserAssignmentTest.php.

References $DIC, and ilObjStudyProgramme\createInstance().

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

◆ tearDown()

ilStudyProgrammeUserAssignmentTest::tearDown ( )
protected

Definition at line 46 of file ilStudyProgrammeUserAssignmentTest.php.

46  {
47  if ($this->root) {
48  $this->root->delete();
49  }
50  }

◆ testDeassignRemovesEntriesInPrgUsrAssignment()

ilStudyProgrammeUserAssignmentTest::testDeassignRemovesEntriesInPrgUsrAssignment ( )

Definition at line 254 of file ilStudyProgrammeUserAssignmentTest.php.

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

254  {
255  $user = $this->newUser();
256  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
257  $ass1 = $this->root->assignUser($user->getId());
258  $ass1->deassign();
259 
260  global $DIC;
261  $ilDB = $DIC['ilDB'];
262  $res = $ilDB->query( "SELECT COUNT(*) cnt "
264  ." WHERE id = ".$ass1->getId()
265  );
266  $rec = $ilDB->fetchAssoc($res);
267  $this->assertEquals(0, $rec["cnt"]);
268  }
global $ilDB
global $DIC
+ Here is the call graph for this function:

◆ testDeleteOfProgrammeRemovesEntriesInPrgUsrAssignment()

ilStudyProgrammeUserAssignmentTest::testDeleteOfProgrammeRemovesEntriesInPrgUsrAssignment ( )

Definition at line 235 of file ilStudyProgrammeUserAssignmentTest.php.

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

235  {
236  $user1 = $this->newUser();
237  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
238  $ass = $this->root->assignUser($user1->getId());
239 
240  $root_id = $this->root->getId();
241  $this->root->delete();
242  $this->root = null;
243 
244  global $DIC;
245  $ilDB = $DIC['ilDB'];
246  $res = $ilDB->query( "SELECT COUNT(*) cnt "
248  ." WHERE root_prg_id = ".$root_id
249  );
250  $rec = $ilDB->fetchAssoc($res);
251  $this->assertEquals(0, $rec["cnt"]);
252  }
global $ilDB
global $DIC
+ Here is the call graph for this function:

◆ testGetAmountOfAssignments()

ilStudyProgrammeUserAssignmentTest::testGetAmountOfAssignments ( )

Definition at line 111 of file ilStudyProgrammeUserAssignmentTest.php.

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

111  {
112  $user1 = $this->newUser();
113  $user2 = $this->newUser();
114  $user3 = $this->newUser();
115  $user4 = $this->newUser();
116 
117  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
118  $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE);
119  $this->node2->setStatus(ilStudyProgramme::STATUS_ACTIVE);
120 
121  $this->assertEquals(0, $this->root->getAmountOfAssignmentsOf($user1->getId()));
122 
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()));
127 
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()));
133 
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()));
139  }
+ Here is the call graph for this function:

◆ testGetAssignments()

ilStudyProgrammeUserAssignmentTest::testGetAssignments ( )

Definition at line 217 of file ilStudyProgrammeUserAssignmentTest.php.

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

217  {
218  $user1 = $this->newUser();
219  $user2 = $this->newUser();
220 
221  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
222  $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE);
223 
224  $ass1 = $this->root->assignUser($user1->getId());
225  $ass2 = $this->node1->assignUser($user2->getId());
226 
227  $asses = $this->node1->getAssignments();
228  $ass_ids = array_map(function($ass) {
229  return $ass->getId();
230  }, $asses);
231  $this->assertContains($ass1->getId(), $ass_ids);
232  $this->assertContains($ass2->getId(), $ass_ids);
233  }
+ Here is the call graph for this function:

◆ testGetAssignmentsOf()

ilStudyProgrammeUserAssignmentTest::testGetAssignmentsOf ( )

Definition at line 141 of file ilStudyProgrammeUserAssignmentTest.php.

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

141  {
142  $user1 = $this->newUser();
143  $user2 = $this->newUser();
144 
145  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
146  $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE);
147 
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())));
151 
152  $this->root->assignUser($user2->getId());
153  $this->node1->assignUser($user2->getId());
154 
155  $root_ass = $this->root->getAssignmentsOf($user2->getId());
156  $node1_ass = $this->node1->getAssignmentsOf($user2->getId());
157  $node2_ass = $this->node2->getAssignmentsOf($user2->getId());
158 
159  $this->assertEquals(1, count($root_ass));
160  $this->assertEquals(2, count($node1_ass));
161  $this->assertEquals(1, count($node2_ass));
162 
163  $this->assertEquals($this->root->getId(), $root_ass[0]->getStudyProgramme()->getId());
164  $this->assertEquals($this->root->getId(), $node2_ass[0]->getStudyProgramme()->getId());
165 
166  $node1_ass_prg_ids = array_map(function($ass) {
167  return $ass->getStudyProgramme()->getId();
168  }, $node1_ass);
169  $this->assertContains($this->root->getId(), $node1_ass_prg_ids);
170  $this->assertContains($this->node1->getId(), $node1_ass_prg_ids);
171  }
+ Here is the call graph for this function:

◆ testHasAssignmentOf()

ilStudyProgrammeUserAssignmentTest::testHasAssignmentOf ( )

Definition at line 95 of file ilStudyProgrammeUserAssignmentTest.php.

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

95  {
96  $user1 = $this->newUser();
97  $user2 = $this->newUser();
98 
99  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
100 
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()));
105 
106  $this->assertFalse($this->root->hasAssignmentOf($user2->getId()));
107  $this->assertFalse($this->node1->hasAssignmentOf($user2->getId()));
108  $this->assertFalse($this->node2->hasAssignmentOf($user2->getId()));
109  }
+ Here is the call graph for this function:

◆ testNoAssignementWhenNotCreated()

ilStudyProgrammeUserAssignmentTest::testNoAssignementWhenNotCreated ( )

ilException

Definition at line 82 of file ilStudyProgrammeUserAssignmentTest.php.

References newUser().

82  {
83  $user = $this->newUser();
84  $prg = new ilObjStudyProgramme();
85  $prg->assignUser($user->getId());
86  }
Class ilObjStudyProgramme.
+ Here is the call graph for this function:

◆ testNoAssignmentWhenDraft()

ilStudyProgrammeUserAssignmentTest::testNoAssignmentWhenDraft ( )

ilException

Definition at line 62 of file ilStudyProgrammeUserAssignmentTest.php.

References newUser(), and ilStudyProgramme\STATUS_DRAFT.

62  {
63  $user = $this->newUser();
64  $this->assertEquals(ilStudyProgramme::STATUS_DRAFT, $this->root->getStatus());
65  $this->root->assignUser($user->getId());
66  }
+ Here is the call graph for this function:

◆ testNoAssignmentWhenOutdated()

ilStudyProgrammeUserAssignmentTest::testNoAssignmentWhenOutdated ( )

ilException

Definition at line 71 of file ilStudyProgrammeUserAssignmentTest.php.

References newUser(), and ilStudyProgramme\STATUS_OUTDATED.

71  {
72  $user = $this->newUser();
73 
74  $this->root->setStatus(ilStudyProgramme::STATUS_OUTDATED);
75  $this->assertEquals(ilStudyProgramme::STATUS_OUTDATED, $this->root->getStatus());
76  $this->root->assignUser($user->getId());
77  }
+ Here is the call graph for this function:

◆ testRemoveAssignment1()

ilStudyProgrammeUserAssignmentTest::testRemoveAssignment1 ( )

Definition at line 197 of file ilStudyProgrammeUserAssignmentTest.php.

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

197  {
198  $user = $this->newUser();
199 
200  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
201 
202  $ass1 = $this->root->assignUser($user->getId());
203  $this->root->removeAssignment($ass1);
204  $this->assertFalse($this->root->hasAssignmentOf($user->getId()));
205  }
+ Here is the call graph for this function:

◆ testRemoveAssignment2()

ilStudyProgrammeUserAssignmentTest::testRemoveAssignment2 ( )

Definition at line 207 of file ilStudyProgrammeUserAssignmentTest.php.

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

207  {
208  $user = $this->newUser();
209 
210  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
211 
212  $ass1 = $this->root->assignUser($user->getId());
213  $ass1->deassign();
214  $this->assertFalse($this->root->hasAssignmentOf($user->getId()));
215  }
+ Here is the call graph for this function:

◆ testRemoveOnRootNodeOnly1()

ilStudyProgrammeUserAssignmentTest::testRemoveOnRootNodeOnly1 ( )

ilException

Definition at line 176 of file ilStudyProgrammeUserAssignmentTest.php.

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

176  {
177  $user = $this->newUser();
178 
179  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
180 
181  $ass1 = $this->root->assignUser($user->getId());
182  $this->node1->removeAssignment($ass1);
183  }
+ Here is the call graph for this function:

◆ testRemoveOnRootNodeOnly2()

ilStudyProgrammeUserAssignmentTest::testRemoveOnRootNodeOnly2 ( )

ilException

Definition at line 188 of file ilStudyProgrammeUserAssignmentTest.php.

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

188  {
189  $user = $this->newUser();
190 
191  $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE);
192 
193  $ass1 = $this->node1->assignUser($user->getId());
194  $this->root->removeAssignment($ass1);
195  }
+ Here is the call graph for this function:

◆ testUserId()

ilStudyProgrammeUserAssignmentTest::testUserId ( )

Definition at line 88 of file ilStudyProgrammeUserAssignmentTest.php.

References newUser(), and ilStudyProgramme\STATUS_ACTIVE.

88  {
89  $user1 = $this->newUser();
90  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
91  $ass = $this->root->assignUser($user1->getId());
92  $this->assertEquals($user1->getId(), $ass->getUserId());
93  }
+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilStudyProgrammeUserAssignmentTest::$backupGlobals = FALSE
protected

Definition at line 16 of file ilStudyProgrammeUserAssignmentTest.php.


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