ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 73 of file ilStudyProgrammeEventsTest.php.

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

74  {
75  $user = new ilObjUser();
76  $user->create();
77  $this->users[] = $user;
78  return $user;
79  }
+ Here is the caller graph for this function:

◆ setUp()

ilStudyProgrammeEventsTest::setUp ( )
protected

Definition at line 40 of file ilStudyProgrammeEventsTest.php.

References $DIC, ilObjStudyProgramme\createInstance(), ilStudyProgrammeDIC\dic(), ROOT_FOLDER_ID, and ilStudyProgrammeSettings\STATUS_ACTIVE.

40  : void
41  {
42  require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
43  PHPUnit\Framework\Error\Deprecated::$enabled = false;
44 
45  global $DIC;
46  if (!$DIC) {
47  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
48  ilUnitUtil::performInitialisation();
49  }
50 
52  $this->root_obj_id = $this->root->getId();
53  $this->root_ref_id = $this->root->getRefId();
54  $this->root->putInTree(ROOT_FOLDER_ID);
55  $this->root->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE);
56  $this->root->object_factory = new ilObjectFactoryWrapperMock();
57 
59  $this->node->object_factory = new ilObjectFactoryWrapperMock();
60  $this->root->addNode($this->node);
61 
62  $this->leaf = new ilStudyProgrammeLeafMock();
63  $this->node->addLeaf($this->leaf);
64  $this->node->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE);
65 
66  $this->users = array();
67 
68  require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
69  $this->event_handler_mock = new ilAppEventHandlerMock();
70  ilStudyProgrammeDIC::dic()['ilStudyProgrammeEvents']->app_event_handler = $this->event_handler_mock;
71  }
Mock classes for tests.
Definition: mocks.php:20
const ROOT_FOLDER_ID
Definition: constants.php:30
global $DIC
Definition: goto.php:24
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 81 of file ilStudyProgrammeEventsTest.php.

81  : void
82  {
83  foreach ($this->users as $user) {
84  $user->delete();
85  }
86  if ($this->root) {
87  $this->root->delete();
88  }
89  }

◆ testAssignUser()

ilStudyProgrammeEventsTest::testAssignUser ( )

Definition at line 91 of file ilStudyProgrammeEventsTest.php.

References newUser().

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

◆ testDeassignUser()

ilStudyProgrammeEventsTest::testDeassignUser ( )

Definition at line 106 of file ilStudyProgrammeEventsTest.php.

References newUser().

107  {
108  $user = $this->newUser();
109  $ass = $this->root->assignUser($user->getId(), 6);
110  $this->event_handler_mock->events = array();
111 
112  $ass->deassign();
113 
114  $this->assertCount(1, $this->event_handler_mock->events);
115 
116  $event = array_pop($this->event_handler_mock->events);
117  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
118  $this->assertEquals("userDeassigned", $event["event"]);
119  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
120  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
121  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
122  }
+ Here is the call graph for this function:

◆ testUserSuccessfulByAccredited()

ilStudyProgrammeEventsTest::testUserSuccessfulByAccredited ( )

Definition at line 151 of file ilStudyProgrammeEventsTest.php.

References newUser().

152  {
153  $user = $this->newUser();
154  $ass = $this->root->assignUser($user->getId(), 6);
155  $this->event_handler_mock->events = array();
156 
157  $progress = $this->node->getProgressForAssignment($ass->getId());
158  $progress->markAccredited(6);
159 
160  $this->assertCount(2, $this->event_handler_mock->events);
161 
162  $event = array_shift($this->event_handler_mock->events);
163  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
164  $this->assertEquals("userSuccessful", $event["event"]);
165  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
166  $this->assertEquals($this->node->getId(), $event["parameters"]["prg_id"]);
167  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
168  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
169 
170  $event = array_shift($this->event_handler_mock->events);
171  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
172  $this->assertEquals("userSuccessful", $event["event"]);
173  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
174  $this->assertEquals($this->root->getId(), $event["parameters"]["prg_id"]);
175  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
176  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
177  }
+ Here is the call graph for this function:

◆ testUserSuccessfulByCompletion()

ilStudyProgrammeEventsTest::testUserSuccessfulByCompletion ( )

Definition at line 124 of file ilStudyProgrammeEventsTest.php.

References newUser().

125  {
126  $user = $this->newUser();
127  $ass = $this->root->assignUser($user->getId(), 6);
128  $this->event_handler_mock->events = array();
129 
130  $this->leaf->markCompletedFor($user->getId());
131 
132  $this->assertCount(2, $this->event_handler_mock->events);
133 
134  $event = array_shift($this->event_handler_mock->events);
135  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
136  $this->assertEquals("userSuccessful", $event["event"]);
137  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
138  $this->assertEquals($this->node->getId(), $event["parameters"]["prg_id"]);
139  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
140  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
141 
142  $event = array_shift($this->event_handler_mock->events);
143  $this->assertEquals("Modules/StudyProgramme", $event["component"]);
144  $this->assertEquals("userSuccessful", $event["event"]);
145  $this->assertEquals($this->root->getId(), $event["parameters"]["root_prg_id"]);
146  $this->assertEquals($this->root->getId(), $event["parameters"]["prg_id"]);
147  $this->assertEquals($user->getId(), $event["parameters"]["usr_id"]);
148  $this->assertEquals($ass->getId(), $event["parameters"]["ass_id"]);
149  }
+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilStudyProgrammeEventsTest::$backupGlobals = false
protected

Definition at line 38 of file ilStudyProgrammeEventsTest.php.


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