ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStudyProgrammeLPTest Class Reference

TestCase for the learning progress of users at a programme. More...

+ Inheritance diagram for ilStudyProgrammeLPTest:
+ Collaboration diagram for ilStudyProgrammeLPTest:

Public Member Functions

 testInitialLPActive ()
 
 testInitialLPDraft ()
 
 testInitialProgressOutdated ()
 
 testMarkAccredited ()
 
 testUnmarkAccredited ()
 
 testMarkNotRelevant ()
 
 testMarkFailed ()
 
 testMarkNotFailed ()
 
 testNewNodesAreNotRelevant ()
 
 test_invalidate ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 
 newUser ()
 
 setAllNodesActive ()
 
 assignNewUserToRoot ()
 

Protected Attributes

 $backupGlobals = false
 

Detailed Description

TestCase for the learning progress of users at 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 17 of file ilStudyProgrammeLPTest.php.

Member Function Documentation

◆ assignNewUserToRoot()

ilStudyProgrammeLPTest::assignNewUserToRoot ( )
protected

Definition at line 77 of file ilStudyProgrammeLPTest.php.

References newUser().

Referenced by test_invalidate(), testInitialLPActive(), testInitialLPDraft(), testInitialProgressOutdated(), testMarkAccredited(), testMarkFailed(), testMarkNotFailed(), testMarkNotRelevant(), testNewNodesAreNotRelevant(), and testUnmarkAccredited().

78  {
79  $user = $this->newUser();
80  return array($this->root->assignUser($user->getId(), 6), $user);
81  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ newUser()

ilStudyProgrammeLPTest::newUser ( )
protected

Definition at line 63 of file ilStudyProgrammeLPTest.php.

Referenced by assignNewUserToRoot(), testMarkAccredited(), testMarkFailed(), testMarkNotFailed(), testMarkNotRelevant(), and testUnmarkAccredited().

64  {
65  $user = new ilObjUser();
66  $user->create();
67  return $user;
68  }
+ Here is the caller graph for this function:

◆ setAllNodesActive()

ilStudyProgrammeLPTest::setAllNodesActive ( )
protected

Definition at line 70 of file ilStudyProgrammeLPTest.php.

References ilStudyProgrammeSettings\STATUS_ACTIVE.

Referenced by test_invalidate(), testInitialLPActive(), testMarkAccredited(), testMarkFailed(), testMarkNotFailed(), testMarkNotRelevant(), testNewNodesAreNotRelevant(), and testUnmarkAccredited().

71  {
72  $this->root->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE)->update();
73  $this->node1->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE)->update();
74  $this->node2->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE)->update();
75  }
+ Here is the caller graph for this function:

◆ setUp()

ilStudyProgrammeLPTest::setUp ( )
protected

Definition at line 21 of file ilStudyProgrammeLPTest.php.

References $DIC, $ilUser, ilObjStudyProgramme\createInstance(), ROOT_FOLDER_ID, and user().

21  : void
22  {
23  require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
24  PHPUnit\Framework\Error\Deprecated::$enabled = false;
25 
26  global $DIC;
27  if (!$DIC) {
28  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
29  ilUnitUtil::performInitialisation();
30  }
31 
33  $this->root->putInTree(ROOT_FOLDER_ID);
34  $this->root->object_factory = new ilObjectFactoryWrapperMock();
35 
36  $this->node1 = ilObjStudyProgramme::createInstance();
37  $this->node2 = ilObjStudyProgramme::createInstance();
38 
39  $this->leaf1 = new ilStudyProgrammeLeafMock();
40  $this->leaf2 = new ilStudyProgrammeLeafMock();
41 
42  $this->root->addNode($this->node1);
43  $this->root->addNode($this->node2);
44  $this->node1->addLeaf($this->leaf1);
45  $this->node2->addLeaf($this->leaf2);
46 
47  global $DIC;
48  $tree = $DIC['tree'];
49  $this->tree = $tree;
50 
51  global $DIC;
52  $ilUser = $DIC['ilUser'];
53  $this->user = $ilUser;
54  }
Mock classes for tests.
Definition: mocks.php:20
const ROOT_FOLDER_ID
Definition: constants.php:30
user()
Definition: user.php:4
global $DIC
Definition: goto.php:24
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
$ilUser
Definition: imgupload.php:18
Mock for object factory.
Definition: mocks.php:68
+ Here is the call graph for this function:

◆ tearDown()

ilStudyProgrammeLPTest::tearDown ( )
protected

Definition at line 56 of file ilStudyProgrammeLPTest.php.

56  : void
57  {
58  if ($this->root) {
59  $this->root->delete();
60  }
61  }

◆ test_invalidate()

ilStudyProgrammeLPTest::test_invalidate ( )

Definition at line 328 of file ilStudyProgrammeLPTest.php.

References ilLPStatusWrapper\_determineStatus(), assignNewUserToRoot(), ilStudyProgrammeDIC\dic(), ilLPStatus\LP_STATUS_COMPLETED_NUM, ilLPStatus\LP_STATUS_FAILED_NUM, and setAllNodesActive().

329  {
330  $progress_repo = ilStudyProgrammeDIC::dic()['model.Progress.ilStudyProgrammeProgressRepository'];
331  $this->setAllNodesActive();
332  $yesterday = new DateTime();
333  $yesterday->sub(new DateInterval('P1D'));
334 
335  $tmp = $this->assignNewUserToRoot();
336  $ass = $tmp[0];
337  $user = $tmp[1];
338 
339  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
340  $node2_progress->markAccredited(6);
341 
342  $this->assertEquals(
344  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
345  );
346  $this->assertEquals(
348  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
349  );
350  $progress_repo->update(
351  $progress_repo->getByIds((int) $this->root->getId(), (int) $ass->getId(), (int) $user->getId())
352  ->setValidityOfQualification($yesterday)
353  );
354 
355  $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
356  $this->assertTrue($root_progress->isSuccessfulExpired());
357  $this->assertFalse($root_progress->isInvalidated());
358  $root_progress->invalidate();
359  $root_progress = array_shift($this->root->getProgressesOf($user->getId()));
360  $this->assertTrue($root_progress->isSuccessfulExpired());
361  $this->assertTrue($root_progress->isInvalidated());
362  $this->assertEquals(
364  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
365  );
366  }
const LP_STATUS_COMPLETED_NUM
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.
const LP_STATUS_FAILED_NUM
+ Here is the call graph for this function:

◆ testInitialLPActive()

ilStudyProgrammeLPTest::testInitialLPActive ( )

Definition at line 83 of file ilStudyProgrammeLPTest.php.

References ilLPStatusWrapper\_determineStatus(), assignNewUserToRoot(), ilLPStatus\LP_STATUS_IN_PROGRESS_NUM, and setAllNodesActive().

84  {
85  $this->setAllNodesActive();
86  $tmp = $this->assignNewUserToRoot();
87  $ass = $tmp[0];
88  $user = $tmp[1];
89 
90  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
91  require_once("Services/Tracking/classes/class.ilLPStatus.php");
92  $this->assertEquals(
94  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
95  );
96  $this->assertEquals(
98  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
99  );
100  $this->assertEquals(
102  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
103  );
104  }
const LP_STATUS_IN_PROGRESS_NUM
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.
+ Here is the call graph for this function:

◆ testInitialLPDraft()

ilStudyProgrammeLPTest::testInitialLPDraft ( )

Definition at line 106 of file ilStudyProgrammeLPTest.php.

References ilLPStatusWrapper\_determineStatus(), assignNewUserToRoot(), ilLPStatus\LP_STATUS_IN_PROGRESS_NUM, ilLPStatus\LP_STATUS_NOT_ATTEMPTED_NUM, ilStudyProgrammeSettings\STATUS_ACTIVE, and ilStudyProgrammeSettings\STATUS_DRAFT.

107  {
108  $this->root->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE)->update();
109  $this->node1->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE)->update();
110  $this->node2->setStatus(ilStudyProgrammeSettings::STATUS_DRAFT)->update();
111 
112  $tmp = $this->assignNewUserToRoot();
113  $user = $tmp[1];
114  $ass = $tmp[0];
115 
116  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
117  require_once("Services/Tracking/classes/class.ilLPStatus.php");
118  $this->assertEquals(
120  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
121  );
122  $this->assertEquals(
124  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
125  );
126  $this->assertEquals(
128  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
129  );
130  }
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.
+ Here is the call graph for this function:

◆ testInitialProgressOutdated()

ilStudyProgrammeLPTest::testInitialProgressOutdated ( )

Definition at line 132 of file ilStudyProgrammeLPTest.php.

References ilLPStatusWrapper\_determineStatus(), assignNewUserToRoot(), ilLPStatus\LP_STATUS_IN_PROGRESS_NUM, ilLPStatus\LP_STATUS_NOT_ATTEMPTED_NUM, ilStudyProgrammeSettings\STATUS_ACTIVE, and ilStudyProgrammeSettings\STATUS_OUTDATED.

133  {
134  $this->root->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE)->update();
135  $this->node1->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE)->update();
136  $this->node2->setStatus(ilStudyProgrammeSettings::STATUS_OUTDATED)->update();
137 
138  $tmp = $this->assignNewUserToRoot();
139  $user = $tmp[1];
140  $ass = $tmp[0];
141 
142  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
143  require_once("Services/Tracking/classes/class.ilLPStatus.php");
144  $this->assertEquals(
146  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
147  );
148  $this->assertEquals(
150  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
151  );
152  $this->assertEquals(
154  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
155  );
156  }
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.
+ Here is the call graph for this function:

◆ testMarkAccredited()

ilStudyProgrammeLPTest::testMarkAccredited ( )

Definition at line 158 of file ilStudyProgrammeLPTest.php.

References ilLPStatusWrapper\_determineStatus(), assignNewUserToRoot(), ilLPStatus\LP_STATUS_COMPLETED_NUM, ilLPStatus\LP_STATUS_IN_PROGRESS_NUM, newUser(), and setAllNodesActive().

159  {
160  $this->setAllNodesActive();
161  $tmp = $this->assignNewUserToRoot();
162  $ass = $tmp[0];
163  $user = $tmp[1];
164 
165  $user2 = $this->newUser();
166  $USER_ID = $user2->getId();
167 
168  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
169  $node2_progress->markAccredited($USER_ID);
170 
171  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
172  require_once("Services/Tracking/classes/class.ilLPStatus.php");
173  $this->assertEquals(
175  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
176  );
177  $this->assertEquals(
179  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
180  );
181  $this->assertEquals(
183  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
184  );
185  }
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.
+ Here is the call graph for this function:

◆ testMarkFailed()

ilStudyProgrammeLPTest::testMarkFailed ( )

Definition at line 249 of file ilStudyProgrammeLPTest.php.

References ilLPStatusWrapper\_determineStatus(), assignNewUserToRoot(), ilLPStatus\LP_STATUS_FAILED_NUM, ilLPStatus\LP_STATUS_IN_PROGRESS_NUM, newUser(), and setAllNodesActive().

250  {
251  $this->setAllNodesActive();
252  $tmp = $this->assignNewUserToRoot();
253  $ass = $tmp[0];
254  $user = $tmp[1];
255 
256  $user2 = $this->newUser();
257  $USER_ID = $user2->getId();
258 
259  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
260  $node2_progress->markFailed($USER_ID);
261 
262  $this->assertEquals(
264  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
265  );
266  $this->assertEquals(
268  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
269  );
270  $this->assertEquals(
272  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
273  );
274  }
const LP_STATUS_IN_PROGRESS_NUM
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.
const LP_STATUS_FAILED_NUM
+ Here is the call graph for this function:

◆ testMarkNotFailed()

ilStudyProgrammeLPTest::testMarkNotFailed ( )

Definition at line 276 of file ilStudyProgrammeLPTest.php.

References ilLPStatusWrapper\_determineStatus(), assignNewUserToRoot(), ilLPStatus\LP_STATUS_FAILED_NUM, ilLPStatus\LP_STATUS_IN_PROGRESS_NUM, newUser(), and setAllNodesActive().

277  {
278  $this->setAllNodesActive();
279  $tmp = $this->assignNewUserToRoot();
280  $ass = $tmp[0];
281  $user = $tmp[1];
282 
283  $user2 = $this->newUser();
284  $USER_ID = (int) $user2->getId();
285 
286  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
287  $node2_progress->markFailed($USER_ID);
288 
289  $this->assertEquals(
291  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
292  );
293  $this->assertEquals(
295  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
296  );
297  $this->assertEquals(
299  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
300  );
301 
302  $node2_progress->markNotFailed($USER_ID);
303  $this->assertEquals(
305  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
306  );
307  }
const LP_STATUS_IN_PROGRESS_NUM
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.
const LP_STATUS_FAILED_NUM
+ Here is the call graph for this function:

◆ testMarkNotRelevant()

ilStudyProgrammeLPTest::testMarkNotRelevant ( )

Definition at line 222 of file ilStudyProgrammeLPTest.php.

References ilLPStatusWrapper\_determineStatus(), assignNewUserToRoot(), ilLPStatus\LP_STATUS_IN_PROGRESS_NUM, ilLPStatus\LP_STATUS_NOT_ATTEMPTED_NUM, newUser(), and setAllNodesActive().

223  {
224  $this->setAllNodesActive();
225  $tmp = $this->assignNewUserToRoot();
226  $ass = $tmp[0];
227  $user = $tmp[1];
228 
229  $user2 = $this->newUser();
230  $USER_ID = $user2->getId();
231 
232  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
233  $node2_progress->markNotRelevant($USER_ID);
234 
235  $this->assertEquals(
237  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
238  );
239  $this->assertEquals(
241  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
242  );
243  $this->assertEquals(
245  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
246  );
247  }
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.
+ Here is the call graph for this function:

◆ testNewNodesAreNotRelevant()

ilStudyProgrammeLPTest::testNewNodesAreNotRelevant ( )

Definition at line 310 of file ilStudyProgrammeLPTest.php.

References ilLPStatusWrapper\_determineStatus(), assignNewUserToRoot(), ilObjStudyProgramme\createInstance(), ilLPStatus\LP_STATUS_NOT_ATTEMPTED_NUM, and setAllNodesActive().

311  {
312  $this->setAllNodesActive();
313  $tmp = $this->assignNewUserToRoot();
314  $ass = $tmp[0];
315  $user = $tmp[1];
316 
318  $this->root->addNode($node3);
319 
320  $node3_progress = array_shift($node3->getProgressesOf($user->getId()));
321  $this->assertNotNull($node3_progress);
322  $this->assertEquals(
324  ilLPStatusWrapper::_determineStatus($node3->getId(), $user->getId())
325  );
326  }
const LP_STATUS_NOT_ATTEMPTED_NUM
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.
+ Here is the call graph for this function:

◆ testUnmarkAccredited()

ilStudyProgrammeLPTest::testUnmarkAccredited ( )

Definition at line 187 of file ilStudyProgrammeLPTest.php.

References ilLPStatusWrapper\_determineStatus(), assignNewUserToRoot(), ilLPStatus\LP_STATUS_COMPLETED_NUM, ilLPStatus\LP_STATUS_IN_PROGRESS_NUM, newUser(), and setAllNodesActive().

188  {
189  $this->setAllNodesActive();
190  $tmp = $this->assignNewUserToRoot();
191  $ass = $tmp[0];
192  $user = $tmp[1];
193 
194  $user2 = $this->newUser();
195  $USER_ID = $user2->getId();
196 
197  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
198  $node2_progress->markAccredited($USER_ID);
199 
200  $this->assertEquals(
202  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
203  );
204 
205  $node2_progress->unmarkAccredited();
206 
207  $this->assertEquals(
209  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
210  );
211  $this->assertEquals(
213  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
214  );
215  $this->assertEquals(
217  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
218  );
219  }
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.
+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilStudyProgrammeLPTest::$backupGlobals = false
protected

Definition at line 19 of file ilStudyProgrammeLPTest.php.


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