ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 public function getLatestAssignment(int $root_prg_obj_id, int $usr_id): ?ilPRGAssignment
140 {
141 throw new Exception("Not implemented for testing", 1);
142 }
143 public function getLongestValidAssignment(int $root_prg_obj_id, int $usr_id): ?ilPRGAssignment
144 {
145 throw new Exception("Not implemented for testing", 1);
146 }
147}
148
149trait SettingsRepoMockNIFT
150{
151 public function __construct()
152 {
153 }
154
155 public function createFor(int $obj_id): ilStudyProgrammeSettings
156 {
157 throw new Exception("Not implemented for testing", 1);
158 }
159 public function delete(ilStudyProgrammeSettings $settings): void
160 {
161 throw new Exception("Not implemented for testing", 1);
162 }
163 public function loadByType(int $type_id): array
164 {
165 throw new Exception("Not implemented for testing", 1);
166 }
167 public function loadIdsByType(int $type_id): array
168 {
169 throw new Exception("Not implemented for testing", 1);
170 }
171}
172
173class AssignmentRepoMock implements PRGAssignmentRepository
174{
175 use AssignmentRepoMockNIFT;
177 public array $assignments = [];
178
179 public function get(int $id): ilPRGAssignment
180 {
181 return $this->assignments[$id];
182 }
183
184 public function store(ilPRGAssignment $assignment): void
185 {
186 $this->assignments[$assignment->getId()] = $assignment;
187 }
188}
189
190class SettingsRepoMock implements ilStudyProgrammeSettingsRepository
191{
192 use SettingsRepoMockNIFT;
194 public array $settings = [];
195
196 public function get(int $obj_id): ilStudyProgrammeSettings
197 {
198 return $this->settings[$obj_id];
199 }
200
201 public function update(ilStudyProgrammeSettings $settings): void
202 {
203 $this->settings[$settings->getObjId()] = $settings;
204 }
205}
206
207class SettingsMock extends ilStudyProgrammeSettings
208{
209 public function __construct(int $id)
210 {
211 $this->obj_id = $id;
212 $this->validity_of_qualification_settings =
214 null,
215 null,
216 null,
217 false
218 );
219 }
220}
221
222class PrgMock extends ilObjStudyProgramme
223{
224 public function __construct(
225 int $id,
226 $env
227 ) {
228 $this->id = $id;
229 $this->env = $env;
230 $this->events = new class () {
231 public function userSuccessful(ilPRGProgress $a_progress): void
232 {
233 }
234 };
235 }
236
237 protected function throwIfNotInTree(): void
238 {
239 }
240
241 public function update(): bool
242 {
243 return $this->updateSettings();// TODO PHP8-REVIEW Required parameter missing
244 }
245 protected function getLoggedInUserId(): int
246 {
247 return 9;
248 }
249
250
251 protected function getProgressIdString(ilPRGAssignment $assignment, ilPRGProgress $progress): string
252 {
253 return (string) $progress->getId();
254 }
255
257 {
258 return $this->env->assignment_repo;
259 }
261 {
262 return $this->env->settings_repo;
263 }
264
265 protected function refreshLPStatus(int $usr_id, ?int $node_obj_id = null): void
266 {
267 }
268
269
270 public function getParentProgress(ilPRGAssignment $assignment, int $child_progress_node_id): ?ilPRGProgress
271 {
272 $parent_id = $this->env->mock_tree[$progress->getNodeId()]['parent'];
273 if (is_null($parent_id)) {
274 return null;
275 }
276 return $this->getProgressRepository()->get($parent_id);
277 }
278
279 public function getChildrenProgress(ilPRGAssignment $assignment, int $progress_node_id): array
280 {
281 $progresses = [];
282 foreach ($this->env->mock_tree[$progress->getNodeId()]['children'] as $child_id) {
283 $progresses[] = $this->getProgressRepository()->get($child_id);
284 }
285 return $progresses;
286 }
287
288 public function testUpdateParentProgress(ilPRGProgress $progress): ilPRGProgress
289 {
290 return $this->updateParentProgress($progress);
291 }
292
293 public function testApplyProgressDeadline(ilPRGProgress $progress): ilPRGProgress
294 {
295 return $this->applyProgressDeadline($progress);
296 }
297
298 protected function getPrgInstanceByObjId(int $obj_id): ilObjStudyProgramme
299 {
300 return $this->tree[$obj_id]['prg'];
301 }
302
303 public function hasChildren(bool $include_references = false): bool
304 {
305 if ($this->id < 12) {
306 return true;
307 }
308 return false;
309 }
310}
311
312class ProgrammeEventsMock extends ilStudyProgrammeEvents
313{
314 public array $raised = [];// TODO PHP8-REVIEW Maybe the shape of the array can be expressed by PHPDoc comments
315
316 public function __construct()
317 {
318 }
319
320 public function raise($event, $parameter): void// TODO PHP8-REVIEW The type hints are missing
321 {
322 $this->raised[] = [$event, $parameter];
323 }
324
325 protected function getRefIdFor(int $obj_id): int
326 {
327 return 666;
328 }
329}
$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)
hasChildren(bool $include_references=false)
Does this StudyProgramme have other ilObjStudyProgrammes as children?
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
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(protected ilLogger $logger, protected ilAppEventHandler $app_event_handler, protected PRGEventHandler $prg_event_handler)
getObjId()
Get the id of the study program.
__construct(int $a_id, protected ilStudyProgrammeTypeSettings $type_settings, protected ilStudyProgrammeAssessmentSettings $assessment_settings, protected ilStudyProgrammeDeadlineSettings $deadline_settings, protected ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings, protected ilStudyProgrammeAutoMailSettings $automail_settings)
getProgressIdString(int $node_id)
getRefIdFor(int $obj_id)
applyProgressDeadline(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $progress, ?int $acting_usr_id=null, bool $recalculate=true)
store(ilPRGAssignment $assignment)
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