ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.

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

Member Function Documentation

◆ newUser()

ilStudyProgrammeProgressCalculationTest::newUser ( )
protected

Definition at line 46 of file ilStudyProgrammeProgressCalculationTest.php.

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

47  {
48  $user = new ilObjUser();
49  $user->create();
50  return $user;
51  }
+ Here is the caller graph for this function:

◆ setUp()

ilStudyProgrammeProgressCalculationTest::setUp ( )
protected

Definition at line 17 of file ilStudyProgrammeProgressCalculationTest.php.

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

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  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE)
30  ->update();
31 
32  global $tree;
33  $this->tree = $tree;
34 
35  global $ilUser;
36  $this->user = $ilUser;
37  }
global $ilUser
Definition: imgupload.php:15
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
Mock for object factory.
Definition: mocks.php:65
+ Here is the call graph for this function:

◆ setUpNodes()

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

Definition at line 53 of file ilStudyProgrammeProgressCalculationTest.php.

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

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

54  {
55  if (!array_key_exists("points", $data)) {
56  throw new Exception("Expected to find 'points' in data array.");
57  }
58 
59  $top->setPoints($data["points"]);
60 
61  foreach ($data as $node_name => $data2) {
62  if ($node_name == "points") {
63  continue;
64  }
65  if (isset($this->$node_name)) {
66  throw new Exception("Node $node_name already exists.");
67  }
68 
69  if ($data2 == null) {
70  $this->$node_name = new ilStudyProgrammeLeafMock();
71  $top->addLeaf($this->$node_name);
72  } else {
73  $this->$node_name = ilObjStudyProgramme::createInstance();
74  $this->$node_name->object_factory = new ilObjectFactoryWrapperMock();
75  $top->addNode($this->$node_name);
76  $this->setUpNodes($this->$node_name, $data2);
77  $this->$node_name->setStatus(ilStudyProgramme::STATUS_ACTIVE)
78  ->update();
79  }
80  }
81  }
Mock classes for tests.
Definition: mocks.php:20
$data
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
Mock for object factory.
Definition: mocks.php:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tearDown()

ilStudyProgrammeProgressCalculationTest::tearDown ( )
protected

Definition at line 39 of file ilStudyProgrammeProgressCalculationTest.php.

40  {
41  if ($this->root) {
42  $this->root->delete();
43  }
44  }

◆ testInitialProgressOnOptionalNodes()

ilStudyProgrammeProgressCalculationTest::testInitialProgressOnOptionalNodes ( )

Definition at line 193 of file ilStudyProgrammeProgressCalculationTest.php.

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

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

◆ testProgress1()

ilStudyProgrammeProgressCalculationTest::testProgress1 ( )

Definition at line 83 of file ilStudyProgrammeProgressCalculationTest.php.

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

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

◆ testProgress2()

ilStudyProgrammeProgressCalculationTest::testProgress2 ( )

Definition at line 109 of file ilStudyProgrammeProgressCalculationTest.php.

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

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

◆ testProgress3()

ilStudyProgrammeProgressCalculationTest::testProgress3 ( )

Definition at line 136 of file ilStudyProgrammeProgressCalculationTest.php.

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

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

◆ testProgress4()

ilStudyProgrammeProgressCalculationTest::testProgress4 ( )

Definition at line 165 of file ilStudyProgrammeProgressCalculationTest.php.

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

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

Field Documentation

◆ $backupGlobals

ilStudyProgrammeProgressCalculationTest::$backupGlobals = false
protected

Definition at line 15 of file ilStudyProgrammeProgressCalculationTest.php.


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