ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
prg_mocks.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 //NIFT: NotImplementedForTesting
22 trait 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 
76 trait 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 
149 trait 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 
173 class 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 
190 class 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 
207 class 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 
222 class 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 
256  protected function getAssignmentRepository(): ilPRGAssignmentDBRepository
257  {
258  return $this->env->assignment_repo;
259  }
260  protected function getSettingsRepository(): ilStudyProgrammeSettingsRepository
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 
312 class 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 }
store(ilPRGAssignment $assignment)
getRefIdFor(int $obj_id)
applyProgressDeadline(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $progress, ?int $acting_usr_id=null, bool $recalculate=true)
getProgressIdString(int $node_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
Covers the persistence of settings belonging to a study programme (SP).
getObjId()
Get the id of the study program.
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...