ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 

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 282 of file MapTest.php.

References ILIAS\GlobalScreen\Provider\getProviderNameForPresentation().

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

282  : StaticMainMenuProvider
283  {
284  return new class () implements StaticMainMenuProvider {
285  public function getAllIdentifications(): array
286  {
287  return [];
288  }
289 
290  public function getFullyQualifiedClassName(): string
291  {
292  return 'Provider';
293  }
294 
295  public function getProviderNameForPresentation(): string
296  {
297  return 'Provider';
298  }
299 
300  public function getStaticTopItems(): array
301  {
302  return [];
303  }
304 
305  public function getStaticSubItems(): array
306  {
307  return [];
308  }
309 
310  public function provideTypeInformation(): TypeInformationCollection
311  {
312  return new TypeInformationCollection();
313  }
314  };
315  }
+ 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.

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

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

◆ getMap()

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

Definition at line 45 of file MapTest.php.

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

45  : Map
46  {
47  return new Map($this->factory);
48  }
+ Here is the caller graph for this function:

◆ setUp()

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

Definition at line 53 of file MapTest.php.

References ILIAS\GlobalScreen\MainMenu\MapTest\getDummyProvider().

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  }
+ Here is the call graph for this function:

◆ testAddItem()

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

Definition at line 67 of file MapTest.php.

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

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->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));
89  }
+ Here is the call graph for this function:

◆ testFilterItems()

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

Definition at line 91 of file MapTest.php.

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

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->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
108 
109  $map->filter(static function (): bool {
110  return true;
111  });
112 
113  $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
114 
115  $map->filter(static function (isItem $i): bool {
116  return $i->getProviderIdentification()->getInternalIdentifier() !== 'parent_1';
117  });
118 
119  $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 3);
120  $this->assertFalse($map->existsInFilter($p1));
121  $this->assertTrue($map->existsInFilter($p2));
122  $this->assertTrue($map->existsInFilter($p3));
123  $this->assertTrue($map->existsInFilter($p4));
124 
125  $map->filter(static function (): bool {
126  return false;
127  });
128  $this->assertFalse($map->existsInFilter($p1));
129  $this->assertFalse($map->existsInFilter($p2));
130  $this->assertFalse($map->existsInFilter($p3));
131  $this->assertFalse($map->existsInFilter($p4));
132  }
$i
Definition: metadata.php:41
+ Here is the call graph for this function:

◆ testSortingTopItems()

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

Definition at line 134 of file MapTest.php.

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

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