24 require_once(__DIR__ .
"/mocks.php");
40 PHPUnit_Framework_Error_Deprecated::$enabled =
false;
42 require_once(
"./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
44 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
45 ilUnitUtil::performInitialisation();
48 $this->root_obj_id = $this->root->getId();
49 $this->root_ref_id = $this->root->getRefId();
50 $this->root->putInTree(ROOT_FOLDER_ID);
56 $this->root->addNode($this->node);
59 $this->node->addLeaf($this->leaf);
62 $this->users = array();
64 require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
73 $this->users[] =
$user;
79 foreach ($this->users as
$user) {
83 $this->root->delete();
90 $ass = $this->root->assignUser(
$user->getId());
92 $this->assertCount(1, $this->event_handler_mock->events);
93 $event = array_pop($this->event_handler_mock->events);
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"]);
105 $ass = $this->root->assignUser(
$user->getId());
106 $this->event_handler_mock->events = array();
110 $this->assertCount(1, $this->event_handler_mock->events);
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"]);
123 $ass = $this->root->assignUser(
$user->getId());
124 $this->event_handler_mock->events = array();
126 $this->leaf->markCompletedFor(
$user->getId());
128 $this->assertCount(2, $this->event_handler_mock->events);
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"]);
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"]);
150 $ass = $this->root->assignUser(
$user->getId());
151 $this->event_handler_mock->events = array();
153 $progress = $this->node->getProgressForAssignment($ass->getId());
154 $progress->markAccredited(6);
156 $this->assertCount(2, $this->event_handler_mock->events);
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"]);
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"]);
static $app_event_handler
testUserSuccessfulByCompletion()
testUserSuccessfulByAccredited()
Mock for ilAppEventHandler.
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
TestCase for the ilObjStudyProgramme needsInstalledILIAS.