ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilStudyProgrammeEventsTest Class Reference

TestCase for the ilObjStudyProgramme needsInstalledILIAS. More...

+ Inheritance diagram for ilStudyProgrammeEventsTest:
+ Collaboration diagram for ilStudyProgrammeEventsTest:

Public Member Functions

 testAssignUser ()
 
 testDeassignUser ()
 
 testUserSuccessfulByCompletion ()
 
 testUserSuccessfulByAccredited ()
 

Protected Member Functions

 setUp ()
 
 newUser ()
 
 tearDown ()
 

Protected Attributes

 $backupGlobals = FALSE
 

Detailed Description

Member Function Documentation

◆ newUser()

ilStudyProgrammeEventsTest::newUser ( )
protected

Definition at line 67 of file ilStudyProgrammeEventsTest.php.

Referenced by testAssignUser(), testDeassignUser(), testUserSuccessfulByAccredited(), and testUserSuccessfulByCompletion().

67  {
68  $user = new ilObjUser();
69  $user->create();
70  $this->users[] = $user;
71  return $user;
72  }
+ Here is the caller graph for this function:

◆ setUp()

ilStudyProgrammeEventsTest::setUp ( )
protected

Definition at line 37 of file ilStudyProgrammeEventsTest.php.

References ilStudyProgrammeEvents\$app_event_handler, array, ilObjStudyProgramme\createInstance(), and ilStudyProgramme\STATUS_ACTIVE.

37  {
38  PHPUnit_Framework_Error_Deprecated::$enabled = FALSE;
39 
40  require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
41 
42  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
43  ilUnitUtil::performInitialisation();
44 
46  $this->root_obj_id = $this->root->getId();
47  $this->root_ref_id = $this->root->getRefId();
48  $this->root->putInTree(ROOT_FOLDER_ID);
49  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
50  $this->root->object_factory = new ilObjectFactoryWrapperMock();
51 
53  $this->node->object_factory = new ilObjectFactoryWrapperMock();
54  $this->root->addNode($this->node);
55 
56  $this->leaf = new ilStudyProgrammeLeafMock();
57  $this->node->addLeaf($this->leaf);
58  $this->node->setStatus(ilStudyProgramme::STATUS_ACTIVE);
59 
60  $this->users = array();
61 
62  require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
63  $this->event_handler_mock = new ilAppEventHandlerMock();
64  ilStudyProgrammeEvents::$app_event_handler = $this->event_handler_mock;
65  }
Mock classes for tests.
Definition: mocks.php:20
Create styles array
The data for the language used.
Mock for ilAppEventHandler.
Definition: mocks.php:82
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()

ilStudyProgrammeEventsTest::tearDown ( )
protected

Definition at line 74 of file ilStudyProgrammeEventsTest.php.

74  {
75  foreach($this->users as $user) {
76  $user->delete();
77  }
78  if ($this->root) {
79  $this->root->delete();
80  }
81  }

◆ testAssignUser()

ilStudyProgrammeEventsTest::testAssignUser ( )

Definition at line 83 of file ilStudyProgrammeEventsTest.php.

References newUser().

83  {
84  $user = $this->newUser();
85  $ass = $this->root->assignUser($user->getId());
86 
87  $this->assertCount(1, $this->event_handler_mock->events);
88  $event = array_pop($this->event_handler_mock->events);
89 
90  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
91  $this->assertEquals("userAssigned", $event["event"]);
92  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
93  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
94  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
95  }
+ Here is the call graph for this function:

◆ testDeassignUser()

ilStudyProgrammeEventsTest::testDeassignUser ( )

Definition at line 97 of file ilStudyProgrammeEventsTest.php.

References array, and newUser().

97  {
98  $user = $this->newUser();
99  $ass = $this->root->assignUser($user->getId());
100  $this->event_handler_mock->events = array();
101 
102  $ass->deassign();
103 
104  $this->assertCount(1, $this->event_handler_mock->events);
105 
106  $event = array_pop($this->event_handler_mock->events);
107  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
108  $this->assertEquals("userDeassigned", $event["event"]);
109  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
110  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
111  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
112  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ testUserSuccessfulByAccredited()

ilStudyProgrammeEventsTest::testUserSuccessfulByAccredited ( )

Definition at line 140 of file ilStudyProgrammeEventsTest.php.

References array, and newUser().

140  {
141  $user = $this->newUser();
142  $ass = $this->root->assignUser($user->getId());
143  $this->event_handler_mock->events = array();
144 
145  $progress = $this->node->getProgressForAssignment($ass->getId());
146  $progress->markAccredited(6);
147 
148  $this->assertCount(2, $this->event_handler_mock->events);
149 
150  $event = array_shift($this->event_handler_mock->events);
151  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
152  $this->assertEquals("userSuccessful", $event["event"]);
153  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
154  $this->assertEquals($this->node->getId(), $event["parameters"]["prg_id"]);
155  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
156  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
157 
158  $event = array_shift($this->event_handler_mock->events);
159  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
160  $this->assertEquals("userSuccessful", $event["event"]);
161  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
162  $this->assertEquals($this->root->getId(), $event["parameters"]["prg_id"]);
163  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
164  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
165  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ testUserSuccessfulByCompletion()

ilStudyProgrammeEventsTest::testUserSuccessfulByCompletion ( )

Definition at line 114 of file ilStudyProgrammeEventsTest.php.

References array, and newUser().

114  {
115  $user = $this->newUser();
116  $ass = $this->root->assignUser($user->getId());
117  $this->event_handler_mock->events = array();
118 
119  $this->leaf->markCompletedFor($user->getId());
120 
121  $this->assertCount(2, $this->event_handler_mock->events);
122 
123  $event = array_shift($this->event_handler_mock->events);
124  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
125  $this->assertEquals("userSuccessful", $event["event"]);
126  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
127  $this->assertEquals($this->node->getId(), $event["parameters"]["prg_id"]);
128  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
129  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
130 
131  $event = array_shift($this->event_handler_mock->events);
132  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
133  $this->assertEquals("userSuccessful", $event["event"]);
134  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
135  $this->assertEquals($this->root->getId(), $event["parameters"]["prg_id"]);
136  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
137  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
138  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilStudyProgrammeEventsTest::$backupGlobals = FALSE
protected

Definition at line 35 of file ilStudyProgrammeEventsTest.php.


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