ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilComponentInfoTest.php
Go to the documentation of this file.
1 <?php
2 
20 
22 {
26 
27  protected function setUp(): void
28  {
29  $slots = [];
30 
31  $this->component = new ilComponentInfo(
32  "mod1",
33  "components/ILIAS",
34  "Module1",
35  $slots
36  );
37 
38  $plugins = [];
39  $this->pluginslot1 = new ilPluginSlotInfo(
40  $this->component,
41  "slt1",
42  "Slot1",
43  $plugins
44  );
45 
46  $this->pluginslot2 = new ilPluginSlotInfo(
47  $this->component,
48  "slt2",
49  "Slot2",
50  $plugins
51  );
52 
53  $slots[] = $this->pluginslot1;
54  $slots[] = $this->pluginslot2;
55  }
56 
57  public function testGetter(): void
58  {
59  $this->assertEquals("mod1", $this->component->getId());
60  $this->assertEquals("components/ILIAS", $this->component->getType());
61  $this->assertEquals("Module1", $this->component->getName());
62  $this->assertEquals("components/ILIAS/Module1", $this->component->getQualifiedName());
63  }
64 
65  public function testInvalidTypeThrowsException(): void
66  {
67  $this->expectException(\InvalidArgumentException::class);
68  $slots = [];
69  new ilComponentInfo(
70  "id",
71  "SomeOtherType",
72  "name",
73  $slots
74  );
75  }
76 
77  public function testGetPluginsSlots(): void
78  {
79  $pluginslots = iterator_to_array($this->component->getPluginSlots());
80  $plugins = [];
81  $this->assertCount(2, $pluginslots);
82  $this->assertEquals(new ilPluginSlotInfo($this->component, "slt1", "Slot1", $plugins), $pluginslots["slt1"]);
83  $this->assertEquals(new ilPluginSlotInfo($this->component, "slt2", "Slot2", $plugins), $pluginslots["slt2"]);
84  }
85 
86  public function testHasPluginSlotId(): void
87  {
88  $this->assertTrue($this->component->hasPluginSlotId("slt1"));
89  $this->assertTrue($this->component->hasPluginSlotId("slt2"));
90  $this->assertFalse($this->component->hasPluginSlotId("slt3"));
91  }
92 
93  public function testGetPluginSlotById(): void
94  {
95  $plugins = [];
96  $this->assertEquals(new ilPluginSlotInfo($this->component, "slt1", "Slot1", $plugins), $this->component->getPluginSlotById("slt1"));
97  $this->assertEquals(new ilPluginSlotInfo($this->component, "slt2", "Slot2", $plugins), $this->component->getPluginSlotById("slt2"));
98  }
99 
100  public function testGetUnknownPluginSlotById(): void
101  {
102  $this->expectException(\InvalidArgumentException::class);
103  $this->component->getPluginSlotById("slt3");
104  }
105 
106  public function testGetUnknownPluginSlot(): void
107  {
108  $this->expectException(\InvalidArgumentException::class);
109  $this->component->getPluginSlotById("slt3");
110  }
111 
112  public function testHasPluginSlotName(): void
113  {
114  $this->assertTrue($this->component->hasPluginSlotName("Slot1"));
115  $this->assertTrue($this->component->hasPluginSlotName("Slot2"));
116  $this->assertFalse($this->component->hasPluginSlotName("Slot3"));
117  }
118 
119  public function testGetPluginSlotByName(): void
120  {
121  $plugins = [];
122  $this->assertEquals(new ilPluginSlotInfo($this->component, "slt1", "Slot1", $plugins), $this->component->getPluginSlotByName("Slot1"));
123  $this->assertEquals(new ilPluginSlotInfo($this->component, "slt2", "Slot2", $plugins), $this->component->getPluginSlotByName("Slot2"));
124  }
125 
126  public function testGetUnknownPluginSlotByName(): void
127  {
128  $this->expectException(\InvalidArgumentException::class);
129  $this->component->getPluginSlotById("Slot3");
130  }
131 }
Simple value class for basic information about a pluginslot.
ilPluginSlotInfo $pluginslot1
ilPluginSlotInfo $pluginslot2
ilComponentInfo $component
Simple value class for basic information about a component.