ILIAS  release_7 Revision v7.30-3-g800a261c036
prg_mocks.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
3//NIFT: NotImplementedForTesting
4trait ProgressRepoMockNIFT
5{
6 public function __construct()
7 {
8 }
9
10 public function getByIds(int $prg_id, int $assignment_id) : ilStudyProgrammeProgress
11 {
12 throw new Exception("Not implemented for testing", 1);
13 }
14 /*public function getByPrgIdAndAssignmentId(int $prg_id, int $assignment_id)
15 {
16 throw new Exception("Not implemented for testing", 1);
17 }*/
18 public function getByPrgIdAndUserId(int $prg_id, int $usr_id) : array
19 {
20 throw new Exception("Not implemented for testing", 1);
21 }
22 public function getByPrgId(int $prg_id) : array
23 {
24 throw new Exception("Not implemented for testing", 1);
25 }
26 public function getFirstByPrgId(int $prg_id)
27 {
28 throw new Exception("Not implemented for testing", 1);
29 }
30 public function getExpiredSuccessfull() : array
31 {
32 throw new Exception("Not implemented for testing", 1);
33 }
34 public function getRiskyToFailInstances() : array
35 {
36 throw new Exception("Not implemented for testing", 1);
37 }
38 public function getPassedDeadline() : array
39 {
40 throw new Exception("Not implemented for testing", 1);
41 }
42 public function delete(ilStudyProgrammeProgress $progress)
43 {
44 throw new Exception("Not implemented for testing", 1);
45 }
46 public function createFor(
50 throw new Exception("Not implemented for testing", 1);
51 }
52}
53
54trait AssignmentRepoMockNIFT
55{
56 public function __construct()
57 {
58 }
59
60 public function createFor(int $prg_id, int $usr_id, int $assigning_usr_id) : ilStudyProgrammeAssignment
61 {
62 throw new Exception("Not implemented for testing", 1);
63 }
64 public function getByUsrId(int $usr_id) : array
65 {
66 throw new Exception("Not implemented for testing", 1);
67 }
68 public function getByPrgId(int $prg_id) : array
69 {
70 throw new Exception("Not implemented for testing", 1);
71 }
72 public function getDueToRestart() : array
73 {
74 throw new Exception("Not implemented for testing", 1);
75 }
76 public function getDueToManuelRestart(int $days_before_end) : array
77 {
78 throw new Exception("Not implemented for testing", 1);
79 }
80 public function delete(ilStudyProgrammeAssignment $assignment)
81 {
82 throw new Exception("Not implemented for testing", 1);
83 }
84}
85
86trait SettingsRepoMockNIFT
87{
88 public function __construct()
89 {
90 }
91
92 public function createFor(int $obj_id) : ilStudyProgrammeSettings
93 {
94 throw new Exception("Not implemented for testing", 1);
95 }
96 public function delete(ilStudyProgrammeSettings $settings) : void
97 {
98 throw new Exception("Not implemented for testing", 1);
99 }
100 public function loadByType(int $type_id) : array
101 {
102 throw new Exception("Not implemented for testing", 1);
103 }
104 public function loadIdsByType(int $type_id) : array
105 {
106 throw new Exception("Not implemented for testing", 1);
107 }
108}
109
110
111class ProgressRepoMock implements ilStudyProgrammeProgressRepository
112{
113 public $progresses = [];
114
115 use ProgressRepoMockNIFT;
116
117 public function get(int $id) : ilStudyProgrammeProgress
118 {
119 return $this->progresses[$id];
120 }
121
122 public function update(ilStudyProgrammeProgress $progress)
123 {
124 $this->progresses[$progress->getNodeId()] = $progress;
125 }
126
127 public function getByPrgIdAndAssignmentId(int $prg_id, int $assignment_id)
128 {
129 return $this->progresses[$prg_id];
130 }
131
132 public function getByAssignmentId(int $assignment_id) : array
133 {
134 $ret = [];
135 foreach ($this->progresses as $progress_id => $progress) {
136 if ($progress->getAssignmentId() === $assignment_id) {
137 $ret[] = $progress;
138 }
139 }
140 return $ret;
141 }
142}
143
144class AssignmentRepoMock implements ilStudyProgrammeAssignmentRepository
145{
146 public $assignments = [];
147
148 use AssignmentRepoMockNIFT;
149
150 public function get(int $id)
151 {
152 return $this->assignments[$id];
153 }
154 public function update(ilStudyProgrammeAssignment $assignment)
155 {
156 $this->assignments[$assignment->getId()] = $assignment;
157 }
158}
159
160class SettingsRepoMock implements ilStudyProgrammeSettingsRepository
161{
162 public $settings = [];
163
164 use SettingsRepoMockNIFT;
165
166 public function get(int $obj_id) : ilStudyProgrammeSettings
167 {
168 return $this->settings[$obj_id];
169 }
170
171 public function update(ilStudyProgrammeSettings $settings) : void
172 {
173 $this->settings[$settings->getObjId()] = $settings;
174 }
175}
176
177class SettingsMock extends ilStudyProgrammeSettings
178{
179 public function __construct(int $id)
180 {
181 $this->obj_id = $id;
182 }
183}
184
185class PrgMock extends ilObjStudyProgramme
186{
187 public function __construct(
188 int $id,
189 $env
190 ) {
191 $this->id = $id;
192 $this->env = $env;
193 $this->events = new class() {
194 public function userSuccessful(ilStudyProgrammeProgress $a_progress) : void
195 {
196 }
197 };
198 }
199
200 public function throwIfNotInTree() : void
201 {
202 }
203
204 public function update() : void
205 {
206 $this->updateSettings();
207 }
208 protected function getLoggedInUserId() : int
209 {
210 return 9;
211 }
212
213 protected function getProgressIdString(ilStudyProgrammeProgress $progress) : string
214 {
215 return (string) $progress->getId();
216 }
217
219 {
220 return $this->env->progress_repo;
221 }
223 {
224 return $this->env->assignment_repo;
225 }
227 {
228 return $this->env->settings_repo;
229 }
230
231 protected function refreshLPStatus(int $usr_id) : void
232 {
233 }
234
236 {
237 $parent_id = $this->env->mock_tree[$progress->getNodeId()]['parent'];
238 if (is_null($parent_id)) {
239 return null;
240 }
241 return $this->getProgressRepository()->get($parent_id);
242 }
243
244 public function getChildrenProgress($progress) : array
245 {
246 $progresses = [];
247 foreach ($this->env->mock_tree[$progress->getNodeId()]['children'] as $child_id) {
248 $progresses[] = $this->getProgressRepository()->get($child_id);
249 }
250 return $progresses;
251 }
252
253 public function testUpdateParentProgress(ilStudyProgrammeProgress $progress) : ilStudyProgrammeProgress
254 {
255 return $this->updateParentProgress($progress);
256 }
257
258 public function testApplyProgressDeadline(ilStudyProgrammeProgress $progress) : ilStudyProgrammeProgress
259 {
260 return $this->applyProgressDeadline($progress);
261 }
262
263 protected function getPrgInstanceByObjId(int $obj_id) : ilObjStudyProgramme
264 {
265 return $this->tree[$obj_id]['prg'];
266 }
267
268 public function hasChildren(bool $include_references = false) : bool
269 {
270 if ($this->id < 12) {
271 return true;
272 }
273 return false;
274 }
275}
276
277class ProgrammeEventsMock extends ilStudyProgrammeEvents
278{
279 public $raised;
280
281 public function __construct()
282 {
283 $this->raised = [];
284 }
285
286 public function raise($event, $parameter) : void
287 {
288 $this->raised[] = [$event, $parameter];
289 }
290}
An exception for terminatinating execution or to throw for unit testing.
updateSettings(ilStudyProgrammeSettings $settings)
applyProgressDeadline(ilStudyProgrammeProgress $progress, int $acting_usr_id=null)
getProgressIdString(ilStudyProgrammeProgress $progress)
refreshLPStatus(int $usr_id, int $node_obj_id=null)
__construct($a_id=0, bool $a_call_by_reference=true)
ATTENTION: After using the constructor the object won't be in the cache.
hasChildren(bool $include_references=false)
Does this StudyProgramme have other ilObjStudyProgrammes as children?
updateParentProgress(ilStudyProgrammeProgress $progress)
getParentProgress(ilStudyProgrammeProgress $progress)
Represents one assignment of the user to a program tree.
__construct(\ilAppEventHandler $app_event_handler, \ilStudyProgrammeAssignmentRepository $assignment_repo)
Class ilStudyProgrammeProgress.
getId()
Get the id of the progress.
getAssignmentId()
Get the assignment this progress belongs to.
getNodeId()
Get the obj_id of the program node this progress belongs to.
__construct(int $a_id, \ilStudyProgrammeTypeSettings $type_settings, \ilStudyProgrammeAssessmentSettings $assessment_settings, \ilStudyProgrammeDeadlineSettings $deadline_settings, \ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings, \ilStudyProgrammeAutoMailSettings $automail_settings)
getObjId()
Get the id of the study program.
update(ilStudyProgrammeAssignment $assignment)
Update settings belonging to a SP-Object.
Covers the persistence of settings belonging to a study programme (SP).
update(ilStudyProgrammeProgress $progress)
Update record corresponding to progress.
getByPrgIdAndAssignmentId(int $prg_id, int $assignment_id)
Load progress belonging to a prg id and assignment.
getByAssignmentId(int $assignment_id)
Load progress objects belonging to an assignment id.
Covers the persistence of settings belonging to a study programme (SP).
update(ilStudyProgrammeSettings $settings)
Update settings belonging to a SP-Object.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
settings()
Definition: settings.php:2