ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\GlobalScreen\MainMenu\MapTest Class Reference

Class FactoryImplTest. More...

+ Inheritance diagram for ILIAS\GlobalScreen\MainMenu\MapTest:
+ Collaboration diagram for ILIAS\GlobalScreen\MainMenu\MapTest:

Public Member Functions

 testAddItem ()
 
 testFilterItems ()
 
 testSortingTopItems ()
 

Protected Member Functions

 setUp ()
 @inheritDoc More...
 

Protected Attributes

IdentificationFactory $identification
 
MainMenuItemFactory $factory
 
StaticMainMenuProvider $provider
 

Private Member Functions

 getMap ()
 
 getId (string $id)
 
 getDummyProvider ()
 

Detailed Description

Class FactoryImplTest.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 39 of file MapTest.php.

Member Function Documentation

◆ getDummyProvider()

ILIAS\GlobalScreen\MainMenu\MapTest::getDummyProvider ( )
private

Definition at line 279 of file MapTest.php.

279 : StaticMainMenuProvider
280 {
281 return new class () implements StaticMainMenuProvider {
282 public function getAllIdentifications(): array
283 {
284 return [];
285 }
286
287 public function getFullyQualifiedClassName(): string
288 {
289 return 'Provider';
290 }
291
292 public function getProviderNameForPresentation(): string
293 {
294 return 'Provider';
295 }
296
297 public function getStaticTopItems(): array
298 {
299 return [];
300 }
301
302 public function getStaticSubItems(): array
303 {
304 return [];
305 }
306
307 public function provideTypeInformation(): TypeInformationCollection
308 {
309 return new TypeInformationCollection();
310 }
311 };
312 }

References ILIAS\GlobalScreen\Provider\getProviderNameForPresentation().

Referenced by ILIAS\GlobalScreen\MainMenu\MapTest\setUp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ILIAS\GlobalScreen\MainMenu\MapTest::getId ( string  $id)
private

Definition at line 62 of file MapTest.php.

62 : IdentificationInterface
63 {
64 return $this->identification->core($this->provider)->identifier($id);
65 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id.

Referenced by ILIAS\GlobalScreen\MainMenu\MapTest\testAddItem(), and ILIAS\GlobalScreen\MainMenu\MapTest\testFilterItems().

+ Here is the caller graph for this function:

◆ getMap()

ILIAS\GlobalScreen\MainMenu\MapTest::getMap ( )
private

Definition at line 45 of file MapTest.php.

45 : Map
46 {
47 return new Map($this->factory);
48 }
factory()

References factory().

Referenced by ILIAS\GlobalScreen\MainMenu\MapTest\testAddItem(), ILIAS\GlobalScreen\MainMenu\MapTest\testFilterItems(), and ILIAS\GlobalScreen\MainMenu\MapTest\testSortingTopItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUp()

ILIAS\GlobalScreen\MainMenu\MapTest::setUp ( )
protected

@inheritDoc

Definition at line 53 of file MapTest.php.

53 : void
54 {
55 parent::setUp();
56
57 $this->provider = $this->getDummyProvider();
58 $this->identification = new IdentificationFactory(new NullProviderFactory());
59 $this->factory = new MainMenuItemFactory();
60 }

References factory(), and ILIAS\GlobalScreen\MainMenu\MapTest\getDummyProvider().

+ Here is the call graph for this function:

◆ testAddItem()

ILIAS\GlobalScreen\MainMenu\MapTest::testAddItem ( )

Definition at line 67 of file MapTest.php.

67 : void
68 {
69 $map = $this->getMap();
70
71 $p1 = $this->getId('parent_1');
72 $p2 = $this->getId('parent_2');
73 $p3 = $this->getId('parent_3');
74 $map->addMultiple(
75 $this->factory->topParentItem($p1),
76 $this->factory->topParentItem($p2),
77 $this->factory->topParentItem($p3)
78 );
79
80 $p4 = $this->getId('parent_4');
81 $map->add($this->factory->topParentItem($p4));
82
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));
89 }

References factory(), ILIAS\GlobalScreen\MainMenu\MapTest\getId(), and ILIAS\GlobalScreen\MainMenu\MapTest\getMap().

+ Here is the call graph for this function:

◆ testFilterItems()

ILIAS\GlobalScreen\MainMenu\MapTest::testFilterItems ( )

Definition at line 91 of file MapTest.php.

91 : void
92 {
93 $map = $this->getMap();
94
95 $p1 = $this->getId('parent_1');
96 $p2 = $this->getId('parent_2');
97 $p3 = $this->getId('parent_3');
98 $p4 = $this->getId('parent_4');
99 $map->addMultiple(
100 $this->factory->topParentItem($p1),
101 $this->factory->topParentItem($p2),
102 $this->factory->topParentItem($p3),
103 $this->factory->topParentItem($p4)
104 );
105
106 $this->assertTrue($map->has());
107 $this->assertCount(4, iterator_to_array($map->getAllFromFilter()));
108
109 $map->filter(static fn(): bool => true);
110
111 $this->assertCount(4, iterator_to_array($map->getAllFromFilter()));
112
113 $map->filter(static fn(isItem $i): bool => $i->getProviderIdentification()->getInternalIdentifier() !== 'parent_1');
114
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));
120
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));
126 }

References factory(), ILIAS\GlobalScreen\MainMenu\MapTest\getId(), ILIAS\GlobalScreen\MainMenu\MapTest\getMap(), and ILIAS\GlobalScreen\isGlobalScreenItem\getProviderIdentification().

+ Here is the call graph for this function:

◆ testSortingTopItems()

ILIAS\GlobalScreen\MainMenu\MapTest::testSortingTopItems ( )

Definition at line 128 of file MapTest.php.

128 : void
129 {
130 $map = $this->getMap();
131
132 for ($x = 1; $x <= 10; $x++) {
133 $map->add($this->factory->topParentItem($this->getId((string) $x))->withPosition(11 - $x));
134 }
135
136 $x = 10;
137 foreach ($map->getAllFromFilter() as $i) {
138 $this->assertSame($i->getPosition(), $x);
139 $x--;
140 }
141
142 $map->sort();
143
144 $generator = $map->getAllFromFilter();
145
146 $one = static function () use ($generator): isItem {
147 $i = $generator->current();
148 $generator->next();
149 return $i;
150 };
151
152 $i = $one();
153 $this->assertSame('10', $i->getProviderIdentification()->getInternalIdentifier());
154 $this->assertSame(1, $i->getPosition());
155
156 $i = $one();
157 $this->assertSame('9', $i->getProviderIdentification()->getInternalIdentifier());
158 $this->assertSame(2, $i->getPosition());
159
160 $i = $one();
161 $this->assertSame('8', $i->getProviderIdentification()->getInternalIdentifier());
162 $this->assertSame(3, $i->getPosition());
163
164 $i = $one();
165 $this->assertSame('7', $i->getProviderIdentification()->getInternalIdentifier());
166 $this->assertSame(4, $i->getPosition());
167
168 $i = $one();
169 $this->assertSame('6', $i->getProviderIdentification()->getInternalIdentifier());
170 $this->assertSame(5, $i->getPosition());
171
172 $i = $one();
173 $this->assertSame('5', $i->getProviderIdentification()->getInternalIdentifier());
174 $this->assertSame(6, $i->getPosition());
175
176 $i = $one();
177 $this->assertSame('4', $i->getProviderIdentification()->getInternalIdentifier());
178 $this->assertSame(7, $i->getPosition());
179
180 $i = $one();
181 $this->assertSame('3', $i->getProviderIdentification()->getInternalIdentifier());
182 $this->assertSame(8, $i->getPosition());
183
184 $i = $one();
185 $this->assertSame('2', $i->getProviderIdentification()->getInternalIdentifier());
186 $this->assertSame(9, $i->getPosition());
187
188 $i = $one();
189 $this->assertSame('1', $i->getProviderIdentification()->getInternalIdentifier());
190 $this->assertSame(10, $i->getPosition());
191 }

References factory(), and ILIAS\GlobalScreen\MainMenu\MapTest\getMap().

+ Here is the call graph for this function:

Field Documentation

◆ $factory

MainMenuItemFactory ILIAS\GlobalScreen\MainMenu\MapTest::$factory
protected

Definition at line 42 of file MapTest.php.

◆ $identification

IdentificationFactory ILIAS\GlobalScreen\MainMenu\MapTest::$identification
protected

Definition at line 41 of file MapTest.php.

◆ $provider

StaticMainMenuProvider ILIAS\GlobalScreen\MainMenu\MapTest::$provider
protected

Definition at line 43 of file MapTest.php.


The documentation for this class was generated from the following file: