ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
CollectorTest.php
Go to the documentation of this file.
1<?php
2
4
17use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
18use PHPUnit\Framework\TestCase;
19
20require_once('./libs/composer/vendor/autoload.php');
21
26class CollectorTest extends TestCase
27{
28 use MockeryPHPUnitIntegration;
29
30 protected function setUp() : void
31 {
32 parent::setUp();
33
34 }
35
36 public function testBasic() : void
37 {
38 $this->assertTrue(true);
39 return; // WIP
40 $collector = new MainMenuMainCollector([$this->getDummyProvider()], $this->getItemInformation());
41 $collector->collectOnce();
42
43 $this->assertTrue($collector->hasItems());
44 }
45
47 {
48 return new class implements ItemInformation {
49 public function isItemActive(isItem $item) : bool
50 {
51 return true;
52 }
53
54 public function customPosition(isItem $item) : isItem
55 {
56 return $item;
57 }
58
59 public function customTranslationForUser(hasTitle $item) : hasTitle
60 {
61 return $item;
62 }
63
64 public function getParent(isChild $item) : IdentificationInterface
65 {
66 return $item->getParent();
67 }
68
69 public function customSymbol(hasSymbol $item) : hasSymbol
70 {
71 return $item;
72 }
73
74 };
75 }
76
77 private function getDummyProvider() : StaticMainMenuProvider
78 {
79 return new class implements StaticMainMenuProvider {
83 private $p_identifications;
87 protected $c_identifications;
88
89 public function __construct()
90 {
92 $iff = function (string $id) use ($if) {
93 return $if->core($this)->identifier($id);
94 };
95 $this->factory = new MainMenuItemFactory();
96 $this->p_identifications = [];
97 $this->c_identifications = [];
98 $this->type_information = new TypeInformationCollection();
99 $this->type_information->add();
100
101 for ($x = 1; $x < 5; $x++) {
102 $this->p_identifications['id_' . $x] = $iff('id_' . $x);
103 for ($y = 1; $y < 5; $y++) {
104 $this->c_identifications[] = $iff('id_' . $x . '/' . $y);
105 }
106 }
107 }
108
109 public function getAllIdentifications() : array
110 {
111 return [];
112 }
113
114 public function getFullyQualifiedClassName() : string
115 {
116 return 'Provider';
117 }
118
119 public function getProviderNameForPresentation() : string
120 {
121 return 'Provider';
122 }
123
124 public function getStaticTopItems() : array
125 {
126 $items = [];
127 foreach ($this->p_identifications as $if) {
128 $items[] = $this->factory->topParentItem($if)->withTitle($if->getInternalIdentifier());
129 }
130 return $items;
131 }
132
133 public function getStaticSubItems() : array
134 {
135 $items = [];
136 foreach ($this->c_identifications as $if) {
137 $identifier = $if->getInternalIdentifier();
138 $items[] = $this->factory->link($if)->withTitle($identifier)->withParent($this->p_identifications[strstr($identifier, '/', true)]);
139 }
140 return $items;
141 }
142
143 public function provideTypeInformation() : TypeInformationCollection
144 {
145 return $this->type_information;
146 }
147 };
148 }
149
150}
An exception for terminatinating execution or to throw for unit testing.
Class MainMenuMainCollector This Collector will collect and then provide all available slates from th...
__construct($a_client_id=0)
Constructor setup ILIAS global object @access public.
Interface hasSymbol Methods for Entries with Symbols.
Definition: hasSymbol.php:12