ILIAS  release_7 Revision v7.30-3-g800a261c036
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

 $identification
 
 $factory
 
 $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 291 of file MapTest.php.

References ILIAS\GlobalScreen\Provider\getProviderNameForPresentation().

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

291  : StaticMainMenuProvider
292  {
293  return new class() implements StaticMainMenuProvider {
294  public function getAllIdentifications() : array
295  {
296  return [];
297  }
298 
299  public function getFullyQualifiedClassName() : string
300  {
301  return 'Provider';
302  }
303 
304  public function getProviderNameForPresentation() : string
305  {
306  return 'Provider';
307  }
308 
309  public function getStaticTopItems() : array
310  {
311  return [];
312  }
313 
314  public function getStaticSubItems() : array
315  {
316  return [];
317  }
318 
319  public function provideTypeInformation() : TypeInformationCollection
320  {
321  return new TypeInformationCollection();
322  }
323  };
324  }
+ 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 71 of file MapTest.php.

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

71  : IdentificationInterface
72  {
73  return $this->identification->core($this->provider)->identifier($id);
74  }
+ Here is the caller graph for this function:

◆ getMap()

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

Definition at line 54 of file MapTest.php.

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

54  : Map
55  {
56  return new Map($this->factory);
57  }
+ Here is the caller graph for this function:

◆ setUp()

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

Definition at line 62 of file MapTest.php.

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

62  : void
63  {
64  parent::setUp();
65 
66  $this->provider = $this->getDummyProvider();
67  $this->identification = new IdentificationFactory(new NullProviderFactory());
68  $this->factory = new MainMenuItemFactory();
69  }
+ Here is the call graph for this function:

◆ testAddItem()

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

Definition at line 76 of file MapTest.php.

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

76  : void
77  {
78  $map = $this->getMap();
79 
80  $p1 = $this->getId('parent_1');
81  $p2 = $this->getId('parent_2');
82  $p3 = $this->getId('parent_3');
83  $map->addMultiple(
84  $this->factory->topParentItem($p1),
85  $this->factory->topParentItem($p2),
86  $this->factory->topParentItem($p3)
87  );
88 
89  $p4 = $this->getId('parent_4');
90  $map->add($this->factory->topParentItem($p4));
91 
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));
98  }
+ Here is the call graph for this function:

◆ testFilterItems()

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

Definition at line 100 of file MapTest.php.

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

100  : void
101  {
102  $map = $this->getMap();
103 
104  $p1 = $this->getId('parent_1');
105  $p2 = $this->getId('parent_2');
106  $p3 = $this->getId('parent_3');
107  $p4 = $this->getId('parent_4');
108  $map->addMultiple(
109  $this->factory->topParentItem($p1),
110  $this->factory->topParentItem($p2),
111  $this->factory->topParentItem($p3),
112  $this->factory->topParentItem($p4)
113  );
114 
115  $this->assertTrue($map->has());
116  $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
117 
118  $map->filter(static function () : bool {
119  return true;
120  });
121 
122  $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
123 
124  $map->filter(static function (isItem $i) : bool {
125  return $i->getProviderIdentification()->getInternalIdentifier() !== 'parent_1';
126  });
127 
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));
133 
134  $map->filter(static function () : bool {
135  return false;
136  });
137  $this->assertFalse($map->existsInFilter($p1));
138  $this->assertFalse($map->existsInFilter($p2));
139  $this->assertFalse($map->existsInFilter($p3));
140  $this->assertFalse($map->existsInFilter($p4));
141  }
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ testSortingTopItems()

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

Definition at line 143 of file MapTest.php.

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

143  : void
144  {
145  $map = $this->getMap();
146 
147  for ($x = 1; $x <= 10; $x++) {
148  $map->add($this->factory->topParentItem($this->getId((string) $x))->withPosition(11 - $x));
149  }
150 
151  $x = 10;
152  foreach ($map->getAllFromFilter() as $i) {
153  $this->assertSame($i->getPosition(), $x);
154  $x--;
155  }
156 
157  $map->sort();
158 
159  $generator = $map->getAllFromFilter();
160 
161  $one = static function () use ($generator) : isItem {
162  $i = $generator->current();
163  $generator->next();
164  return $i;
165  };
166 
167  $i = $one();
168  $this->assertSame('10', $i->getProviderIdentification()->getInternalIdentifier());
169  $this->assertSame(1, $i->getPosition());
170 
171  $i = $one();
172  $this->assertSame('9', $i->getProviderIdentification()->getInternalIdentifier());
173  $this->assertSame(2, $i->getPosition());
174 
175  $i = $one();
176  $this->assertSame('8', $i->getProviderIdentification()->getInternalIdentifier());
177  $this->assertSame(3, $i->getPosition());
178 
179  $i = $one();
180  $this->assertSame('7', $i->getProviderIdentification()->getInternalIdentifier());
181  $this->assertSame(4, $i->getPosition());
182 
183  $i = $one();
184  $this->assertSame('6', $i->getProviderIdentification()->getInternalIdentifier());
185  $this->assertSame(5, $i->getPosition());
186 
187  $i = $one();
188  $this->assertSame('5', $i->getProviderIdentification()->getInternalIdentifier());
189  $this->assertSame(6, $i->getPosition());
190 
191  $i = $one();
192  $this->assertSame('4', $i->getProviderIdentification()->getInternalIdentifier());
193  $this->assertSame(7, $i->getPosition());
194 
195  $i = $one();
196  $this->assertSame('3', $i->getProviderIdentification()->getInternalIdentifier());
197  $this->assertSame(8, $i->getPosition());
198 
199  $i = $one();
200  $this->assertSame('2', $i->getProviderIdentification()->getInternalIdentifier());
201  $this->assertSame(9, $i->getPosition());
202 
203  $i = $one();
204  $this->assertSame('1', $i->getProviderIdentification()->getInternalIdentifier());
205  $this->assertSame(10, $i->getPosition());
206  }
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

Field Documentation

◆ $factory

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

Definition at line 48 of file MapTest.php.

◆ $identification

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

Definition at line 44 of file MapTest.php.

◆ $provider

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

Definition at line 52 of file MapTest.php.


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