26 "mod1" => [
"Modules",
"Module1", [
30 "mod2" => [
"Modules",
"Module2", [
32 "ser1" => [
"Services",
"Service1", [
35 "ser2" => [
"Services",
"Service2", [
50 "richard.klees@concepts-and-training.de",
64 "richard.klees@concepts-and-training.de",
78 "richard.klees@concepts-and-training.de",
85 protected function setUp(): void
87 $this->data_factory =
new Data\Factory();
88 $this->ilias_version = $this->createMock(Data\Version::class);
90 public function isPluginActivated(
string $id):
bool 98 public function setActivation(
string $id,
bool $activated):
void 101 public function getCurrentPluginVersion(
string $id): ?Data\Version
103 return (
new Data\
Factory())->version(
"0.9.1");
105 public function getCurrentPluginDBVersion(
string $id): ?
int 109 public function setCurrentPluginVersion(
string $id, Data\
Version $version,
int $db_version):
void 112 public function remove(
string $id):
void 118 protected function readComponentData(): array
122 protected function readPluginData(): array
126 public function _buildDatabase():
void 128 $this->buildDatabase();
147 $this->ilias_version,
152 $this->data_factory->version(
"0.9.1"),
154 $this->data_factory->version(
"1.9.1"),
155 $this->data_factory->version(
"8.0"),
156 $this->data_factory->version(
"8.999"),
158 "richard.klees@concepts-and-training.de",
163 $plugins1[
"plg1"] = $this->plg1;
171 $slots1 = [
"slt1" => $this->slt1,
"slt2" => $this->slt2];
196 $slots3 = [
"slt3" => $this->slt3];
212 $slots4 = [
"slt4" => $this->slt4];
215 $this->ilias_version,
220 $this->data_factory->version(
"0.9.1"),
222 $this->data_factory->version(
"2.9.1"),
223 $this->data_factory->version(
"8.1"),
224 $this->data_factory->version(
"8.999"),
226 "richard.klees@concepts-and-training.de",
231 $plugins4[
"plg2"] = $this->plg2;
234 $this->ilias_version,
239 $this->data_factory->version(
"0.9.1"),
241 $this->data_factory->version(
"2.9.2"),
242 $this->data_factory->version(
"8.1"),
243 $this->data_factory->version(
"8.999"),
245 "richard.klees@concepts-and-training.de",
250 $plugins4[
"plg3"] = $this->plg3;
255 $this->assertTrue($this->db->hasComponent(
"Modules",
"Module1"));
256 $this->assertTrue($this->db->hasComponent(
"Modules",
"Module2"));
257 $this->assertTrue($this->db->hasComponent(
"Services",
"Service1"));
258 $this->assertTrue($this->db->hasComponent(
"Services",
"Service2"));
259 $this->assertFalse($this->db->hasComponent(
"Modules",
"Module3"));
260 $this->assertFalse($this->db->hasComponent(
"Modules",
"Module4"));
261 $this->assertFalse($this->db->hasComponent(
"Services",
"Service3"));
262 $this->assertFalse($this->db->hasComponent(
"Services",
"Service4"));
267 $this->expectException(\InvalidArgumentException::class);
268 $this->db->hasComponent(
"OtherComponent",
"Module1");
273 $this->assertTrue($this->db->hasComponentId(
"mod1"));
274 $this->assertTrue($this->db->hasComponentId(
"mod2"));
275 $this->assertTrue($this->db->hasComponentId(
"ser1"));
276 $this->assertTrue($this->db->hasComponentId(
"ser2"));
277 $this->assertFalse($this->db->hasComponentId(
"mod3"));
278 $this->assertFalse($this->db->hasComponentId(
"mod4"));
279 $this->assertFalse($this->db->hasComponentId(
"ser3"));
280 $this->assertFalse($this->db->hasComponentId(
"ser4"));
285 $result = iterator_to_array($this->db->getComponents());
287 $ids = array_keys($result);
288 $expected_ids = [
"mod1",
"mod2",
"ser1",
"ser2"];
292 $this->assertEquals($expected_ids, $ids);
294 $this->assertEquals($this->mod1, $result[
"mod1"]);
295 $this->assertEquals($this->
mod2, $result[
"mod2"]);
296 $this->assertEquals($this->
ser1, $result[
"ser1"]);
297 $this->assertEquals($this->
ser2, $result[
"ser2"]);
302 $this->assertEquals($this->mod1, $this->db->getComponentById(
"mod1"));
303 $this->assertEquals($this->
mod2, $this->db->getComponentById(
"mod2"));
304 $this->assertEquals($this->
ser1, $this->db->getComponentById(
"ser1"));
305 $this->assertEquals($this->
ser2, $this->db->getComponentById(
"ser2"));
310 $this->assertEquals($this->mod1, $this->db->getComponentByTypeAndName(
"Modules",
"Module1"));
311 $this->assertEquals($this->
mod2, $this->db->getComponentByTypeAndName(
"Modules",
"Module2"));
312 $this->assertEquals($this->
ser1, $this->db->getComponentByTypeAndName(
"Services",
"Service1"));
313 $this->assertEquals($this->
ser2, $this->db->getComponentByTypeAndName(
"Services",
"Service2"));
318 $this->expectException(\InvalidArgumentException::class);
319 $this->db->getComponentByTypeAndName(
"Modules",
"Module3");
324 $this->expectException(\InvalidArgumentException::class);
325 $this->db->getComponentByTypeAndName(
"OtherComponent",
"Service1");
330 $this->expectException(\InvalidArgumentException::class);
331 $this->db->getComponentById(
"some_id");
336 $slots = iterator_to_array($this->db->getPluginSlots());
338 $ids = array_keys($slots);
339 $expected_ids = [
"slt1",
"slt2",
"slt3",
"slt4"];
343 $this->assertEquals($expected_ids, $ids);
345 $this->assertEquals($this->slt1, $slots[
"slt1"]);
346 $this->assertEquals($this->slt2, $slots[
"slt2"]);
347 $this->assertEquals($this->slt3, $slots[
"slt3"]);
348 $this->assertEquals($this->slt4, $slots[
"slt4"]);
353 $this->assertEquals($this->slt1, $this->db->getPluginSlotById(
"slt1"));
354 $this->assertEquals($this->slt2, $this->db->getPluginSlotById(
"slt2"));
355 $this->assertEquals($this->slt3, $this->db->getPluginSlotById(
"slt3"));
356 $this->assertEquals($this->slt4, $this->db->getPluginSlotById(
"slt4"));
362 protected function readComponentData(): array
364 return [
"mod2" => [
"Modules",
"Module2", []]];
366 protected function readPluginData(): array
372 $slots = iterator_to_array($db->getPluginSlots());
373 $this->assertEquals([], $slots);
378 $plugins = iterator_to_array($this->db->getPlugins());
380 $ids = array_keys($plugins);
381 $expected_ids = [
"plg1",
"plg2",
"plg3"];
385 $this->assertEquals($expected_ids, $ids);
387 $this->assertEquals($this->plg1, $plugins[
"plg1"]);
388 $this->assertEquals($this->
plg2, $plugins[
"plg2"]);
393 $this->assertEquals($this->plg1, $this->db->getPluginById(
"plg1"));
394 $this->assertEquals($this->
plg2, $this->db->getPluginById(
"plg2"));
399 $this->assertEquals($this->plg1, $this->db->getPluginByName(
"Plugin1"));
400 $this->assertEquals($this->
plg2, $this->db->getPluginByName(
"Plugin2"));
405 $this->expectException(\InvalidArgumentException::class);
406 $this->db->getPluginById(
"some_id");
411 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
412 $plugin_state_db->expects($this->once())
413 ->method(
"isPluginActivated")
416 $plugin_state_db->expects($this->once())
417 ->method(
"getCurrentPluginVersion")
419 ->willReturn($this->data_factory->version(
"1.8.0"));
420 $plugin_state_db->expects($this->once())
421 ->method(
"getCurrentPluginDBVersion")
426 protected function readComponentData(): array
428 return [
"mod1" => [
"Modules",
"Module1", [[
"slt1",
"Slot1"]]]];
430 protected function readPluginData(): array
442 "richard.klees@concepts-and-training.de",
451 $plugin = $db->getPluginById(
"plg1");
452 $this->assertTrue(
$plugin->isActivated());
454 $this->data_factory->version(
"1.8.0"),
457 $this->assertEquals(42,
$plugin->getCurrentDBVersion());
463 ->getComponentByTypeAndName(
"Modules",
"Module1")
464 ->getPluginSlotById(
"slt1")
465 ->getPluginById(
"plg1");
467 $this->assertEquals($this->plg1, $plg1);
472 $VERSION = $this->data_factory->version(
"1000.0.0");
475 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
477 ->method(
"isPluginActivated")
481 ->method(
"getCurrentPluginVersion")
483 ->willReturn($this->data_factory->version(
"1.8.0"));
485 ->method(
"getCurrentPluginDBVersion")
488 $plugin_state_db->expects($this->once())
489 ->method(
"setCurrentPluginVersion")
490 ->with(
"plg1", $VERSION, $DB_VERSION);
493 protected function readComponentData(): array
495 return [
"mod1" => [
"Modules",
"Module1", [[
"slt1",
"Slot1"]]]];
497 protected function readPluginData(): array
509 "richard.klees@concepts-and-training.de",
518 $db->setCurrentPluginVersion(
"plg1", $VERSION, $DB_VERSION);
523 $VERSION = $this->data_factory->version(
"1000.0.0");
526 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
528 public int $build_called = 0;
529 protected function buildDatabase():
void 531 $this->build_called++;
532 parent::buildDatabase();
534 protected function readComponentData(): array
536 return [
"mod1" => [
"Modules",
"Module1", [[
"slt1",
"Slot1"]]]];
538 protected function readPluginData(): array
550 "richard.klees@concepts-and-training.de",
559 $this->assertEquals(1, $db->build_called);
561 $db->setCurrentPluginVersion(
"plg1", $VERSION, $DB_VERSION);
563 $this->assertEquals(2, $db->build_called);
568 $this->db->_buildDatabase();
570 $this->assertEquals($this->mod1, $this->db->getComponentById(
"mod1"));
571 $this->assertEquals($this->mod1, $this->db->getComponentByTypeAndName(
"Modules",
"Module1"));
572 $this->assertEquals($this->slt1, $this->db->getPluginSlotById(
"slt1"));
573 $this->assertEquals($this->plg1, $this->db->getPluginById(
"plg1"));
574 $this->assertEquals($this->
plg2, $this->db->getPluginByName(
"Plugin2"));
579 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
582 protected function readComponentData(): array
584 return [
"mod1" => [
"Modules",
"Module1", [[
"slt1",
"Slot1"]]]];
586 protected function readPluginData(): array
598 "richard.klees@concepts-and-training.de",
607 $plugin_state_db->expects($this->once())
608 ->method(
"setActivation")
609 ->with(
"plg1",
true);
611 $db->setActivation(
"plg1",
true);
616 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
618 public int $build_called = 0;
619 protected function buildDatabase():
void 621 $this->build_called++;
622 parent::buildDatabase();
624 protected function readComponentData(): array
626 return [
"mod1" => [
"Modules",
"Module1", [[
"slt1",
"Slot1"]]]];
628 protected function readPluginData(): array
640 "richard.klees@concepts-and-training.de",
649 $this->assertEquals(1, $db->build_called);
651 $db->setActivation(
"plg1",
false);
653 $this->assertEquals(2, $db->build_called);
658 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
661 protected function readComponentData(): array
663 return [
"mod1" => [
"Modules",
"Module1", [[
"slt1",
"Slot1"]]]];
665 protected function readPluginData(): array
677 "richard.klees@concepts-and-training.de",
686 $plugin_state_db->expects($this->once())
690 $db->removeStateInformationOf(
"plg1");
695 $plugin_state_db = $this->createMock(ilPluginStateDB::class);
697 public int $build_called = 0;
698 protected function buildDatabase():
void 700 $this->build_called++;
701 parent::buildDatabase();
703 protected function readComponentData(): array
705 return [
"mod1" => [
"Modules",
"Module1", [[
"slt1",
"Slot1"]]]];
707 protected function readPluginData(): array
719 "richard.klees@concepts-and-training.de",
728 $this->assertEquals(1, $db->build_called);
730 $db->removeStateInformationOf(
"plg1");
732 $this->assertEquals(2, $db->build_called);
737 $this->assertTrue($this->db->hasPluginId(
"plg1"));
738 $this->assertFalse($this->db->hasPluginId(
"plg666"));
743 $this->assertFalse($this->db->hasActivatedPlugin(
"plg1"));
744 $this->assertFalse($this->db->hasActivatedPlugin(
"plg666"));
745 $this->assertTrue($this->db->hasActivatedPlugin(
"plg3"));
static array static array plg2
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.
testSetActivationCallsStateDB()
testGetPluginViaComponentAndPluginSlot()
static array $component_data
testGetComponentByTypeAndNameThrowsOnUnknownComponent2()
testSetCurrentPluginVersionCallsStateDBTriggersRebuild()
Repository interface for plugin state data.
Simple value class for information about a plugin.
testRemoveStateInformationOfCallsStateDB()
testGetComponentByIdTypeThrowsOnInvalidId()
Repository for component data implemented over artifacts.
static array static array Richard richard klees concepts and training plg3
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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()