ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
CollectorTest.php
Go to the documentation of this file.
1 <?php
2 
20 
35 
36 require_once('./libs/composer/vendor/autoload.php');
37 
42 class CollectorTest extends TestCase
43 {
45 
46  protected function setUp() : void
47  {
48  parent::setUp();
49  }
50 
51  public function testBasic() : void
52  {
53  $this->assertTrue(true);
54  return; // WIP
55  $collector = new MainMenuMainCollector([$this->getDummyProvider()], $this->getItemInformation());
56  $collector->collectOnce();
57 
58  $this->assertTrue($collector->hasItems());
59  }
60 
61  private function getItemInformation() : ItemInformation
62  {
63  return new class() implements ItemInformation {
64  public function isItemActive(isItem $item) : bool
65  {
66  return true;
67  }
68 
69  public function customPosition(isItem $item) : isItem
70  {
71  return $item;
72  }
73 
74  public function customTranslationForUser(hasTitle $item) : hasTitle
75  {
76  return $item;
77  }
78 
79  public function getParent(isItem $item) : IdentificationInterface
80  {
81  return $item->getParent();
82  }
83 
84  public function customSymbol(hasSymbol $item) : hasSymbol
85  {
86  return $item;
87  }
88  };
89  }
90 
91  private function getDummyProvider() : StaticMainMenuProvider
92  {
93  return new class() implements StaticMainMenuProvider {
97  private $p_identifications;
101  protected $c_identifications;
102 
103  public function __construct()
104  {
106  $iff = function (string $id) use ($if) {
107  return $if->core($this)->identifier($id);
108  };
109  $this->factory = new MainMenuItemFactory();
110  $this->p_identifications = [];
111  $this->c_identifications = [];
112  $this->type_information = new TypeInformationCollection();
113  $this->type_information->add();
114 
115  for ($x = 1; $x < 5; $x++) {
116  $this->p_identifications['id_' . $x] = $iff('id_' . $x);
117  for ($y = 1; $y < 5; $y++) {
118  $this->c_identifications[] = $iff('id_' . $x . '/' . $y);
119  }
120  }
121  }
122 
123  public function getAllIdentifications() : array
124  {
125  return [];
126  }
127 
128  public function getFullyQualifiedClassName() : string
129  {
130  return 'Provider';
131  }
132 
133  public function getProviderNameForPresentation() : string
134  {
135  return 'Provider';
136  }
137 
138  public function getStaticTopItems() : array
139  {
140  $items = [];
141  foreach ($this->p_identifications as $if) {
142  $items[] = $this->factory->topParentItem($if)->withTitle($if->getInternalIdentifier());
143  }
144  return $items;
145  }
146 
147  public function getStaticSubItems() : array
148  {
149  $items = [];
150  foreach ($this->c_identifications as $if) {
151  $identifier = $if->getInternalIdentifier();
152  $items[] = $this->factory->link($if)->withTitle($identifier)->withParent($this->p_identifications[strstr($identifier, '/', true)]);
153  }
154  return $items;
155  }
156 
157  public function provideTypeInformation() : TypeInformationCollection
158  {
159  return $this->type_information;
160  }
161  };
162  }
163 }
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...
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
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
__construct($a_client_id=0)
Constructor setup ILIAS global object public.