53 protected function setUp(): void
64 return $this->identification->core($this->provider)->identifier($id);
71 $p1 = $this->
getId(
'parent_1');
72 $p2 = $this->
getId(
'parent_2');
73 $p3 = $this->
getId(
'parent_3');
75 $this->
factory->topParentItem($p1),
76 $this->
factory->topParentItem($p2),
77 $this->
factory->topParentItem($p3)
80 $p4 = $this->
getId(
'parent_4');
81 $map->add($this->
factory->topParentItem($p4));
83 $this->assertTrue($map->has());
84 $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
85 $this->assertTrue($map->existsInFilter($p1));
86 $this->assertTrue($map->existsInFilter($p2));
87 $this->assertTrue($map->existsInFilter($p3));
88 $this->assertTrue($map->existsInFilter($p4));
95 $p1 = $this->
getId(
'parent_1');
96 $p2 = $this->
getId(
'parent_2');
97 $p3 = $this->
getId(
'parent_3');
98 $p4 = $this->
getId(
'parent_4');
100 $this->
factory->topParentItem($p1),
101 $this->
factory->topParentItem($p2),
102 $this->
factory->topParentItem($p3),
103 $this->
factory->topParentItem($p4)
106 $this->assertTrue($map->has());
107 $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
109 $map->filter(
static fn():
bool =>
true);
111 $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
115 $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 3);
116 $this->assertFalse($map->existsInFilter($p1));
117 $this->assertTrue($map->existsInFilter($p2));
118 $this->assertTrue($map->existsInFilter($p3));
119 $this->assertTrue($map->existsInFilter($p4));
121 $map->filter(
static fn():
bool =>
false);
122 $this->assertFalse($map->existsInFilter($p1));
123 $this->assertFalse($map->existsInFilter($p2));
124 $this->assertFalse($map->existsInFilter($p3));
125 $this->assertFalse($map->existsInFilter($p4));
132 for ($x = 1; $x <= 10; $x++) {
133 $map->add($this->
factory->topParentItem($this->getId((
string) $x))->withPosition(11 - $x));
137 foreach ($map->getAllFromFilter() as $i) {
138 $this->assertSame($i->getPosition(), $x);
144 $generator = $map->getAllFromFilter();
146 $one =
static function () use ($generator):
isItem {
147 $i = $generator->current();
153 $this->assertSame(
'10', $i->getProviderIdentification()->getInternalIdentifier());
154 $this->assertSame(1, $i->getPosition());
157 $this->assertSame(
'9', $i->getProviderIdentification()->getInternalIdentifier());
158 $this->assertSame(2, $i->getPosition());
161 $this->assertSame(
'8', $i->getProviderIdentification()->getInternalIdentifier());
162 $this->assertSame(3, $i->getPosition());
165 $this->assertSame(
'7', $i->getProviderIdentification()->getInternalIdentifier());
166 $this->assertSame(4, $i->getPosition());
169 $this->assertSame(
'6', $i->getProviderIdentification()->getInternalIdentifier());
170 $this->assertSame(5, $i->getPosition());
173 $this->assertSame(
'5', $i->getProviderIdentification()->getInternalIdentifier());
174 $this->assertSame(6, $i->getPosition());
177 $this->assertSame(
'4', $i->getProviderIdentification()->getInternalIdentifier());
178 $this->assertSame(7, $i->getPosition());
181 $this->assertSame(
'3', $i->getProviderIdentification()->getInternalIdentifier());
182 $this->assertSame(8, $i->getPosition());
185 $this->assertSame(
'2', $i->getProviderIdentification()->getInternalIdentifier());
186 $this->assertSame(9, $i->getPosition());
189 $this->assertSame(
'1', $i->getProviderIdentification()->getInternalIdentifier());
190 $this->assertSame(10, $i->getPosition());
193 public function testSortingNestedItems():
void 197 $tp_1 = $this->
factory->topParentItem($this->
getId(
'tp_1'))
200 ->withParent($tp_1->getProviderIdentification())
203 ->withParent($tp_1->getProviderIdentification())
205 $tp_1 = $tp_1->withChildren([
213 $tp_2 = $this->
factory->topParentItem($this->
getId(
'tp_2'))
216 ->withParent($tp_2->getProviderIdentification())
219 ->withParent($tp_2->getProviderIdentification())
221 $tp_2 = $tp_2->withChildren([
231 $this->assertEquals(1, $map->getSingleItemFromRaw($this->getId(
'tp_1'))->getPosition());
232 $this->assertEquals(1, $map->getSingleItemFromRaw($this->getId(
'tp_1_1'))->getPosition());
233 $this->assertEquals(2, $map->getSingleItemFromRaw($this->getId(
'tp_1_2'))->getPosition());
234 $this->assertEquals(2, $map->getSingleItemFromRaw($this->getId(
'tp_2'))->getPosition());
235 $this->assertEquals(1, $map->getSingleItemFromRaw($this->getId(
'tp_2_1'))->getPosition());
236 $this->assertEquals(2, $map->getSingleItemFromRaw($this->getId(
'tp_2_2'))->getPosition());
239 $get_tp_1 = $map->getSingleItemFromFilter($this->
getId(
'tp_1'));
240 $children_of_tp_1 = $get_tp_1->getChildren();
241 $first = reset($children_of_tp_1);
242 $this->assertEquals($tp_1_1, $first);
243 $this->assertEquals(1, $first->getPosition());
245 $get_tp_2 = $map->getSingleItemFromFilter($this->
getId(
'tp_2'));
246 $children_of_tp_2 = $get_tp_2->getChildren();
247 $first = reset($children_of_tp_2);
248 $this->assertEquals($tp_2_1, $first);
249 $this->assertEquals(1, $first->getPosition());
252 public function testSamePositionResolution():
void 256 $tp_1 = $this->
factory->topParentItem($this->
getId(
'tp_1'))
259 ->withParent($tp_1->getProviderIdentification())
262 ->withParent($tp_1->getProviderIdentification())
264 $tp_1 = $tp_1->withChildren([
272 $item = $map->getSingleItemFromFilter($this->
getId(
'tp_1'));
273 $this->assertCount(2, $item->getChildren());
279 public function getAllIdentifications(): array
284 public function getFullyQualifiedClassName():
string 294 public function getStaticTopItems(): array
299 public function getStaticSubItems(): array
IdentificationFactory $identification
StaticMainMenuProvider $provider
Interface IdentificationInterface.
Class MainMenuItemFactory This factory provides you all available types for MainMenu GlobalScreen Ite...
Class TypeInformationCollection.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getProviderNameForPresentation()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Class NullProviderFactory.
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
Interface StaticMainMenuProvider.
getProviderIdentification()
MainMenuItemFactory $factory