25 "mod1" => [
"components/ILIAS",
"Module1", [
29 "mod2" => [
"components/ILIAS",
"Module2", [
31 "ser1" => [
"components/ILIAS",
"Service1", [
34 "ser2" => [
"components/ILIAS",
"Service2", [
49 "richard.klees@concepts-and-training.de",
63 "richard.klees@concepts-and-training.de",
77 "richard.klees@concepts-and-training.de",
102 $this->data_factory =
new Data\Factory();
103 $this->ilias_version = $this->createMock(
Data\Version::class);
105 public function isPluginActivated(
string $id):
bool 113 public function setActivation(
string $id,
bool $activated):
void 116 public function getCurrentPluginVersion(
string $id): ?
Data\Version 120 public function getCurrentPluginDBVersion(
string $id): ?
int 124 public function setCurrentPluginVersion(
string $id,
Data\
Version $version,
int $db_version):
void 127 public function remove(
string $id):
void 133 protected function readComponentData(): array
137 protected function readPluginData(): array
141 public function _buildDatabase():
void 143 $this->buildDatabase();
162 $this->ilias_version,
168 $this->data_factory->version(
"0.9.1"),
170 $this->data_factory->version(
"1.9.1"),
171 $this->data_factory->version(
"8.0"),
172 $this->data_factory->version(
"8.999"),
174 "richard.klees@concepts-and-training.de",
231 $this->ilias_version,
237 $this->data_factory->version(
"0.9.1"),
239 $this->data_factory->version(
"2.9.1"),
240 $this->data_factory->version(
"8.1"),
241 $this->data_factory->version(
"8.999"),
243 "richard.klees@concepts-and-training.de",
251 $this->ilias_version,
257 $this->data_factory->version(
"0.9.1"),
259 $this->data_factory->version(
"2.9.2"),
260 $this->data_factory->version(
"8.1"),
261 $this->data_factory->version(
"8.999"),
263 "richard.klees@concepts-and-training.de",
273 $this->assertTrue($this->db->hasComponent(
"components/ILIAS",
"Module1"));
274 $this->assertTrue($this->db->hasComponent(
"components/ILIAS",
"Module2"));
275 $this->assertTrue($this->db->hasComponent(
"components/ILIAS",
"Service1"));
276 $this->assertTrue($this->db->hasComponent(
"components/ILIAS",
"Service2"));
277 $this->assertFalse($this->db->hasComponent(
"components/ILIAS",
"Module3"));
278 $this->assertFalse($this->db->hasComponent(
"components/ILIAS",
"Module4"));
279 $this->assertFalse($this->db->hasComponent(
"components/ILIAS",
"Service3"));
280 $this->assertFalse($this->db->hasComponent(
"components/ILIAS",
"Service4"));
285 $this->expectException(\InvalidArgumentException::class);
286 $this->db->hasComponent(
"OtherComponent",
"Module1");
291 $this->assertTrue($this->db->hasComponentId(
"mod1"));
292 $this->assertTrue($this->db->hasComponentId(
"mod2"));
293 $this->assertTrue($this->db->hasComponentId(
"ser1"));
294 $this->assertTrue($this->db->hasComponentId(
"ser2"));
295 $this->assertFalse($this->db->hasComponentId(
"mod3"));
296 $this->assertFalse($this->db->hasComponentId(
"mod4"));
297 $this->assertFalse($this->db->hasComponentId(
"ser3"));
298 $this->assertFalse($this->db->hasComponentId(
"ser4"));
303 $result = iterator_to_array($this->db->getComponents());
305 $ids = array_keys($result);
306 $expected_ids = [
"mod1",
"mod2",
"ser1",
"ser2"];
310 $this->assertEquals($expected_ids, $ids);
312 $this->assertEquals($this->mod1, $result[
"mod1"]);
313 $this->assertEquals($this->
mod2, $result[
"mod2"]);
314 $this->assertEquals($this->
ser1, $result[
"ser1"]);
315 $this->assertEquals($this->
ser2, $result[
"ser2"]);
320 $this->assertEquals($this->mod1, $this->db->getComponentById(
"mod1"));
321 $this->assertEquals($this->
mod2, $this->db->getComponentById(
"mod2"));
322 $this->assertEquals($this->
ser1, $this->db->getComponentById(
"ser1"));
323 $this->assertEquals($this->
ser2, $this->db->getComponentById(
"ser2"));
328 $this->assertEquals($this->mod1, $this->db->getComponentByTypeAndName(
"components/ILIAS",
"Module1"));
329 $this->assertEquals($this->
mod2, $this->db->getComponentByTypeAndName(
"components/ILIAS",
"Module2"));
330 $this->assertEquals($this->
ser1, $this->db->getComponentByTypeAndName(
"components/ILIAS",
"Service1"));
331 $this->assertEquals($this->
ser2, $this->db->getComponentByTypeAndName(
"components/ILIAS",
"Service2"));
336 $this->expectException(\InvalidArgumentException::class);
337 $this->db->getComponentByTypeAndName(
"components/ILIAS",
"Module3");
342 $this->expectException(\InvalidArgumentException::class);
343 $this->db->getComponentByTypeAndName(
"OtherComponent",
"Service1");
348 $this->expectException(\InvalidArgumentException::class);
349 $this->db->getComponentById(
"some_id");
354 $slots = iterator_to_array($this->db->getPluginSlots());
356 $ids = array_keys($slots);
357 $expected_ids = [
"slt1",
"slt2",
"slt3",
"slt4"];
361 $this->assertEquals($expected_ids, $ids);
363 $this->assertEquals($this->slt1, $slots[
"slt1"]);
364 $this->assertEquals($this->slt2, $slots[
"slt2"]);
365 $this->assertEquals($this->slt3, $slots[
"slt3"]);
366 $this->assertEquals($this->slt4, $slots[
"slt4"]);
371 $this->assertEquals($this->slt1, $this->db->getPluginSlotById(
"slt1"));
372 $this->assertEquals($this->slt2, $this->db->getPluginSlotById(
"slt2"));
373 $this->assertEquals($this->slt3, $this->db->getPluginSlotById(
"slt3"));
374 $this->assertEquals($this->slt4, $this->db->getPluginSlotById(
"slt4"));
380 protected function readComponentData(): array
382 return [
"mod2" => [
"components/ILIAS",
"Module2", []]];
384 protected function readPluginData(): array
391 $this->assertEquals([], $slots);
396 $plugins = iterator_to_array($this->db->getPlugins());
398 $ids = array_keys($plugins);
399 $expected_ids = [
"plg1",
"plg2",
"plg3"];
403 $this->assertEquals($expected_ids, $ids);
405 $this->assertEquals($this->plg1, $plugins[
"plg1"]);
406 $this->assertEquals($this->
plg2, $plugins[
"plg2"]);
411 $this->assertEquals($this->plg1, $this->db->getPluginById(
"plg1"));
412 $this->assertEquals($this->
plg2, $this->db->getPluginById(
"plg2"));
417 $this->assertEquals($this->plg1, $this->db->getPluginByName(
"Plugin1"));
418 $this->assertEquals($this->
plg2, $this->db->getPluginByName(
"Plugin2"));
423 $this->expectException(\InvalidArgumentException::class);
424 $this->db->getPluginById(
"some_id");
429 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
430 $plugin_state_db->expects($this->once())
431 ->method(
"isPluginActivated")
434 $plugin_state_db->expects($this->once())
435 ->method(
"getCurrentPluginVersion")
437 ->willReturn($this->data_factory->version(
"1.8.0"));
438 $plugin_state_db->expects($this->once())
439 ->method(
"getCurrentPluginDBVersion")
444 protected function readComponentData(): array
446 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
448 protected function readPluginData(): array
460 "richard.klees@concepts-and-training.de",
470 $this->assertTrue(
$plugin->isActivated());
472 $this->data_factory->version(
"1.8.0"),
475 $this->assertEquals(42,
$plugin->getCurrentDBVersion());
481 ->getComponentByTypeAndName(
"components/ILIAS",
"Module1")
482 ->getPluginSlotById(
"slt1")
483 ->getPluginById(
"plg1");
485 $this->assertEquals($this->plg1, $plg1);
490 $VERSION = $this->data_factory->version(
"1000.0.0");
493 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
495 ->method(
"isPluginActivated")
499 ->method(
"getCurrentPluginVersion")
501 ->willReturn($this->data_factory->version(
"1.8.0"));
503 ->method(
"getCurrentPluginDBVersion")
506 $plugin_state_db->expects($this->once())
507 ->method(
"setCurrentPluginVersion")
508 ->with(
"plg1", $VERSION, $DB_VERSION);
511 protected function readComponentData(): array
513 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
515 protected function readPluginData(): array
527 "richard.klees@concepts-and-training.de",
541 $VERSION = $this->data_factory->version(
"1000.0.0");
544 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
546 public int $build_called = 0;
547 protected function buildDatabase():
void 549 $this->build_called++;
550 parent::buildDatabase();
552 protected function readComponentData(): array
554 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
556 protected function readPluginData(): array
568 "richard.klees@concepts-and-training.de",
577 $this->assertEquals(1, $db->build_called);
581 $this->assertEquals(2, $db->build_called);
586 $this->db->_buildDatabase();
588 $this->assertEquals($this->mod1, $this->db->getComponentById(
"mod1"));
589 $this->assertEquals($this->mod1, $this->db->getComponentByTypeAndName(
"components/ILIAS",
"Module1"));
590 $this->assertEquals($this->slt1, $this->db->getPluginSlotById(
"slt1"));
591 $this->assertEquals($this->plg1, $this->db->getPluginById(
"plg1"));
592 $this->assertEquals($this->
plg2, $this->db->getPluginByName(
"Plugin2"));
597 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
600 protected function readComponentData(): array
602 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
604 protected function readPluginData(): array
616 "richard.klees@concepts-and-training.de",
625 $plugin_state_db->expects($this->once())
626 ->method(
"setActivation")
627 ->with(
"plg1",
true);
634 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
636 public int $build_called = 0;
637 protected function buildDatabase():
void 639 $this->build_called++;
640 parent::buildDatabase();
642 protected function readComponentData(): array
644 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
646 protected function readPluginData(): array
658 "richard.klees@concepts-and-training.de",
667 $this->assertEquals(1, $db->build_called);
671 $this->assertEquals(2, $db->build_called);
676 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
679 protected function readComponentData(): array
681 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
683 protected function readPluginData(): array
695 "richard.klees@concepts-and-training.de",
704 $plugin_state_db->expects($this->once())
713 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
715 public int $build_called = 0;
716 protected function buildDatabase():
void 718 $this->build_called++;
719 parent::buildDatabase();
721 protected function readComponentData(): array
723 return [
"mod1" => [
"components/ILIAS",
"Module1", [[
"slt1",
"Slot1"]]]];
725 protected function readPluginData(): array
737 "richard.klees@concepts-and-training.de",
746 $this->assertEquals(1, $db->build_called);
750 $this->assertEquals(2, $db->build_called);
755 $this->assertTrue($this->db->hasPluginId(
"plg1"));
756 $this->assertFalse($this->db->hasPluginId(
"plg666"));
761 $this->assertFalse($this->db->hasActivatedPlugin(
"plg1"));
762 $this->assertFalse($this->db->hasActivatedPlugin(
"plg666"));
763 $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()