ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 69 of file ilStudyProgrammeEventsTest.php.

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

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

◆ setUp()

ilStudyProgrammeEventsTest::setUp ( )
protected

Definition at line 38 of file ilStudyProgrammeEventsTest.php.

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

39  {
40  PHPUnit_Framework_Error_Deprecated::$enabled = false;
41 
42  require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
43 
44  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
45  ilUnitUtil::performInitialisation();
46 
48  $this->root_obj_id = $this->root->getId();
49  $this->root_ref_id = $this->root->getRefId();
50  $this->root->putInTree(ROOT_FOLDER_ID);
51  $this->root->setStatus(ilStudyProgramme::STATUS_ACTIVE);
52  $this->root->object_factory = new ilObjectFactoryWrapperMock();
53 
55  $this->node->object_factory = new ilObjectFactoryWrapperMock();
56  $this->root->addNode($this->node);
57 
58  $this->leaf = new ilStudyProgrammeLeafMock();
59  $this->node->addLeaf($this->leaf);
60  $this->node->setStatus(ilStudyProgramme::STATUS_ACTIVE);
61 
62  $this->users = array();
63 
64  require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
65  $this->event_handler_mock = new ilAppEventHandlerMock();
66  ilStudyProgrammeEvents::$app_event_handler = $this->event_handler_mock;
67  }
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 77 of file ilStudyProgrammeEventsTest.php.

78  {
79  foreach ($this->users as $user) {
80  $user->delete();
81  }
82  if ($this->root) {
83  $this->root->delete();
84  }
85  }

◆ testAssignUser()

ilStudyProgrammeEventsTest::testAssignUser ( )

Definition at line 87 of file ilStudyProgrammeEventsTest.php.

References newUser().

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

◆ testDeassignUser()

ilStudyProgrammeEventsTest::testDeassignUser ( )

Definition at line 102 of file ilStudyProgrammeEventsTest.php.

References array, and newUser().

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

◆ testUserSuccessfulByAccredited()

ilStudyProgrammeEventsTest::testUserSuccessfulByAccredited ( )

Definition at line 147 of file ilStudyProgrammeEventsTest.php.

References array, and newUser().

148  {
149  $user = $this->newUser();
150  $ass = $this->root->assignUser($user->getId());
151  $this->event_handler_mock->events = array();
152 
153  $progress = $this->node->getProgressForAssignment($ass->getId());
154  $progress->markAccredited(6);
155 
156  $this->assertCount(2, $this->event_handler_mock->events);
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->node->getId(), $event["parameters"]["prg_id"]);
163  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
164  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
165 
166  $event = array_shift($this->event_handler_mock->events);
167  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
168  $this->assertEquals("userSuccessful", $event["event"]);
169  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
170  $this->assertEquals($this->root->getId(), $event["parameters"]["prg_id"]);
171  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
172  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
173  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ testUserSuccessfulByCompletion()

ilStudyProgrammeEventsTest::testUserSuccessfulByCompletion ( )

Definition at line 120 of file ilStudyProgrammeEventsTest.php.

References array, and newUser().

121  {
122  $user = $this->newUser();
123  $ass = $this->root->assignUser($user->getId());
124  $this->event_handler_mock->events = array();
125 
126  $this->leaf->markCompletedFor($user->getId());
127 
128  $this->assertCount(2, $this->event_handler_mock->events);
129 
130  $event = array_shift($this->event_handler_mock->events);
131  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
132  $this->assertEquals("userSuccessful", $event["event"]);
133  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
134  $this->assertEquals($this->node->getId(), $event["parameters"]["prg_id"]);
135  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
136  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
137 
138  $event = array_shift($this->event_handler_mock->events);
139  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
140  $this->assertEquals("userSuccessful", $event["event"]);
141  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
142  $this->assertEquals($this->root->getId(), $event["parameters"]["prg_id"]);
143  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
144  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
145  }
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 36 of file ilStudyProgrammeEventsTest.php.


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