ILIAS  release_7 Revision v7.30-3-g800a261c036
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 16 of file ilStudyProgrammeProgressCalculationTest.php.

Member Function Documentation

◆ newUser()

ilStudyProgrammeProgressCalculationTest::newUser ( )
protected

Definition at line 53 of file ilStudyProgrammeProgressCalculationTest.php.

54 {
55 $user = new ilObjUser();
56 $user->create();
57 return $user;
58 }

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

+ Here is the caller graph for this function:

◆ setUp()

ilStudyProgrammeProgressCalculationTest::setUp ( )
protected

Definition at line 20 of file ilStudyProgrammeProgressCalculationTest.php.

20 : void
21 {
22 require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
23 PHPUnit\Framework\Error\Deprecated::$enabled = false;
24
25 global $DIC;
26 if (!$DIC) {
27 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
28 ilUnitUtil::performInitialisation();
29 }
30
32 $this->root->putInTree(ROOT_FOLDER_ID);
33 $this->root->object_factory = new ilObjectFactoryWrapperMock();
34 $this->root->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE)
35 ->update();
36
37 global $DIC;
38 $tree = $DIC['tree'];
39 $this->tree = $tree;
40
41 global $DIC;
42 $ilUser = $DIC['ilUser'];
43 $this->user = $ilUser;
44 }
user()
Definition: user.php:4
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
Mock for object factory.
Definition: mocks.php:69
const ROOT_FOLDER_ID
Definition: constants.php:30
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18

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

+ Here is the call graph for this function:

◆ setUpNodes()

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

Definition at line 60 of file ilStudyProgrammeProgressCalculationTest.php.

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

References $data, ilObjStudyProgramme\createInstance(), setUpNodes(), and ilStudyProgrammeSettings\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 46 of file ilStudyProgrammeProgressCalculationTest.php.

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

◆ testInitialProgressOnOptionalNodes()

ilStudyProgrammeProgressCalculationTest::testInitialProgressOnOptionalNodes ( )

Definition at line 200 of file ilStudyProgrammeProgressCalculationTest.php.

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

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

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

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

+ Here is the call graph for this function:

◆ testProgress2()

ilStudyProgrammeProgressCalculationTest::testProgress2 ( )

Definition at line 116 of file ilStudyProgrammeProgressCalculationTest.php.

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

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

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

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

+ Here is the call graph for this function:

◆ testProgress4()

ilStudyProgrammeProgressCalculationTest::testProgress4 ( )

Definition at line 172 of file ilStudyProgrammeProgressCalculationTest.php.

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

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

+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilStudyProgrammeProgressCalculationTest::$backupGlobals = false
protected

Definition at line 18 of file ilStudyProgrammeProgressCalculationTest.php.


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