ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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

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

Member Function Documentation

◆ getDummyProvider()

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

Definition at line 278 of file MapTest.php.

References ILIAS\GlobalScreen\Provider\getProviderNameForPresentation().

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

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

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

52  : IdentificationInterface
53  {
54  return $this->identification->core($this->provider)->identifier($id);
55  }
+ Here is the caller graph for this function:

◆ setUp()

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

Definition at line 43 of file MapTest.php.

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

43  : void
44  {
45  parent::setUp();
46 
47  $this->provider = $this->getDummyProvider();
48  $this->identification = new IdentificationFactory(new NullProviderFactory());
49  $this->factory = new MainMenuItemFactory();
50  }
+ Here is the call graph for this function:

◆ testAddItem()

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

Definition at line 57 of file MapTest.php.

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

57  : void
58  {
59  $map = new Map($this->factory);
60 
61  $p1 = $this->getId('parent_1');
62  $p2 = $this->getId('parent_2');
63  $p3 = $this->getId('parent_3');
64  $map->addMultiple(
65  ...[
66  $this->factory->topParentItem($p1),
67  $this->factory->topParentItem($p2),
68  $this->factory->topParentItem($p3),
69  ]
70  );
71 
72  $p4 = $this->getId('parent_4');
73  $map->add($this->factory->topParentItem($p4));
74 
75  $this->assertTrue($map->has());
76  $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
77  $this->assertTrue($map->existsInFilter($p1));
78  $this->assertTrue($map->existsInFilter($p2));
79  $this->assertTrue($map->existsInFilter($p3));
80  $this->assertTrue($map->existsInFilter($p4));
81  }
+ Here is the call graph for this function:

◆ testFilterItems()

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

Definition at line 83 of file MapTest.php.

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

83  : void
84  {
85  $map = new Map($this->factory);
86 
87  $p1 = $this->getId('parent_1');
88  $p2 = $this->getId('parent_2');
89  $p3 = $this->getId('parent_3');
90  $p4 = $this->getId('parent_4');
91  $map->addMultiple(
92  ...[
93  $this->factory->topParentItem($p1),
94  $this->factory->topParentItem($p2),
95  $this->factory->topParentItem($p3),
96  $this->factory->topParentItem($p4)
97  ]
98  );
99 
100  $this->assertTrue($map->has());
101  $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
102 
103  $map->filter(static function () {
104  return true;
105  });
106 
107  $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 4);
108 
109  $map->filter(static function (isItem $i) {
110  return $i->getProviderIdentification()->getInternalIdentifier() !== 'parent_1';
111  });
112 
113  $this->assertSame(count(iterator_to_array($map->getAllFromFilter())), 3);
114  $this->assertFalse($map->existsInFilter($p1));
115  $this->assertTrue($map->existsInFilter($p2));
116  $this->assertTrue($map->existsInFilter($p3));
117  $this->assertTrue($map->existsInFilter($p4));
118 
119  $map->filter(static function () {
120  return false;
121  });
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 
127  }
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ testSortingTopItems()

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

Definition at line 129 of file MapTest.php.

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

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

◆ $identification

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

Definition at line 30 of file MapTest.php.

◆ $provider

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

Definition at line 38 of file MapTest.php.


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