56 return new Map($this->factory);
62 protected function setUp() : void
73 return $this->identification->core($this->provider)->identifier($id);
80 $p1 = $this->
getId(
'parent_1');
81 $p2 = $this->
getId(
'parent_2');
82 $p3 = $this->
getId(
'parent_3');
84 $this->factory->topParentItem($p1),
85 $this->factory->topParentItem($p2),
86 $this->factory->topParentItem($p3)
89 $p4 = $this->
getId(
'parent_4');
90 $map->add($this->factory->topParentItem($p4));
92 $this->assertTrue($map->has());
93 $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
94 $this->assertTrue($map->existsInFilter($p1));
95 $this->assertTrue($map->existsInFilter($p2));
96 $this->assertTrue($map->existsInFilter($p3));
97 $this->assertTrue($map->existsInFilter($p4));
104 $p1 = $this->
getId(
'parent_1');
105 $p2 = $this->
getId(
'parent_2');
106 $p3 = $this->
getId(
'parent_3');
107 $p4 = $this->
getId(
'parent_4');
109 $this->factory->topParentItem($p1),
110 $this->factory->topParentItem($p2),
111 $this->factory->topParentItem($p3),
112 $this->factory->topParentItem($p4)
115 $this->assertTrue($map->has());
116 $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
118 $map->filter(
static function () :
bool {
122 $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
124 $map->filter(
static function (
isItem $i) :
bool {
128 $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 3);
129 $this->assertFalse($map->existsInFilter($p1));
130 $this->assertTrue($map->existsInFilter($p2));
131 $this->assertTrue($map->existsInFilter($p3));
132 $this->assertTrue($map->existsInFilter($p4));
134 $map->filter(
static function () :
bool {
137 $this->assertFalse($map->existsInFilter($p1));
138 $this->assertFalse($map->existsInFilter($p2));
139 $this->assertFalse($map->existsInFilter($p3));
140 $this->assertFalse($map->existsInFilter($p4));
147 for ($x = 1; $x <= 10; $x++) {
148 $map->add($this->factory->topParentItem($this->getId((
string) $x))->withPosition(11 - $x));
152 foreach ($map->getAllFromFilter() as
$i) {
153 $this->assertSame(
$i->getPosition(), $x);
159 $generator = $map->getAllFromFilter();
161 $one =
static function () use ($generator) :
isItem {
162 $i = $generator->current();
168 $this->assertSame(
'10',
$i->getProviderIdentification()->getInternalIdentifier());
169 $this->assertSame(1,
$i->getPosition());
172 $this->assertSame(
'9', $i->getProviderIdentification()->getInternalIdentifier());
173 $this->assertSame(2, $i->getPosition());
176 $this->assertSame(
'8', $i->getProviderIdentification()->getInternalIdentifier());
177 $this->assertSame(3, $i->getPosition());
180 $this->assertSame(
'7', $i->getProviderIdentification()->getInternalIdentifier());
181 $this->assertSame(4, $i->getPosition());
184 $this->assertSame(
'6', $i->getProviderIdentification()->getInternalIdentifier());
185 $this->assertSame(5, $i->getPosition());
188 $this->assertSame(
'5', $i->getProviderIdentification()->getInternalIdentifier());
189 $this->assertSame(6, $i->getPosition());
192 $this->assertSame(
'4', $i->getProviderIdentification()->getInternalIdentifier());
193 $this->assertSame(7, $i->getPosition());
196 $this->assertSame(
'3', $i->getProviderIdentification()->getInternalIdentifier());
197 $this->assertSame(8, $i->getPosition());
200 $this->assertSame(
'2', $i->getProviderIdentification()->getInternalIdentifier());
201 $this->assertSame(9, $i->getPosition());
204 $this->assertSame(
'1', $i->getProviderIdentification()->getInternalIdentifier());
205 $this->assertSame(10, $i->getPosition());
208 public function testSortingNestedItems() :
void 212 $tp_1 = $this->factory->topParentItem($this->
getId(
'tp_1'))
214 $tp_1_1 = $this->factory->link($this->
getId(
'tp_1_1'))
215 ->withParent($tp_1->getProviderIdentification())
217 $tp_1_2 = $this->factory->link($this->
getId(
'tp_1_2'))
218 ->withParent($tp_1->getProviderIdentification())
220 $tp_1 = $tp_1->withChildren([
228 $tp_2 = $this->factory->topParentItem($this->
getId(
'tp_2'))
230 $tp_2_1 = $this->factory->link($this->
getId(
'tp_2_1'))
231 ->withParent($tp_2->getProviderIdentification())
233 $tp_2_2 = $this->factory->link($this->
getId(
'tp_2_2'))
234 ->withParent($tp_2->getProviderIdentification())
236 $tp_2 = $tp_2->withChildren([
246 $this->assertEquals(1, $map->getSingleItemFromRaw($this->getId(
'tp_1'))->getPosition());
247 $this->assertEquals(1, $map->getSingleItemFromRaw($this->getId(
'tp_1_1'))->getPosition());
248 $this->assertEquals(2, $map->getSingleItemFromRaw($this->getId(
'tp_1_2'))->getPosition());
249 $this->assertEquals(2, $map->getSingleItemFromRaw($this->getId(
'tp_2'))->getPosition());
250 $this->assertEquals(1, $map->getSingleItemFromRaw($this->getId(
'tp_2_1'))->getPosition());
251 $this->assertEquals(2, $map->getSingleItemFromRaw($this->getId(
'tp_2_2'))->getPosition());
254 $get_tp_1 = $map->getSingleItemFromFilter($this->
getId(
'tp_1'));
255 $children_of_tp_1 = $get_tp_1->getChildren();
256 $first = reset($children_of_tp_1);
257 $this->assertEquals($tp_1_1, $first);
258 $this->assertEquals(1, $first->getPosition());
260 $get_tp_2 = $map->getSingleItemFromFilter($this->
getId(
'tp_2'));
261 $children_of_tp_2 = $get_tp_2->getChildren();
262 $first = reset($children_of_tp_2);
263 $this->assertEquals($tp_2_1, $first);
264 $this->assertEquals(1, $first->getPosition());
267 public function testSamePositionResolution() :
void 271 $tp_1 = $this->factory->topParentItem($this->
getId(
'tp_1'))
273 $tp_1_1 = $this->factory->link($this->
getId(
'tp_1_1'))
274 ->withParent($tp_1->getProviderIdentification())
276 $tp_1_2 = $this->factory->link($this->
getId(
'tp_1_2'))
277 ->withParent($tp_1->getProviderIdentification())
279 $tp_1 = $tp_1->withChildren([
287 $item = $map->getSingleItemFromFilter($this->
getId(
'tp_1'));
288 $this->assertCount(2, $item->getChildren());
294 public function getAllIdentifications() : array
299 public function getFullyQualifiedClassName() :
string 309 public function getStaticTopItems() : array
314 public function getStaticSubItems() : array
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()
Class NullProviderFactory.
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
Interface StaticMainMenuProvider.
getProviderIdentification()