ILIAS  release_8 Revision v8.24
ilPluginInfoTest.php
Go to the documentation of this file.
1<?php
19use ILIAS\Data;
20use PHPUnit\Framework\TestCase;
21
22class ilPluginInfoTest extends TestCase
23{
24 protected ?Data\Factory $data_factory = null;
25 protected ?ilComponentInfo $component = null;
26 protected ?ilPluginSlotInfo $pluginslot = null;
27 protected ?ilPluginInfo $plugin = null;
28
29 protected function setUp(): void
30 {
31 $this->data_factory = new Data\Factory();
32
33 $slots = [];
34 $this->component = new ilComponentInfo(
35 "mod1",
36 "Modules",
37 "Module1",
38 $slots
39 );
40
41 $plugins = [];
42 $this->pluginslot = new ilPluginSlotInfo(
43 $this->component,
44 "slt1",
45 "Slot1",
46 $plugins
47 );
48 $slots[] = $this->pluginslot;
49
50 $this->plugin = new ilPluginInfo(
51 $this->data_factory->version("6.5"),
52 $this->pluginslot,
53 "plg1",
54 "Plugin1",
55 true,
56 $this->data_factory->version("1.0.0"),
57 12,
58 $this->data_factory->version("1.0.0"),
59 $this->data_factory->version("6.0"),
60 $this->data_factory->version("6.99"),
61 "Richard Klees",
62 "richard.klees@concepts-and-training.de",
63 true,
64 false,
65 true
66 );
67 }
68
69 public function testGetter(): void
70 {
71 $this->assertEquals($this->pluginslot, $this->plugin->getPluginSlot());
72 $this->assertEquals($this->component, $this->plugin->getComponent());
73 $this->assertEquals("plg1", $this->plugin->getId());
74 $this->assertEquals("Plugin1", $this->plugin->getName());
75 $this->assertTrue($this->plugin->isActivated());
76 $this->assertEquals($this->data_factory->version("1.0.0"), $this->plugin->getCurrentVersion());
77 $this->assertEquals(12, $this->plugin->getCurrentDBVersion());
78 $this->assertEquals($this->data_factory->version("1.0.0"), $this->plugin->getAvailableVersion());
79 $this->assertEquals($this->data_factory->version("6.0"), $this->plugin->getMinimumILIASVersion());
80 $this->assertEquals($this->data_factory->version("6.99"), $this->plugin->getMaximumILIASVersion());
81 $this->assertEquals("Richard Klees", $this->plugin->getResponsible());
82 $this->assertEquals("richard.klees@concepts-and-training.de", $this->plugin->getResponsibleMail());
83 $this->assertTrue($this->plugin->supportsLearningProgress());
84 $this->assertFalse($this->plugin->supportsExport());
85 $this->assertTrue($this->plugin->supportsCLISetup());
86 }
87
88 public function testIsInstalled(): void
89 {
90 $this->assertTrue($this->plugin->isInstalled());
91 }
92
93 public function testIsNotInstalled(): void
94 {
95 $this->plugin = new ilPluginInfo(
96 $this->data_factory->version("6.5"),
97 $this->pluginslot,
98 "plg1",
99 "Plugin1",
100 true,
101 null,
102 null,
103 $this->data_factory->version("1.0.0"),
104 $this->data_factory->version("6.0"),
105 $this->data_factory->version("6.99"),
106 "Richard Klees",
107 "richard.klees@concepts-and-training.de",
108 true,
109 false,
110 true
111 );
112
113 $this->assertFalse($this->plugin->isInstalled());
114 }
115
116 public function testUpdateIsNotRequired(): void
117 {
118 $this->assertFalse($this->plugin->isUpdateRequired());
119 }
120
122 {
123 $this->plugin = new ilPluginInfo(
124 $this->data_factory->version("6.5"),
125 $this->pluginslot,
126 "plg1",
127 "Plugin1",
128 true,
129 null,
130 null,
131 $this->data_factory->version("1.0.0"),
132 $this->data_factory->version("6.0"),
133 $this->data_factory->version("6.99"),
134 "Richard Klees",
135 "richard.klees@concepts-and-training.de",
136 true,
137 false,
138 true
139 );
140
141 $this->assertFalse($this->plugin->isUpdateRequired());
142 }
143
144 public function testUpdateIsRequired(): void
145 {
146 $this->plugin = new ilPluginInfo(
147 $this->data_factory->version("6.5"),
148 $this->pluginslot,
149 "plg1",
150 "Plugin1",
151 true,
152 $this->data_factory->version("2.0.0"),
153 11,
154 $this->data_factory->version("1.0.0"),
155 $this->data_factory->version("6.0"),
156 $this->data_factory->version("6.99"),
157 "Richard Klees",
158 "richard.klees@concepts-and-training.de",
159 true,
160 false,
161 true
162 );
163
164 $this->assertTrue($this->plugin->isUpdateRequired());
165 }
166
167 public function testIsVersionOld(): void
168 {
169 $this->assertFalse($this->plugin->isVersionToOld());
170
171 $plugin = new ilPluginInfo(
172 $this->data_factory->version("6.5"),
173 $this->pluginslot,
174 "plg1",
175 "Plugin1",
176 true,
177 $this->data_factory->version("1.0.0"),
178 12,
179 $this->data_factory->version("2.0.0"),
180 $this->data_factory->version("6.0"),
181 $this->data_factory->version("6.99"),
182 "Richard Klees",
183 "richard.klees@concepts-and-training.de",
184 true,
185 false,
186 true
187 );
188 $this->assertFalse($plugin->isVersionToOld());
189
190 $plugin = new ilPluginInfo(
191 $this->data_factory->version("6.5"),
192 $this->pluginslot,
193 "plg1",
194 "Plugin1",
195 true,
196 $this->data_factory->version("1.2.2"),
197 12,
198 $this->data_factory->version("1.0.0"),
199 $this->data_factory->version("6.0"),
200 $this->data_factory->version("6.99"),
201 "Richard Klees",
202 "richard.klees@concepts-and-training.de",
203 true,
204 false,
205 true
206 );
207 $this->assertTrue($plugin->isVersionToOld());
208 }
209
213 public function testIsCompliantToILIAS(Data\Version $version, bool $is_compliant): void
214 {
215 $plugin = new ilPluginInfo(
216 $version,
217 $this->pluginslot,
218 "plg1",
219 "Plugin1",
220 true,
221 $this->data_factory->version("1.2.2"),
222 12,
223 $this->data_factory->version("1.0.0"),
224 $this->data_factory->version("6.0"),
225 $this->data_factory->version("6.99"),
226 "Richard Klees",
227 "richard.klees@concepts-and-training.de",
228 true,
229 false,
230 true
231 );
232 $this->assertSame($is_compliant, $plugin->isCompliantToILIAS());
233 }
234
235 public function versionCompliance(): array
236 {
238 return [
239 [$data_factory->version("5.4"), false],
240 [$data_factory->version("6.5"), true],
241 [$data_factory->version("7.1"), false]
242 ];
243 }
244
245 public function testGetPath(): void
246 {
247 $this->assertEquals(
248 ilComponentRepository::PLUGIN_BASE_PATH . "/" . "Modules/Module1/Slot1/Plugin1",
249 $this->plugin->getPath()
250 );
251 }
252
253 public function testGetClassName(): void
254 {
255 $this->assertEquals(
256 "ilPlugin1Plugin",
257 $this->plugin->getClassName()
258 );
259 }
260
261 public function testGetConfigureClassName(): void
262 {
263 $this->assertEquals(
264 "ilPlugin1ConfigGUI",
265 $this->plugin->getConfigGUIClassName()
266 );
267 }
268
273 bool $is_installed,
274 bool $supports_current_ilias,
275 bool $needs_update,
276 bool $is_version_to_old,
277 bool $is_activation_possible
278 ): void {
279 $plugin = new class ($is_installed, $supports_current_ilias, $needs_update, $is_version_to_old) extends ilPluginInfo {
280 protected bool $is_installed;
281 protected bool $supports_current_ilias;
282 protected bool $needs_update;
283 protected bool $is_version_to_old;
284
285 public function __construct(
286 bool $is_installed,
287 bool $supports_current_ilias,
288 bool $needs_update,
289 bool $is_version_to_old
290 ) {
291 $this->is_installed = $is_installed;
292 $this->supports_current_ilias = $supports_current_ilias;
293 $this->needs_update = $needs_update;
294 $this->is_version_to_old = $is_version_to_old;
295 }
296
297 public function isInstalled(): bool
298 {
299 return $this->is_installed;
300 }
301
302 public function isUpdateRequired(): bool
303 {
304 return $this->needs_update;
305 }
306
307 public function isCompliantToILIAS(): bool
308 {
309 return $this->supports_current_ilias;
310 }
311
312 public function isVersionToOld(): bool
313 {
314 return $this->is_version_to_old;
315 }
316 };
317
318 $this->assertEquals($is_activation_possible, $plugin->isActivationPossible());
319 }
320
321 public function isActivationPossibleTruthTable(): array
322 {
323 // is_installed, supports_current_ilias, needs_update, is_version_to_old => is_activation_possible
324 return [
325 [false, false, false, false, false],
326 [false, false, true, false, false],
327 [false, true, false, false, false],
328 [false, true, true, false, false],
329 [true, false, false, false, false],
330 [true, false, true, false, false],
331 [true, true, false, false, true],
332 [true, true, true, true, false],
333 [false, false, false, true, false],
334 [false, false, true, true, false],
335 [false, true, false, true, false],
336 [false, true, true, true, false],
337 [true, false, false, true, false],
338 [true, false, true, true, false],
339 [true, true, false, true, false],
340 [true, true, true, true, false]
341 ];
342 }
343
347 public function testIsActive(
348 bool $is_installed,
349 bool $supports_current_ilias,
350 bool $needs_update,
351 bool $is_activated,
352 bool $is_version_to_old,
353 bool $is_activation_possible
354 ): void {
355 $plugin = new class ($is_installed, $supports_current_ilias, $needs_update, $is_activated, $is_version_to_old) extends ilPluginInfo {
356 protected bool $is_installed;
357 protected bool $supports_current_ilias;
358 protected bool $needs_update;
359 protected bool $is_activated;
360 protected bool $is_version_to_old;
361
362 public function __construct(
363 bool $is_installed,
364 bool $supports_current_ilias,
365 bool $needs_update,
366 bool $is_activated,
367 bool $is_version_to_old
368 ) {
369 $this->is_installed = $is_installed;
370 $this->supports_current_ilias = $supports_current_ilias;
371 $this->needs_update = $needs_update;
372 $this->is_activated = $is_activated;
373 $this->is_version_to_old = $is_version_to_old;
374 }
375
376 public function isActivated(): bool
377 {
378 return $this->is_activated;
379 }
380
381 public function isInstalled(): bool
382 {
383 return $this->is_installed;
384 }
385
386 public function isUpdateRequired(): bool
387 {
388 return $this->needs_update;
389 }
390
391 public function isCompliantToILIAS(): bool
392 {
393 return $this->supports_current_ilias;
394 }
395
396 public function isVersionToOld(): bool
397 {
398 return $this->is_version_to_old;
399 }
400 };
401
402 $this->assertEquals($is_activation_possible, $plugin->isActive());
403 }
404
405 public function isActiveTruthTable(): array
406 {
407 // is_installed, supports_current_ilias, needs_update, is_activated, is_version_to_old => is_active
408 return [
409 [false, false, false, false, false, false],
410 [false, false, false, true, false, false],
411 [false, false, true , false, false, false],
412 [false, false, true , true, false, false],
413 [false, true, false, false, false, false],
414 [false, true, false, true, false, false],
415 [false, true, true , false, false, false],
416 [false, true, true , true, false, false],
417 [true, false, false, false, false, false],
418 [true, false, false, true, false, false],
419 [true, false, true , false, false, false],
420 [true, false, true , true, false, false],
421 [true, true, false, false, false, false],
422 [true, true, false, true, false, true],
423 [true, true, true , false, false, false],
424 [true, true, true , true, false, false],
425
426 [false, false, false, false, true, false],
427 [false, false, false, true, true, false],
428 [false, false, true , false, true, false],
429 [false, false, true , true, true, false],
430 [false, true, false, false, true, false],
431 [false, true, false, true, true, false],
432 [false, true, true , false, true, false],
433 [false, true, true , true, true, false],
434 [true, false, false, false, true, false],
435 [true, false, false, true, true, false],
436 [true, false, true , false, true, false],
437 [true, false, true , true, true, false],
438 [true, true, false, false, true, false],
439 [true, true, false, true, true, false],
440 [true, true, true , false, true, false],
441 [true, true, true , true, true, false],
442 ];
443 }
444
445
450 bool $is_installed,
451 bool $supports_current_ilias,
452 bool $needs_update,
453 bool $is_activated,
454 bool $is_version_to_old,
455 string $inactivity_reason
456 ): void {
457 $plugin = new class ($is_installed, $supports_current_ilias, $needs_update, $is_activated, $is_version_to_old) extends ilPluginInfo {
458 protected bool $is_installed;
459 protected bool $supports_current_ilias;
460 protected bool $needs_update;
461 protected bool $is_activated;
462 protected bool $is_version_to_old;
463
464 public function __construct(
465 bool $is_installed,
466 bool $supports_current_ilias,
467 bool $needs_update,
468 bool $is_activated,
469 bool $is_version_to_old
470 ) {
471 $this->is_installed = $is_installed;
472 $this->supports_current_ilias = $supports_current_ilias;
473 $this->needs_update = $needs_update;
474 $this->is_activated = $is_activated;
475 $this->is_version_to_old = $is_version_to_old;
476 }
477
478 public function isActivated(): bool
479 {
480 return $this->is_activated;
481 }
482
483 public function isInstalled(): bool
484 {
485 return $this->is_installed;
486 }
487
488 public function isUpdateRequired(): bool
489 {
490 return $this->needs_update;
491 }
492
493 public function isCompliantToILIAS(): bool
494 {
495 return $this->supports_current_ilias;
496 }
497
498 public function getCurrentVersion(): ?Data\Version
499 {
500 return $this->current_version;
501 }
502
503 public function isVersionToOld(): bool
504 {
505 return $this->is_version_to_old;
506 }
507 };
508
509 $this->assertEquals($inactivity_reason, $plugin->getReasonForInactivity());
510 }
511
513 {
514 $this->expectException(LogicException::class);
515
516 $plugin = new class () extends ilPluginInfo {
517 public function __construct()
518 {
519 }
520
521 public function isActive(): bool
522 {
523 return true;
524 }
525 };
526
527 $plugin->getReasonForInactivity();
528 }
529
530 public function inactivityReasonTable(): array
531 {
532 // is_installed, supports_current_ilias, needs_update, is_activated, is_version_to_old => inactivity_reason
533 return [
534 [false, false, false, false, false, "cmps_needs_matching_ilias_version"],
535 [false, false, false, true, false, "cmps_needs_matching_ilias_version"],
536 [false, false, true , false, false, "cmps_needs_matching_ilias_version"],
537 [false, false, true , true, false, "cmps_needs_matching_ilias_version"],
538 [false, true, false, false, false, "cmps_must_installed"],
539 [false, true, false, true, false, "cmps_must_installed"],
540 [false, true, true , false, false, "cmps_must_installed"],
541 [false, true, true , true, false, "cmps_must_installed"],
542 [true, false, false, false, false, "cmps_needs_matching_ilias_version"],
543 [true, false, false, true, false, "cmps_needs_matching_ilias_version"],
544 [true, false, true , false, false, "cmps_needs_matching_ilias_version"],
545 [true, false, true , true, false, "cmps_needs_matching_ilias_version"],
546 [true, true, false, false, false, "cmps_not_activated"],
547 [true, true, true , false, false, "cmps_needs_update"],
548 [true, true, true , true, false, "cmps_needs_update"],
549 [false, false, false, false, true, "cmps_needs_matching_ilias_version"],
550 [false, false, false, true, true, "cmps_needs_matching_ilias_version"],
551 [false, false, true , false, true, "cmps_needs_matching_ilias_version"],
552 [false, false, true , true, true, "cmps_needs_matching_ilias_version"],
553 [false, true, false, false, true, "cmps_must_installed"],
554 [false, true, false, true, true, "cmps_must_installed"],
555 [false, true, true , false, true, "cmps_must_installed"],
556 [false, true, true , true, true, "cmps_must_installed"],
557 [true, false, false, false, true, "cmps_needs_matching_ilias_version"],
558 [true, false, false, true, true, "cmps_needs_matching_ilias_version"],
559 [true, false, true , false, true, "cmps_needs_matching_ilias_version"],
560 [true, false, true , true, true, "cmps_needs_matching_ilias_version"],
561 [true, true, false, false, true, "cmps_needs_upgrade"],
562 [true, true, true , false, true, "cmps_needs_upgrade"],
563 [true, true, true , true, true, "cmps_needs_upgrade"],
564 ];
565 }
566}
$version
Definition: plugin.php:24
Builds data types.
Definition: Factory.php:21
version(string $version)
Definition: Factory.php:154
A version number that consists of three numbers (major, minor, patch).
Definition: Version.php:27
return true
Simple value class for basic information about a component.
testIsCompliantToILIAS(Data\Version $version, bool $is_compliant)
@dataProvider versionCompliance
ilPluginInfo $plugin
testIsActive(bool $is_installed, bool $supports_current_ilias, bool $needs_update, bool $is_activated, bool $is_version_to_old, bool $is_activation_possible)
@dataProvider isActiveTruthTable
testGetReasonForInactivityThrowsOnActivePlugin()
testGetReasonForInactivity(bool $is_installed, bool $supports_current_ilias, bool $needs_update, bool $is_activated, bool $is_version_to_old, string $inactivity_reason)
@dataProvider inactivityReasonTable
testIsActivationPossible(bool $is_installed, bool $supports_current_ilias, bool $needs_update, bool $is_version_to_old, bool $is_activation_possible)
@dataProvider isActivationPossibleTruthTable
Data Factory $data_factory
ilPluginSlotInfo $pluginslot
ilComponentInfo $component
Simple value class for information about a plugin.
isCompliantToILIAS()
"ILIAS Version compliance" tells if the plugin can be operated with the given ILIAS version.
isVersionToOld()
"Version to old" tells if the plugin code has a version that is below the version that was updated la...
Simple value class for basic information about a pluginslot.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc