ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
CollectorTest.php
Go to the documentation of this file.
1 <?php
2 
4 
19 
20 require_once('./libs/composer/vendor/autoload.php');
21 
26 class CollectorTest extends TestCase
27 {
29 
30  protected function setUp(): void
31  {
32  parent::setUp();
33  }
34 
35  public function testBasic(): void
36  {
37  $this->assertTrue(true);
38  return; // WIP
39  $collector = new MainMenuMainCollector([$this->getDummyProvider()], $this->getItemInformation());
40  $collector->collectOnce();
41 
42  $this->assertTrue($collector->hasItems());
43  }
44 
45  private function getItemInformation(): ItemInformation
46  {
47  return new class () implements ItemInformation {
48  public function isItemActive(isItem $item): bool
49  {
50  return true;
51  }
52 
53  public function customPosition(isItem $item): isItem
54  {
55  return $item;
56  }
57 
58  public function customTranslationForUser(hasTitle $item): hasTitle
59  {
60  return $item;
61  }
62 
63  public function getParent(isItem $item): IdentificationInterface
64  {
65  return $item->getParent();
66  }
67 
68  public function customSymbol(hasSymbol $item): hasSymbol
69  {
70  return $item;
71  }
72  };
73  }
74 
75  private function getDummyProvider(): StaticMainMenuProvider
76  {
77  return new class () implements StaticMainMenuProvider {
81  private $p_identifications;
85  protected $c_identifications;
86 
87  public function __construct()
88  {
90  $iff = function (string $id) use ($if) {
91  return $if->core($this)->identifier($id);
92  };
93  $this->factory = new MainMenuItemFactory();
94  $this->p_identifications = [];
95  $this->c_identifications = [];
96  $this->type_information = new TypeInformationCollection();
97  $this->type_information->add();
98 
99  for ($x = 1; $x < 5; $x++) {
100  $this->p_identifications['id_' . $x] = $iff('id_' . $x);
101  for ($y = 1; $y < 5; $y++) {
102  $this->c_identifications[] = $iff('id_' . $x . '/' . $y);
103  }
104  }
105  }
106 
107  public function getAllIdentifications(): array
108  {
109  return [];
110  }
111 
112  public function getFullyQualifiedClassName(): string
113  {
114  return 'Provider';
115  }
116 
117  public function getProviderNameForPresentation(): string
118  {
119  return 'Provider';
120  }
121 
122  public function getStaticTopItems(): array
123  {
124  $items = [];
125  foreach ($this->p_identifications as $if) {
126  $items[] = $this->factory->topParentItem($if)->withTitle($if->getInternalIdentifier());
127  }
128  return $items;
129  }
130 
131  public function getStaticSubItems(): array
132  {
133  $items = [];
134  foreach ($this->c_identifications as $if) {
135  $identifier = $if->getInternalIdentifier();
136  $items[] = $this->factory->link($if)->withTitle($identifier)->withParent($this->p_identifications[strstr($identifier, '/', true)]);
137  }
138  return $items;
139  }
140 
141  public function provideTypeInformation(): TypeInformationCollection
142  {
143  return $this->type_information;
144  }
145  };
146  }
147 }
Class MainMenuMainCollector This Collector will collect and then provide all available slates from th...
Class MainMenuItemFactory This factory provides you all available types for MainMenu GlobalScreen Ite...
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:62
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface hasSymbol Methods for Entries with Symbols.
Definition: hasSymbol.php:32
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...