29use PHPUnit\Framework\TestCase;
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->assertCount(4, iterator_to_array($map->getAllFromFilter()));
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->assertCount(4, iterator_to_array($map->getAllFromFilter()));
109 $map->filter(
static fn():
bool =>
true);
111 $this->assertCount(4, iterator_to_array($map->getAllFromFilter()));
115 $this->assertCount(3, iterator_to_array($map->getAllFromFilter()));
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 $this->assertInstanceOf(\
ILIAS\
GlobalScreen\isGlobalScreenItem::class, $get_tp_1);
241 $children_of_tp_1 = $get_tp_1->getChildren();
242 $first = reset($children_of_tp_1);
243 $this->assertEquals($tp_1_1, $first);
244 $this->assertEquals(1, $first->getPosition());
246 $get_tp_2 = $map->getSingleItemFromFilter($this->
getId(
'tp_2'));
247 $this->assertInstanceOf(\
ILIAS\
GlobalScreen\isGlobalScreenItem::class, $get_tp_2);
248 $children_of_tp_2 = $get_tp_2->getChildren();
249 $first = reset($children_of_tp_2);
250 $this->assertEquals($tp_2_1, $first);
251 $this->assertEquals(1, $first->getPosition());
254 public function testSamePositionResolution(): void
258 $tp_1 = $this->
factory->topParentItem($this->
getId(
'tp_1'))
261 ->withParent($tp_1->getProviderIdentification())
264 ->withParent($tp_1->getProviderIdentification())
266 $tp_1 = $tp_1->withChildren([
274 $item = $map->getSingleItemFromFilter($this->
getId(
'tp_1'));
276 $this->assertCount(2, $item->getChildren());
282 public function getAllIdentifications(): array
287 public function getFullyQualifiedClassName():
string
297 public function getStaticTopItems(): array
302 public function getStaticSubItems(): array
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
StaticMainMenuProvider $provider
IdentificationFactory $identification
MainMenuItemFactory $factory
Class NullProviderFactory.
Class TypeInformationCollection.
Class MainMenuItemFactory This factory provides you all available types for MainMenu GlobalScreen Ite...
Interface IdentificationInterface.
Interface StaticMainMenuProvider.
getProviderIdentification()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getProviderNameForPresentation()
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.