26 "mod1" => [
"components/ILIAS",
"Module1", [
30 "mod2" => [
"components/ILIAS",
"Module2", [
32 "ser1" => [
"components/ILIAS",
"Service1", [
35 "ser2" => [
"components/ILIAS",
"Service2", [
50 "richard.klees@concepts-and-training.de",
64 "richard.klees@concepts-and-training.de",
78 "richard.klees@concepts-and-training.de",
103 $this->data_factory =
new Data\Factory();
104 $this->ilias_version = $this->createMock(
Data\Version::class);
106 public function isPluginActivated(
string $id):
bool 114 public function setActivation(
string $id,
bool $activated):
void 117 public function getCurrentPluginVersion(
string $id): ?
Data\Version 121 public function getCurrentPluginDBVersion(
string $id): ?
int 125 public function setCurrentPluginVersion(
string $id,
Data\
Version $version,
int $db_version):
void 128 public function remove(
string $id):
void 134 protected function readComponentData(): array
138 protected function readPluginData(): array
142 public function _buildDatabase():
void 144 $this->buildDatabase();
163 $this->ilias_version,
169 $this->data_factory->version(
"0.9.1"),
171 $this->data_factory->version(
"1.9.1"),
172 $this->data_factory->version(
"8.0"),
173 $this->data_factory->version(
"8.999"),
175 "richard.klees@concepts-and-training.de",
232 $this->ilias_version,
238 $this->data_factory->version(
"0.9.1"),
240 $this->data_factory->version(
"2.9.1"),
241 $this->data_factory->version(
"8.1"),
242 $this->data_factory->version(
"8.999"),
244 "richard.klees@concepts-and-training.de",
252 $this->ilias_version,
258 $this->data_factory->version(
"0.9.1"),
260 $this->data_factory->version(
"2.9.2"),
261 $this->data_factory->version(
"8.1"),
262 $this->data_factory->version(
"8.999"),
264 "richard.klees@concepts-and-training.de",
274 $this->assertTrue($this->db->hasComponent(
"components/ILIAS",
"Module1"));
275 $this->assertTrue($this->db->hasComponent(
"components/ILIAS",
"Module2"));
276 $this->assertTrue($this->db->hasComponent(
"components/ILIAS",
"Service1"));
277 $this->assertTrue($this->db->hasComponent(
"components/ILIAS",
"Service2"));
278 $this->assertFalse($this->db->hasComponent(
"components/ILIAS",
"Module3"));
279 $this->assertFalse($this->db->hasComponent(
"components/ILIAS",
"Module4"));
280 $this->assertFalse($this->db->hasComponent(
"components/ILIAS",
"Service3"));
281 $this->assertFalse($this->db->hasComponent(
"components/ILIAS",
"Service4"));
286 $this->expectException(\InvalidArgumentException::class);
287 $this->db->hasComponent(
"OtherComponent",
"Module1");
292 $this->assertTrue($this->db->hasComponentId(
"mod1"));
293 $this->assertTrue($this->db->hasComponentId(
"mod2"));
294 $this->assertTrue($this->db->hasComponentId(
"ser1"));
295 $this->assertTrue($this->db->hasComponentId(
"ser2"));
296 $this->assertFalse($this->db->hasComponentId(
"mod3"));
297 $this->assertFalse($this->db->hasComponentId(
"mod4"));
298 $this->assertFalse($this->db->hasComponentId(
"ser3"));
299 $this->assertFalse($this->db->hasComponentId(
"ser4"));
304 $result = iterator_to_array($this->db->getComponents());
306 $ids = array_keys($result);
307 $expected_ids = [
"mod1",
"mod2",
"ser1",
"ser2"];
311 $this->assertEquals($expected_ids, $ids);
313 $this->assertEquals($this->mod1, $result[
"mod1"]);
314 $this->assertEquals($this->
mod2, $result[
"mod2"]);
315 $this->assertEquals($this->
ser1, $result[
"ser1"]);
316 $this->assertEquals($this->
ser2, $result[
"ser2"]);
321 $this->assertEquals($this->mod1, $this->db->getComponentById(
"mod1"));
322 $this->assertEquals($this->
mod2, $this->db->getComponentById(
"mod2"));
323 $this->assertEquals($this->
ser1, $this->db->getComponentById(
"ser1"));
324 $this->assertEquals($this->
ser2, $this->db->getComponentById(
"ser2"));
329 $this->assertEquals($this->mod1, $this->db->getComponentByTypeAndName(
"components/ILIAS",
"Module1"));
330 $this->assertEquals($this->
mod2, $this->db->getComponentByTypeAndName(
"components/ILIAS",
"Module2"));
331 $this->assertEquals($this->
ser1, $this->db->getComponentByTypeAndName(
"components/ILIAS",
"Service1"));
332 $this->assertEquals($this->
ser2, $this->db->getComponentByTypeAndName(
"components/ILIAS",
"Service2"));
337 $this->expectException(\InvalidArgumentException::class);
338 $this->db->getComponentByTypeAndName(
"components/ILIAS",
"Module3");
343 $this->expectException(\InvalidArgumentException::class);
344 $this->db->getComponentByTypeAndName(
"OtherComponent",
"Service1");
349 $this->expectException(\InvalidArgumentException::class);
350 $this->db->getComponentById(
"some_id");
355 $slots = iterator_to_array($this->db->getPluginSlots());
357 $ids = array_keys($slots);
358 $expected_ids = [
"slt1",
"slt2",
"slt3",
"slt4"];
362 $this->assertEquals($expected_ids, $ids);
364 $this->assertEquals($this->slt1, $slots[
"slt1"]);
365 $this->assertEquals($this->slt2, $slots[
"slt2"]);
366 $this->assertEquals($this->slt3, $slots[
"slt3"]);
367 $this->assertEquals($this->slt4, $slots[
"slt4"]);
372 $this->assertEquals($this->slt1, $this->db->getPluginSlotById(
"slt1"));
373 $this->assertEquals($this->slt2, $this->db->getPluginSlotById(
"slt2"));
374 $this->assertEquals($this->slt3, $this->db->getPluginSlotById(
"slt3"));
375 $this->assertEquals($this->slt4, $this->db->getPluginSlotById(
"slt4"));
381 protected function readComponentData(): array
383 return [
"mod2" => [
"components/ILIAS",
"Module2", []]];
385 protected function readPluginData(): array
392 $this->assertEquals([], $slots);
397 $plugins = iterator_to_array($this->db->getPlugins());
399 $ids = array_keys($plugins);
400 $expected_ids = [
"plg1",
"plg2",
"plg3"];
404 $this->assertEquals($expected_ids, $ids);
406 $this->assertEquals($this->plg1, $plugins[
"plg1"]);
407 $this->assertEquals($this->
plg2, $plugins[
"plg2"]);
412 $this->assertEquals($this->plg1, $this->db->getPluginById(
"plg1"));
413 $this->assertEquals($this->
plg2, $this->db->getPluginById(
"plg2"));
418 $this->assertEquals($this->plg1, $this->db->getPluginByName(
"Plugin1"));
419 $this->assertEquals($this->
plg2, $this->db->getPluginByName(
"Plugin2"));
424 $this->expectException(\InvalidArgumentException::class);
425 $this->db->getPluginById(
"some_id");
430 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
431 $plugin_state_db->expects($this->once())
432 ->method(
"isPluginActivated")
435 $plugin_state_db->expects($this->once())
436 ->method(
"getCurrentPluginVersion")
438 ->willReturn($this->data_factory->version(
"1.8.0"));
439 $plugin_state_db->expects($this->once())
440 ->method(
"getCurrentPluginDBVersion")
445 protected function readComponentData(): array
447 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
449 protected function readPluginData(): array
461 "richard.klees@concepts-and-training.de",
471 $this->assertTrue(
$plugin->isActivated());
473 $this->data_factory->version(
"1.8.0"),
476 $this->assertEquals(42,
$plugin->getCurrentDBVersion());
482 ->getComponentByTypeAndName(
"components/ILIAS",
"Module1")
483 ->getPluginSlotById(
"slt1")
484 ->getPluginById(
"plg1");
486 $this->assertEquals($this->plg1, $plg1);
491 $VERSION = $this->data_factory->version(
"1000.0.0");
494 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
496 ->method(
"isPluginActivated")
500 ->method(
"getCurrentPluginVersion")
502 ->willReturn($this->data_factory->version(
"1.8.0"));
504 ->method(
"getCurrentPluginDBVersion")
507 $plugin_state_db->expects($this->once())
508 ->method(
"setCurrentPluginVersion")
509 ->with(
"plg1", $VERSION, $DB_VERSION);
512 protected function readComponentData(): array
514 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
516 protected function readPluginData(): array
528 "richard.klees@concepts-and-training.de",
542 $VERSION = $this->data_factory->version(
"1000.0.0");
545 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
547 public int $build_called = 0;
548 protected function buildDatabase():
void 550 $this->build_called++;
551 parent::buildDatabase();
553 protected function readComponentData(): array
555 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
557 protected function readPluginData(): array
569 "richard.klees@concepts-and-training.de",
578 $this->assertEquals(1, $db->build_called);
582 $this->assertEquals(2, $db->build_called);
587 $this->db->_buildDatabase();
589 $this->assertEquals($this->mod1, $this->db->getComponentById(
"mod1"));
590 $this->assertEquals($this->mod1, $this->db->getComponentByTypeAndName(
"components/ILIAS",
"Module1"));
591 $this->assertEquals($this->slt1, $this->db->getPluginSlotById(
"slt1"));
592 $this->assertEquals($this->plg1, $this->db->getPluginById(
"plg1"));
593 $this->assertEquals($this->
plg2, $this->db->getPluginByName(
"Plugin2"));
598 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
601 protected function readComponentData(): array
603 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
605 protected function readPluginData(): array
617 "richard.klees@concepts-and-training.de",
626 $plugin_state_db->expects($this->once())
627 ->method(
"setActivation")
628 ->with(
"plg1",
true);
635 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
637 public int $build_called = 0;
638 protected function buildDatabase():
void 640 $this->build_called++;
641 parent::buildDatabase();
643 protected function readComponentData(): array
645 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
647 protected function readPluginData(): array
659 "richard.klees@concepts-and-training.de",
668 $this->assertEquals(1, $db->build_called);
672 $this->assertEquals(2, $db->build_called);
677 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
680 protected function readComponentData(): array
682 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
684 protected function readPluginData(): array
696 "richard.klees@concepts-and-training.de",
705 $plugin_state_db->expects($this->once())
714 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
716 public int $build_called = 0;
717 protected function buildDatabase():
void 719 $this->build_called++;
720 parent::buildDatabase();
722 protected function readComponentData(): array
724 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
726 protected function readPluginData(): array
738 "richard.klees@concepts-and-training.de",
747 $this->assertEquals(1, $db->build_called);
751 $this->assertEquals(2, $db->build_called);
756 $this->assertTrue($this->db->hasPluginId(
"plg1"));
757 $this->assertFalse($this->db->hasPluginId(
"plg666"));
762 $this->assertFalse($this->db->hasActivatedPlugin(
"plg1"));
763 $this->assertFalse($this->db->hasActivatedPlugin(
"plg666"));
764 $this->assertTrue($this->db->hasActivatedPlugin(
"plg3"));
Data Factory $data_factory
static array static array plg2
Data Version $ilias_version
setCurrentPluginVersion(string $plugin_id, Data\Version $version, int $db_version)
static array static array Richard richard klees concepts and training true
testHasComponentThrowsOnUnknownType()
testSetCurrentPluginVersionCallsStateDB()
testRemoveStateInformationOfTriggersRebuild()
static array static array Richard richard klees concepts and training null
testGetComponentByTypeAndNameThrowsOnUnknownComponent1()
testGetComponentByTypeAndName()
Simple value class for basic information about a pluginslot.
sort()
description: > Example for rendering a Sort Glyph.
testSetActivationCallsStateDB()
testGetPluginViaComponentAndPluginSlot()
removeStateInformationOf(string $plugin_id)
static array $component_data
ilArtifactComponentRepository $db
testGetComponentByTypeAndNameThrowsOnUnknownComponent2()
testSetCurrentPluginVersionCallsStateDBTriggersRebuild()
setActivation(string $plugin_id, bool $activated)
Repository interface for plugin state data.
Simple value class for information about a plugin.
testRemoveStateInformationOfCallsStateDB()
ilPluginStateDB $plugin_state_db
getPluginById(string $id)
Get a plugin by id.
testGetComponentByIdTypeThrowsOnInvalidId()
Repository for component data implemented over artifacts.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static array static array Richard richard klees concepts and training plg3
testSetActivationTriggersRebuild()
static array static array $plugin_data
A version number that consists of three numbers (major, minor, patch).
static array static array Richard richard klees concepts and training false
Simple value class for basic information about a component.
testCallBuildDatabaseTwice()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...