ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
CollectorTestTBD.php
Go to the documentation of this file.
1 <?php
2 
20 
34 
35 require_once('./vendor/composer/vendor/autoload.php');
36 
41 class CollectorTest extends TestCase
42 {
44 
45  protected function setUp(): void
46  {
47  parent::setUp();
48  }
49 
50  public function testBasic(): void
51  {
52  $this->assertTrue(true);
53  return; // WIP
54  $collector = new MainMenuMainCollector([$this->getDummyProvider()], $this->getItemInformation());
55  $collector->collectOnce();
56 
57  $this->assertTrue($collector->hasItems());
58  }
59 
60  private function getItemInformation(): ItemInformation
61  {
62  return new class () implements ItemInformation {
63  public function isItemActive(isItem $item): bool
64  {
65  return true;
66  }
67 
68  public function customPosition(isItem $item): isItem
69  {
70  return $item;
71  }
72 
73  public function customTranslationForUser(hasTitle $item): hasTitle
74  {
75  return $item;
76  }
77 
78  public function getParent(isItem $item): IdentificationInterface
79  {
80  return $item->getParent();
81  }
82 
83  public function customSymbol(hasSymbol $item): hasSymbol
84  {
85  return $item;
86  }
87  };
88  }
89 
90  private function getDummyProvider(): StaticMainMenuProvider
91  {
92  return new class () implements StaticMainMenuProvider {
96  private array $p_identifications = [];
100  protected $c_identifications = [];
101 
102  public function __construct()
103  {
105  $iff = (fn(string $id): IdentificationInterface => $if->core($this)->identifier($id));
106  $this->factory = new MainMenuItemFactory();
107  $this->type_information = new TypeInformationCollection();
108  $this->type_information->add();
109 
110  for ($x = 1; $x < 5; $x++) {
111  $this->p_identifications['id_' . $x] = $iff('id_' . $x);
112  for ($y = 1; $y < 5; $y++) {
113  $this->c_identifications[] = $iff('id_' . $x . '/' . $y);
114  }
115  }
116  }
117 
118  public function getAllIdentifications(): array
119  {
120  return [];
121  }
122 
123  public function getFullyQualifiedClassName(): string
124  {
125  return 'Provider';
126  }
127 
128  public function getProviderNameForPresentation(): string
129  {
130  return 'Provider';
131  }
132 
133  public function getStaticTopItems(): array
134  {
135  $items = [];
136  foreach ($this->p_identifications as $if) {
137  $items[] = $this->factory->topParentItem($if)->withTitle($if->getInternalIdentifier());
138  }
139  return $items;
140  }
141 
142  public function getStaticSubItems(): array
143  {
144  $items = [];
145  foreach ($this->c_identifications as $if) {
146  $identifier = $if->getInternalIdentifier();
147  $items[] = $this->factory->link($if)->withTitle($identifier)->withParent($this->p_identifications[strstr($identifier, '/', true)]);
148  }
149  return $items;
150  }
151 
152  public function provideTypeInformation(): TypeInformationCollection
153  {
154  return $this->type_information;
155  }
156  };
157  }
158 }
Class MainMenuMainCollector This Collector will collect and then provide all available slates from th...
factory()
Class MainMenuItemFactory This factory provides you all available types for MainMenu GlobalScreen Ite...
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...