ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ()
 

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 15 of file ilStudyProgrammeLPTest.php.

Member Function Documentation

◆ assignNewUserToRoot()

ilStudyProgrammeLPTest::assignNewUserToRoot ( )
protected

Definition at line 73 of file ilStudyProgrammeLPTest.php.

References array, and newUser().

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

74  {
75  $user = $this->newUser();
76  return array($this->root->assignUser($user->getId()), $user);
77  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ newUser()

ilStudyProgrammeLPTest::newUser ( )
protected

Definition at line 59 of file ilStudyProgrammeLPTest.php.

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

60  {
61  $user = new ilObjUser();
62  $user->create();
63  return $user;
64  }
+ Here is the caller graph for this function:

◆ setAllNodesActive()

ilStudyProgrammeLPTest::setAllNodesActive ( )
protected

Definition at line 66 of file ilStudyProgrammeLPTest.php.

References ilStudyProgramme\STATUS_ACTIVE.

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

67  {
68  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
69  $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
70  $this->node2->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
71  }
+ Here is the caller graph for this function:

◆ setUp()

ilStudyProgrammeLPTest::setUp ( )
protected

Definition at line 19 of file ilStudyProgrammeLPTest.php.

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

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 
32  $this->node1 = ilObjStudyProgramme::createInstance();
33  $this->node2 = ilObjStudyProgramme::createInstance();
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 
47  global $DIC;
48  $ilUser = $DIC['ilUser'];
49  $this->user = $ilUser;
50  }
Mock classes for tests.
Definition: mocks.php:20
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
$ilUser
Definition: imgupload.php:18
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
Mock for object factory.
Definition: mocks.php:68
+ Here is the call graph for this function:

◆ tearDown()

ilStudyProgrammeLPTest::tearDown ( )
protected

Definition at line 52 of file ilStudyProgrammeLPTest.php.

53  {
54  if ($this->root) {
55  $this->root->delete();
56  }
57  }

◆ testInitialLPActive()

ilStudyProgrammeLPTest::testInitialLPActive ( )

Definition at line 79 of file ilStudyProgrammeLPTest.php.

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

80  {
81  $this->setAllNodesActive();
82  $tmp = $this->assignNewUserToRoot();
83  $ass = $tmp[0];
84  $user = $tmp[1];
85 
86  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
87  require_once("Services/Tracking/classes/class.ilLPStatus.php");
88  $this->assertEquals(
90  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
91  );
92  $this->assertEquals(
94  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
95  );
96  $this->assertEquals(
98  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
99  );
100  }
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 102 of file ilStudyProgrammeLPTest.php.

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

103  {
104  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
105  $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
106  $this->node2->setStatus(ilStudyProgramme::STATUS_DRAFT)->update();
107 
108  $tmp = $this->assignNewUserToRoot();
109  $user = $tmp[1];
110  $ass = $tmp[0];
111 
112  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
113  require_once("Services/Tracking/classes/class.ilLPStatus.php");
114  $this->assertEquals(
116  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
117  );
118  $this->assertEquals(
120  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
121  );
122  $this->assertEquals(
124  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
125  );
126  }
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 128 of file ilStudyProgrammeLPTest.php.

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

129  {
130  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
131  $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
132  $this->node2->setStatus(ilStudyProgramme::STATUS_OUTDATED)->update();
133 
134  $tmp = $this->assignNewUserToRoot();
135  $user = $tmp[1];
136  $ass = $tmp[0];
137 
138  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
139  require_once("Services/Tracking/classes/class.ilLPStatus.php");
140  $this->assertEquals(
142  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
143  );
144  $this->assertEquals(
146  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
147  );
148  $this->assertEquals(
150  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
151  );
152  }
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 154 of file ilStudyProgrammeLPTest.php.

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

155  {
156  $this->setAllNodesActive();
157  $tmp = $this->assignNewUserToRoot();
158  $ass = $tmp[0];
159  $user = $tmp[1];
160 
161  $user2 = $this->newUser();
162  $USER_ID = $user2->getId();
163 
164  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
165  $node2_progress->markAccredited($USER_ID);
166 
167  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
168  require_once("Services/Tracking/classes/class.ilLPStatus.php");
169  $this->assertEquals(
171  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
172  );
173  $this->assertEquals(
175  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
176  );
177  $this->assertEquals(
179  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
180  );
181  }
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 245 of file ilStudyProgrammeLPTest.php.

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

246  {
247  $this->setAllNodesActive();
248  $tmp = $this->assignNewUserToRoot();
249  $ass = $tmp[0];
250  $user = $tmp[1];
251 
252  $user2 = $this->newUser();
253  $USER_ID = $user2->getId();
254 
255  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
256  $node2_progress->markFailed($USER_ID);
257 
258  $this->assertEquals(
260  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
261  );
262  $this->assertEquals(
264  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
265  );
266  $this->assertEquals(
268  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
269  );
270  }
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 272 of file ilStudyProgrammeLPTest.php.

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

273  {
274  $this->setAllNodesActive();
275  $tmp = $this->assignNewUserToRoot();
276  $ass = $tmp[0];
277  $user = $tmp[1];
278 
279  $user2 = $this->newUser();
280  $USER_ID = $user2->getId();
281 
282  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
283  $node2_progress->markFailed($USER_ID);
284 
285  $this->assertEquals(
287  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
288  );
289  $this->assertEquals(
291  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
292  );
293  $this->assertEquals(
295  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
296  );
297 
298  $node2_progress->markNotFailed($USER_ID);
299  $this->assertEquals(
301  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
302  );
303  }
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 218 of file ilStudyProgrammeLPTest.php.

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

219  {
220  $this->setAllNodesActive();
221  $tmp = $this->assignNewUserToRoot();
222  $ass = $tmp[0];
223  $user = $tmp[1];
224 
225  $user2 = $this->newUser();
226  $USER_ID = $user2->getId();
227 
228  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
229  $node2_progress->markNotRelevant($USER_ID);
230 
231  $this->assertEquals(
233  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
234  );
235  $this->assertEquals(
237  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
238  );
239  $this->assertEquals(
241  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
242  );
243  }
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 306 of file ilStudyProgrammeLPTest.php.

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

307  {
308  $this->setAllNodesActive();
309  $tmp = $this->assignNewUserToRoot();
310  $ass = $tmp[0];
311  $user = $tmp[1];
312 
314  $this->root->addNode($node3);
315 
316  $node3_progress = array_shift($node3->getProgressesOf($user->getId()));
317  $this->assertNotNull($node3_progress);
318  $this->assertEquals(
320  ilLPStatusWrapper::_determineStatus($node3->getId(), $user->getId())
321  );
322  }
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 183 of file ilStudyProgrammeLPTest.php.

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

184  {
185  $this->setAllNodesActive();
186  $tmp = $this->assignNewUserToRoot();
187  $ass = $tmp[0];
188  $user = $tmp[1];
189 
190  $user2 = $this->newUser();
191  $USER_ID = $user2->getId();
192 
193  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
194  $node2_progress->markAccredited($USER_ID);
195 
196  $this->assertEquals(
198  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
199  );
200 
201  $node2_progress->unmarkAccredited();
202 
203  $this->assertEquals(
205  ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
206  );
207  $this->assertEquals(
209  ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
210  );
211  $this->assertEquals(
213  ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
214  );
215  }
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 17 of file ilStudyProgrammeLPTest.php.


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