ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ()
 
 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 68 of file ilStudyProgrammeLPTest.php.

References array, and newUser().

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

68  {
69  $user = $this->newUser();
70  return array($this->root->assignUser($user->getId()), $user);
71  }
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 56 of file ilStudyProgrammeLPTest.php.

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

56  {
57  $user = new ilObjUser();
58  $user->create();
59  return $user;
60  }
+ Here is the caller graph for this function:

◆ setAllNodesActive()

ilStudyProgrammeLPTest::setAllNodesActive ( )
protected

Definition at line 62 of file ilStudyProgrammeLPTest.php.

References ilStudyProgramme\STATUS_ACTIVE.

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

62  {
63  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
64  $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
65  $this->node2->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
66  }
+ Here is the caller graph for this function:

◆ setUp()

ilStudyProgrammeLPTest::setUp ( )
protected

Definition at line 18 of file ilStudyProgrammeLPTest.php.

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

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 
45  global $DIC;
46  $ilUser = $DIC['ilUser'];
47  $this->user = $ilUser;
48  }
Mock classes for tests.
Definition: mocks.php:20
user()
Definition: user.php:4
$ilUser
Definition: imgupload.php:18
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()

ilStudyProgrammeLPTest::tearDown ( )
protected

Definition at line 50 of file ilStudyProgrammeLPTest.php.

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

◆ testInitialLPActive()

ilStudyProgrammeLPTest::testInitialLPActive ( )

Definition at line 73 of file ilStudyProgrammeLPTest.php.

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

73  {
74  $this->setAllNodesActive();
75  $tmp = $this->assignNewUserToRoot();
76  $ass = $tmp[0];
77  $user = $tmp[1];
78 
79  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
80  require_once("Services/Tracking/classes/class.ilLPStatus.php");
81  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
82  , ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
83  );
84  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
85  , ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
86  );
87  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
88  , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
89  );
90  }
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 92 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.

92  {
93  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
94  $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
95  $this->node2->setStatus(ilStudyProgramme::STATUS_DRAFT)->update();
96 
97  $tmp = $this->assignNewUserToRoot();
98  $user = $tmp[1];
99  $ass = $tmp[0];
100 
101  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
102  require_once("Services/Tracking/classes/class.ilLPStatus.php");
103  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
104  , ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
105  );
106  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
107  , ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
108  );
109  $this->assertEquals( ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM
110  , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
111  );
112  }
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 114 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.

114  {
115  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
116  $this->node1->setStatus(ilStudyProgramme::STATUS_ACTIVE)->update();
117  $this->node2->setStatus(ilStudyProgramme::STATUS_OUTDATED)->update();
118 
119  $tmp = $this->assignNewUserToRoot();
120  $user = $tmp[1];
121  $ass = $tmp[0];
122 
123  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
124  require_once("Services/Tracking/classes/class.ilLPStatus.php");
125  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
126  , ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
127  );
128  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
129  , ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
130  );
131  $this->assertEquals( ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM
132  , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
133  );
134  }
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 136 of file ilStudyProgrammeLPTest.php.

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

136  {
137  $this->setAllNodesActive();
138  $tmp = $this->assignNewUserToRoot();
139  $ass = $tmp[0];
140  $user = $tmp[1];
141 
142  $user2 = $this->newUser();
143  $USER_ID = $user2->getId();
144 
145  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
146  $node2_progress->markAccredited($USER_ID);
147 
148  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
149  require_once("Services/Tracking/classes/class.ilLPStatus.php");
150  $this->assertEquals( ilLPStatus::LP_STATUS_COMPLETED_NUM
151  , ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
152  );
153  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
154  , ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
155  );
156  $this->assertEquals( ilLPStatus::LP_STATUS_COMPLETED_NUM
157  , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
158  );
159  }
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:

◆ testMarkNotRelevant()

ilStudyProgrammeLPTest::testMarkNotRelevant ( )

Definition at line 191 of file ilStudyProgrammeLPTest.php.

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

191  {
192  $this->setAllNodesActive();
193  $tmp = $this->assignNewUserToRoot();
194  $ass = $tmp[0];
195  $user = $tmp[1];
196 
197  $user2 = $this->newUser();
198  $USER_ID = $user2->getId();
199 
200  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
201  $node2_progress->markNotRelevant($USER_ID);
202 
203  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
204  , ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
205  );
206  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
207  , ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
208  );
209  $this->assertEquals( ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM
210  , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
211  );
212  }
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 215 of file ilStudyProgrammeLPTest.php.

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

215  {
216  $this->setAllNodesActive();
217  $tmp = $this->assignNewUserToRoot();
218  $ass = $tmp[0];
219  $user = $tmp[1];
220 
222  $this->root->addNode($node3);
223 
224  $node3_progress = array_shift($node3->getProgressesOf($user->getId()));
225  $this->assertNotNull($node3_progress);
226  $this->assertEquals( ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM
227  , ilLPStatusWrapper::_determineStatus($node3->getId(), $user->getId())
228  );
229  }
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 161 of file ilStudyProgrammeLPTest.php.

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

161  {
162  $this->setAllNodesActive();
163  $tmp = $this->assignNewUserToRoot();
164  $ass = $tmp[0];
165  $user = $tmp[1];
166 
167  $user2 = $this->newUser();
168  $USER_ID = $user2->getId();
169 
170  $node2_progress = array_shift($this->node2->getProgressesOf($user->getId()));
171  $node2_progress->markAccredited($USER_ID);
172 
173  $this->assertEquals( ilLPStatus::LP_STATUS_COMPLETED_NUM
174  , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
175  );
176 
177  $node2_progress->unmarkAccredited();
178 
179  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
180  , ilLPStatusWrapper::_determineStatus($this->root->getId(), $user->getId())
181  );
182  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
183  , ilLPStatusWrapper::_determineStatus($this->node1->getId(), $user->getId())
184  );
185  $this->assertEquals( ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
186  , ilLPStatusWrapper::_determineStatus($this->node2->getId(), $user->getId())
187  );
188  }
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 16 of file ilStudyProgrammeLPTest.php.


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