ILIAS  release_8 Revision v8.24
prg_mocks.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21//NIFT: NotImplementedForTesting
22trait ProgressRepoMockNIFT
23{
24 public function __construct()
25 {
26 }
27
28 public function getByIds(int $prg_id, int $assignment_id): ilPRGProgress
29 {
30 throw new Exception("Not implemented for testing", 1);
31 }
32 /*public function getByPrgIdAndAssignmentId(int $prg_id, int $assignment_id)
33 {
34 throw new Exception("Not implemented for testing", 1);
35 }*/
36 public function getByPrgIdAndUserId(int $prg_id, int $usr_id): array
37 {
38 throw new Exception("Not implemented for testing", 1);
39 }
40 public function getByPrgId(int $prg_id): array
41 {
42 throw new Exception("Not implemented for testing", 1);
43 }
44 public function getFirstByPrgId(int $prg_id): void
45 {
46 throw new Exception("Not implemented for testing", 1);
47 }
48 public function getExpiredSuccessfull(): array
49 {
50 throw new Exception("Not implemented for testing", 1);
51 }
52 public function getRiskyToFailInstances(): array
53 {
54 throw new Exception("Not implemented for testing", 1);
55 }
56 public function getLatestAssignedProgress(int $prg_id, int $usr_id): ?\ilPRGProgress
57 {
58 throw new Exception("Not implemented for testing", 1);
59 }
60 public function getPassedDeadline(): array
61 {
62 throw new Exception("Not implemented for testing", 1);
63 }
64 public function delete(ilPRGProgress $progress)
65 {
66 throw new Exception("Not implemented for testing", 1);
67 }
68 public function createFor(
70 ilStudyProgrammeAssignment $ass
71 ): ilPRGProgress {
72 throw new Exception("Not implemented for testing", 1);
73 }
74}
75
76trait AssignmentRepoMockNIFT
77{
78 public function __construct()
79 {
80 }
81 public function createFor(int $prg_obj_id, int $usr_id, int $assigning_usr_id): ilPRGAssignment
82 {
83 throw new Exception("Not implemented for testing", 1);
84 }
85 public function getForUser(int $usr_id): array
86 {
87 throw new Exception("Not implemented for testing", 1);
88 }
89 public function getAllForNodeIsContained(int $prg_obj_id, ?array $user_filter = null, ?ilPRGAssignmentFilter $custom_filters = null): array
90 {
91 throw new Exception("Not implemented for testing", 1);
92 }
93 public function countAllForNodeIsContained(int $prg_obj_id, array $user_filter = null, ilPRGAssignmentFilter $custom_filters = null): int
94 {
95 throw new Exception("Not implemented for testing", 1);
96 }
97 public function getAllForSpecificNode(int $prg_obj_id, array $user_filter = null): array
98 {
99 throw new Exception("Not implemented for testing", 1);
100 }
101 public function getPassedDeadline(\DateTimeImmutable $deadline): array
102 {
103 throw new Exception("Not implemented for testing", 1);
104 }
105 public function getDashboardInstancesforUser(int $usr_id): array
106 {
107 throw new Exception("Not implemented for testing", 1);
108 }
109 public function getAboutToExpire(
110 array $programmes_and_due,
111 bool $discard_formerly_notified = true
112 ): array {
113 throw new Exception("Not implemented for testing", 1);
114 }
115 public function getByPrgId(int $prg_id): array
116 {
117 throw new Exception("Not implemented for testing", 1);
118 }
119 public function getDueToRestart(): array
120 {
121 throw new Exception("Not implemented for testing", 1);
122 }
123 public function getDueToManuelRestart(int $days_before_end): array
124 {
125 throw new Exception("Not implemented for testing", 1);
126 }
127 public function delete(ilPRGAssignment $assignment): void
128 {
129 throw new Exception("Not implemented for testing", 1);
130 }
131 public function deleteAllAssignmentsForProgrammeId(int $prg_obj_id): void
132 {
133 throw new Exception("Not implemented for testing", 1);
134 }
135 public function getExpiredAndNotInvalidated(): array
136 {
137 throw new Exception("Not implemented for testing", 1);
138 }
139}
140
141trait SettingsRepoMockNIFT
142{
143 public function __construct()
144 {
145 }
146
147 public function createFor(int $obj_id): ilStudyProgrammeSettings
148 {
149 throw new Exception("Not implemented for testing", 1);
150 }
151 public function delete(ilStudyProgrammeSettings $settings): void
152 {
153 throw new Exception("Not implemented for testing", 1);
154 }
155 public function loadByType(int $type_id): array
156 {
157 throw new Exception("Not implemented for testing", 1);
158 }
159 public function loadIdsByType(int $type_id): array
160 {
161 throw new Exception("Not implemented for testing", 1);
162 }
163}
164
165class AssignmentRepoMock implements PRGAssignmentRepository
166{
167 use AssignmentRepoMockNIFT;
169 public array $assignments = [];
170
171 public function get(int $id): ilPRGAssignment
172 {
173 return $this->assignments[$id];
174 }
175
176 public function store(ilPRGAssignment $assignment): void
177 {
178 $this->assignments[$assignment->getId()] = $assignment;
179 }
180}
181
182class SettingsRepoMock implements ilStudyProgrammeSettingsRepository
183{
184 use SettingsRepoMockNIFT;
186 public array $settings = [];
187
188 public function get(int $obj_id): ilStudyProgrammeSettings
189 {
190 return $this->settings[$obj_id];
191 }
192
193 public function update(ilStudyProgrammeSettings $settings): void
194 {
195 $this->settings[$settings->getObjId()] = $settings;
196 }
197}
198
199class SettingsMock extends ilStudyProgrammeSettings
200{
201 public function __construct(int $id)
202 {
203 $this->obj_id = $id;
204 $this->validity_of_qualification_settings =
206 null,
207 null,
208 null,
209 false
210 );
211 }
212}
213
214class PrgMock extends ilObjStudyProgramme
215{
216 public function __construct(
217 int $id,
218 $env
219 ) {
220 $this->id = $id;
221 $this->env = $env;
222 $this->events = new class () {
223 public function userSuccessful(ilPRGProgress $a_progress): void
224 {
225 }
226 };
227 }
228
229 protected function throwIfNotInTree(): void
230 {
231 }
232
233 public function update(): bool
234 {
235 return $this->updateSettings();// TODO PHP8-REVIEW Required parameter missing
236 }
237 protected function getLoggedInUserId(): int
238 {
239 return 9;
240 }
241
242
243 protected function getProgressIdString(ilPRGAssignment $assignment, ilPRGProgress $progress): string
244 {
245 return (string) $progress->getId();
246 }
247
249 {
250 return $this->env->assignment_repo;
251 }
253 {
254 return $this->env->settings_repo;
255 }
256
257 protected function refreshLPStatus(int $usr_id, int $node_obj_id = null): void
258 {
259 }
260
261
262 public function getParentProgress(ilPRGAssignment $assignment, int $child_progress_node_id): ?ilPRGProgress
263 {
264 $parent_id = $this->env->mock_tree[$progress->getNodeId()]['parent'];
265 if (is_null($parent_id)) {
266 return null;
267 }
268 return $this->getProgressRepository()->get($parent_id);
269 }
270
271 public function getChildrenProgress(ilPRGAssignment $assignment, int $progress_node_id): array
272 {
273 $progresses = [];
274 foreach ($this->env->mock_tree[$progress->getNodeId()]['children'] as $child_id) {
275 $progresses[] = $this->getProgressRepository()->get($child_id);
276 }
277 return $progresses;
278 }
279
280 public function testUpdateParentProgress(ilPRGProgress $progress): ilPRGProgress
281 {
282 return $this->updateParentProgress($progress);
283 }
284
285 public function testApplyProgressDeadline(ilPRGProgress $progress): ilPRGProgress
286 {
287 return $this->applyProgressDeadline($progress);
288 }
289
290 protected function getPrgInstanceByObjId(int $obj_id): ilObjStudyProgramme
291 {
292 return $this->tree[$obj_id]['prg'];
293 }
294
295 public function hasChildren(bool $include_references = false): bool
296 {
297 if ($this->id < 12) {
298 return true;
299 }
300 return false;
301 }
302}
303
304class ProgrammeEventsMock extends ilStudyProgrammeEvents
305{
306 public array $raised = [];// TODO PHP8-REVIEW Maybe the shape of the array can be expressed by PHPDoc comments
307
308 public function __construct()
309 {
310 }
311
312 public function raise($event, $parameter): void// TODO PHP8-REVIEW The type hints are missing
313 {
314 $this->raised[] = [$event, $parameter];
315 }
316
317 protected function getRefIdFor(int $obj_id): int
318 {
319 return 666;
320 }
321}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(int $id=0, bool $call_by_reference=true)
ATTENTION: After using the constructor the object won't be in the cache.
updateSettings(ilStudyProgrammeSettings $settings)
refreshLPStatus(int $usr_id, int $node_obj_id=null)
getProgressIdString(ilPRGAssignment $assignment, ilPRGProgress $progress)
hasChildren(bool $include_references=false)
Does this StudyProgramme have other ilObjStudyProgrammes as children?
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
__construct(ilLogger $logger, ilAppEventHandler $app_event_handler, PRGEventHandler $prg_event_handler)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getObjId()
Get the id of the study program.
__construct(int $a_id, ilStudyProgrammeTypeSettings $type_settings, ilStudyProgrammeAssessmentSettings $assessment_settings, ilStudyProgrammeDeadlineSettings $deadline_settings, ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings, ilStudyProgrammeAutoMailSettings $automail_settings)
getRefIdFor(int $obj_id)
applyProgressDeadline(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $progress, int $acting_usr_id=null, bool $recalculate=true)
store(ilPRGAssignment $assignment)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
update(ilStudyProgrammeSettings $settings)
Update settings belonging to a SP-Object.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200