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

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

+ Inheritance diagram for ilStudyProgrammeProgressCalculationTest:
+ Collaboration diagram for ilStudyProgrammeProgressCalculationTest:

Public Member Functions

 testProgress1 ()
 
 testProgress2 ()
 
 testProgress3 ()
 
 testProgress4 ()
 
 testInitialProgressOnOptionalNodes ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 
 newUser ()
 
 setUpNodes ($top, $data)
 

Protected Attributes

 $backupGlobals = false
 

Detailed Description

TestCase for the assignment of users to a programme.

@group needsInstalledILIAS

Author
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 14 of file ilStudyProgrammeProgressCalculationTest.php.

Member Function Documentation

◆ newUser()

ilStudyProgrammeProgressCalculationTest::newUser ( )
protected

Definition at line 49 of file ilStudyProgrammeProgressCalculationTest.php.

50 {
51 $user = new ilObjUser();
52 $user->create();
53 return $user;
54 }

Referenced by testInitialProgressOnOptionalNodes(), testProgress1(), testProgress2(), testProgress3(), and testProgress4().

+ Here is the caller graph for this function:

◆ setUp()

ilStudyProgrammeProgressCalculationTest::setUp ( )
protected

Definition at line 18 of file ilStudyProgrammeProgressCalculationTest.php.

19 {
20 PHPUnit_Framework_Error_Deprecated::$enabled = false;
21
22 require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
23
24 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
25 ilUnitUtil::performInitialisation();
26
28 $this->root->putInTree(ROOT_FOLDER_ID);
29 $this->root->object_factory = new ilObjectFactoryWrapperMock();
30 $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)
31 ->update();
32
33 global $DIC;
34 $tree = $DIC['tree'];
35 $this->tree = $tree;
36
37 global $DIC;
38 $ilUser = $DIC['ilUser'];
39 $this->user = $ilUser;
40 }
user()
Definition: user.php:4
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
Mock for object factory.
Definition: mocks.php:69
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18

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

+ Here is the call graph for this function:

◆ setUpNodes()

ilStudyProgrammeProgressCalculationTest::setUpNodes (   $top,
  $data 
)
protected

Definition at line 56 of file ilStudyProgrammeProgressCalculationTest.php.

57 {
58 if (!array_key_exists("points", $data)) {
59 throw new Exception("Expected to find 'points' in data array.");
60 }
61
62 $top->setPoints($data["points"]);
63
64 foreach ($data as $node_name => $data2) {
65 if ($node_name == "points") {
66 continue;
67 }
68 if (isset($this->$node_name)) {
69 throw new Exception("Node $node_name already exists.");
70 }
71
72 if ($data2 == null) {
73 $this->$node_name = new ilStudyProgrammeLeafMock();
74 $top->addLeaf($this->$node_name);
75 } else {
76 $this->$node_name = ilObjStudyProgramme::createInstance();
77 $this->$node_name->object_factory = new ilObjectFactoryWrapperMock();
78 $top->addNode($this->$node_name);
79 $this->setUpNodes($this->$node_name, $data2);
80 $this->$node_name->setStatus(ilStudyProgramme::STATUS_ACTIVE)
81 ->update();
82 }
83 }
84 }
Mock classes for tests.
Definition: mocks.php:21

References $data, ilObjStudyProgramme\createInstance(), setUpNodes(), and ilStudyProgramme\STATUS_ACTIVE.

Referenced by setUpNodes(), testInitialProgressOnOptionalNodes(), testProgress1(), testProgress2(), testProgress3(), and testProgress4().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tearDown()

ilStudyProgrammeProgressCalculationTest::tearDown ( )
protected

Definition at line 42 of file ilStudyProgrammeProgressCalculationTest.php.

43 {
44 if ($this->root) {
45 $this->root->delete();
46 }
47 }

◆ testInitialProgressOnOptionalNodes()

ilStudyProgrammeProgressCalculationTest::testInitialProgressOnOptionalNodes ( )

Definition at line 196 of file ilStudyProgrammeProgressCalculationTest.php.

197 {
198 $this->setUpNodes($this->root, array( "points" => 0
199 , "node1" => array( "points" => 100
200 , "leaf11" => null
201 , "leaf12" => null
202 )
203 , "node2" => array( "points" => 100
204 , "leaf21" => null
205 , "leaf22" => null
206 )
207 ));
208
209 $user = $this->newUser();
210 $user_id = $user->getId();
211 $ass = $this->root->assignUser($user->getId());
212 $ass_id = $ass->getId();
213
214 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $this->root->getProgressForAssignment($ass_id)->getStatus());
215
216 $this->leaf11->markCompletedFor($user_id);
217
218 $this->assertEquals(ilStudyProgrammeProgress::STATUS_COMPLETED, $this->root->getProgressForAssignment($ass_id)->getStatus());
219 }

References newUser(), setUpNodes(), ilStudyProgrammeProgress\STATUS_COMPLETED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

+ Here is the call graph for this function:

◆ testProgress1()

ilStudyProgrammeProgressCalculationTest::testProgress1 ( )

Definition at line 86 of file ilStudyProgrammeProgressCalculationTest.php.

87 {
88 $this->setUpNodes($this->root, array( "points" => 200
89 , "node1" => array( "points" => 100
90 , "leaf11" => null
91 , "leaf12" => null
92 )
93 , "node2" => array( "points" => 100
94 , "leaf21" => null
95 , "leaf22" => null
96 )
97 ));
98
99 $user = $this->newUser();
100 $user_id = $user->getId();
101 $ass = $this->root->assignUser($user->getId());
102 $ass_id = $ass->getId();
103
104 $this->leaf11->markCompletedFor($user_id);
105 $this->leaf21->markCompletedFor($user_id);
106
107 $this->assertEquals(ilStudyProgrammeProgress::STATUS_COMPLETED, $this->root->getProgressForAssignment($ass_id)->getStatus());
108 $this->assertEquals(ilStudyProgrammeProgress::STATUS_COMPLETED, $this->node1->getProgressForAssignment($ass_id)->getStatus());
109 $this->assertEquals(ilStudyProgrammeProgress::STATUS_COMPLETED, $this->node2->getProgressForAssignment($ass_id)->getStatus());
110 }

References newUser(), setUpNodes(), and ilStudyProgrammeProgress\STATUS_COMPLETED.

+ Here is the call graph for this function:

◆ testProgress2()

ilStudyProgrammeProgressCalculationTest::testProgress2 ( )

Definition at line 112 of file ilStudyProgrammeProgressCalculationTest.php.

113 {
114 $this->setUpNodes($this->root, array( "points" => 200
115 , "node1" => array( "points" => 100
116 , "leaf11" => null
117 , "leaf12" => null
118 )
119 , "node2" => array( "points" => 100
120 , "leaf21" => null
121 , "leaf22" => null
122 )
123 ));
124
125 $user = $this->newUser();
126 $user_id = $user->getId();
127 $ass = $this->root->assignUser($user->getId());
128 $ass_id = $ass->getId();
129
130 $this->node1->getProgressForAssignment($ass_id)
131 ->markAccredited($this->user->getId());
132 $this->leaf21->markCompletedFor($user_id);
133
134 $this->assertEquals(ilStudyProgrammeProgress::STATUS_COMPLETED, $this->root->getProgressForAssignment($ass_id)->getStatus());
135 $this->assertEquals(ilStudyProgrammeProgress::STATUS_ACCREDITED, $this->node1->getProgressForAssignment($ass_id)->getStatus());
136 $this->assertEquals(ilStudyProgrammeProgress::STATUS_COMPLETED, $this->node2->getProgressForAssignment($ass_id)->getStatus());
137 }

References newUser(), setUpNodes(), ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_COMPLETED, and user().

+ Here is the call graph for this function:

◆ testProgress3()

ilStudyProgrammeProgressCalculationTest::testProgress3 ( )

Definition at line 139 of file ilStudyProgrammeProgressCalculationTest.php.

140 {
141 $this->setUpNodes($this->root, array( "points" => 200
142 , "node1" => array( "points" => 100
143 , "leaf11" => null
144 , "leaf12" => null
145 )
146 , "node2" => array( "points" => 100
147 , "leaf21" => null
148 , "leaf22" => null
149 )
150 ));
151
152 $user = $this->newUser();
153 $user_id = $user->getId();
154 $ass = $this->root->assignUser($user->getId());
155 $ass_id = $ass->getId();
156
157 $this->node1->getProgressForAssignment($ass_id)
158 ->markNotRelevant($this->user->getId());
159 $this->root->getProgressForAssignment($ass_id)
160 ->setRequiredAmountOfPoints(100, $this->user->getId());
161 $this->leaf21->markCompletedFor($user_id);
162
163 $this->assertEquals(ilStudyProgrammeProgress::STATUS_COMPLETED, $this->root->getProgressForAssignment($ass_id)->getStatus());
164 $this->assertEquals(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT, $this->node1->getProgressForAssignment($ass_id)->getStatus());
165 $this->assertEquals(ilStudyProgrammeProgress::STATUS_COMPLETED, $this->node2->getProgressForAssignment($ass_id)->getStatus());
166 }

References newUser(), setUpNodes(), ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, and user().

+ Here is the call graph for this function:

◆ testProgress4()

ilStudyProgrammeProgressCalculationTest::testProgress4 ( )

Definition at line 168 of file ilStudyProgrammeProgressCalculationTest.php.

169 {
170 $this->setUpNodes($this->root, array( "points" => 200
171 , "node1" => array( "points" => 100
172 , "leaf11" => null
173 , "leaf12" => null
174 )
175 , "node2" => array( "points" => 100
176 , "leaf21" => null
177 , "leaf22" => null
178 )
179 ));
180
181 $user = $this->newUser();
182 $user_id = $user->getId();
183 $ass = $this->root->assignUser($user->getId());
184 $ass_id = $ass->getId();
185
186 $this->node1->getProgressForAssignment($ass_id)
187 ->markNotRelevant($this->user->getId());
188 $this->leaf11->markCompletedFor($user_id);
189 $this->leaf21->markCompletedFor($user_id);
190
191 $this->assertEquals(ilStudyProgrammeProgress::STATUS_IN_PROGRESS, $this->root->getProgressForAssignment($ass_id)->getStatus());
192 $this->assertEquals(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT, $this->node1->getProgressForAssignment($ass_id)->getStatus());
193 $this->assertEquals(ilStudyProgrammeProgress::STATUS_COMPLETED, $this->node2->getProgressForAssignment($ass_id)->getStatus());
194 }

References newUser(), setUpNodes(), ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, and user().

+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilStudyProgrammeProgressCalculationTest::$backupGlobals = false
protected

Definition at line 16 of file ilStudyProgrammeProgressCalculationTest.php.


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