ILIAS  release_8 Revision v8.24
MainBarTest Class Reference

Tests for the Main Bar. More...

+ Inheritance diagram for MainBarTest:
+ Collaboration diagram for MainBarTest:

Public Member Functions

 setUp ()
 
 testConstruction ()
 
 testAddEntry ()
 
 testDisallowedEntry ()
 
 testDouplicateIdEntry ()
 
 testDisallowedToolEntry ()
 
 testAddToolEntryWithoutToolsButton ()
 
 testAddToolEntry ()
 
 testDouplicateIdToolEntry ()
 
 testActive (C\MainControls\MainBar $mb)
 @depends testAddEntry More...
 
 testWithInvalidActive ()
 
 testSignalsPresent ()
 
 getUIFactory ()
 
 testRendering ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 getButton ()
 
 getLink ()
 
 getSlate ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Protected Attributes

I Button Factory $button_factory
 
I Link Factory $link_factory
 
I Symbol Icon Factory $icon_factory
 
I MainControls Factory $factory
 
C MainControls MainBar $mainbar
 

Detailed Description

Tests for the Main Bar.

Definition at line 34 of file MainBarTest.php.

Member Function Documentation

◆ getButton()

MainBarTest::getButton ( )
protected

Definition at line 71 of file MainBarTest.php.

71 : C\Button\Bulky
72 {
73 $symbol = $this->icon_factory->custom('', '');
74 return $this->button_factory->bulky($symbol, 'TestEntry', '#');
75 }

Referenced by testAddEntry(), testAddToolEntry(), testDouplicateIdEntry(), testDouplicateIdToolEntry(), and testRendering().

+ Here is the caller graph for this function:

◆ getLink()

MainBarTest::getLink ( )
protected

Definition at line 77 of file MainBarTest.php.

78 {
79 $symbol = $this->icon_factory->custom('', '');
80 $target = new Data\URI("http://www.ilias.de");
81 return $this->link_factory->bulky($symbol, 'TestEntry', $target);
82 }

Referenced by testAddEntry().

+ Here is the caller graph for this function:

◆ getSlate()

MainBarTest::getSlate ( )
protected
Returns
Legacy|mixed|MockObject

Definition at line 87 of file MainBarTest.php.

88 {
89 $mock = $this->getMockBuilder(Legacy::class)
90 ->disableOriginalConstructor()
91 ->getMock();
92
93 return $mock;
94 }

Referenced by testAddToolEntry(), testAddToolEntryWithoutToolsButton(), and testDouplicateIdToolEntry().

+ Here is the caller graph for this function:

◆ getUIFactory()

MainBarTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 184 of file MainBarTest.php.

185 {
186 $factory = new class () extends NoUIFactory {
187 public C\Button\Factory $button_factory;
188
189 public function button(): C\Button\Factory
190 {
192 }
193 public function symbol(): C\Symbol\Factory
194 {
195 $f_icon = new I\Symbol\Icon\Factory();
196 $f_glyph = new I\Symbol\Glyph\Factory();
197 $f_avatar = new I\Symbol\Avatar\Factory();
198
199 return new I\Symbol\Factory($f_icon, $f_glyph, $f_avatar);
200 }
201 public function mainControls(): C\MainControls\Factory
202 {
203 $sig_gen = new I\SignalGenerator();
204 $counter_factory = new I\Counter\Factory();
205 $symbol_factory = new I\Symbol\Factory(
206 new I\Symbol\Icon\Factory(),
207 new I\Symbol\Glyph\Factory(),
208 new I\Symbol\Avatar\Factory()
209 );
210 $slate_factory = new I\MainControls\Slate\Factory($sig_gen, $counter_factory, $symbol_factory);
211 return new I\MainControls\Factory($sig_gen, $slate_factory);
212 }
213 public function legacy(string $content): C\Legacy\Legacy
214 {
215 $sig_gen = new I\SignalGenerator();
216 return new I\Legacy\Legacy($content, $sig_gen);
217 }
218 };
219 $factory->button_factory = $this->button_factory;
220 return $factory;
221 }
Builds data types.
Definition: Factory.php:21
I Button Factory $button_factory
Definition: MainBarTest.php:36
I MainControls Factory $factory
Definition: MainBarTest.php:39
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $button_factory, $factory, and ILIAS\UI\examples\MainControls\Slate\Legacy\legacy().

+ Here is the call graph for this function:

◆ setUp()

MainBarTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 42 of file MainBarTest.php.

42 : void
43 {
44 $sig_gen = new I\SignalGenerator();
45 $this->button_factory = new I\Button\Factory();
46 $this->link_factory = new I\Link\Factory();
47 $this->icon_factory = new I\Symbol\Icon\Factory();
48 $counter_factory = new I\Counter\Factory();
49 $slate_factory = new I\MainControls\Slate\Factory(
50 $sig_gen,
51 $counter_factory,
52 new I\Symbol\Factory(
53 new I\Symbol\Icon\Factory(),
54 new I\Symbol\Glyph\Factory(),
55 new I\Symbol\Avatar\Factory()
56 )
57 );
58 $this->factory = new I\MainControls\Factory($sig_gen, $slate_factory);
59
60 $this->mainbar = $this->factory->mainBar();
61 }

References ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testActive()

MainBarTest::testActive ( C\MainControls\MainBar  $mb)

@depends testAddEntry

Definition at line 164 of file MainBarTest.php.

164 : void
165 {
166 $mb = $mb->withActive('testbtn');
167 $this->assertEquals('testbtn', $mb->getActive());
168 }

◆ testAddEntry()

MainBarTest::testAddEntry ( )

Definition at line 96 of file MainBarTest.php.

96 : C\MainControls\MainBar
97 {
98 $btn = $this->getButton();
99 $lnk = $this->getLink();
100 $mb = $this->mainbar
101 ->withAdditionalEntry('testbtn', $btn)
102 ->withAdditionalEntry('testlnk', $lnk);
103
104 $entries = $mb->getEntries();
105 $expected = [
106 'testbtn' => $btn,
107 'testlnk' => $lnk,
108 ];
109 $this->assertEquals($expected, $entries);
110 return $mb;
111 }

References getButton(), getLink(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testAddToolEntry()

MainBarTest::testAddToolEntry ( )

Definition at line 140 of file MainBarTest.php.

140 : void
141 {
142 $slate = $this->getSlate();
143 $mb = $this->mainbar
144 ->withToolsButton($this->getButton())
145 ->withAdditionalToolEntry('test', $slate);
146 $entries = $mb->getToolEntries();
147 $this->assertEquals($slate, $entries['test']);
148 }

References getButton(), getSlate(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testAddToolEntryWithoutToolsButton()

MainBarTest::testAddToolEntryWithoutToolsButton ( )

Definition at line 134 of file MainBarTest.php.

134 : void
135 {
136 $this->expectException(LogicException::class);
137 $this->mainbar->withAdditionalToolEntry('test', $this->getSlate());
138 }

References getSlate(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testConstruction()

MainBarTest::testConstruction ( )

Definition at line 63 of file MainBarTest.php.

63 : void
64 {
65 $this->assertInstanceOf(
66 "ILIAS\\UI\\Component\\MainControls\\MainBar",
67 $this->mainbar
68 );
69 }

References ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testDisallowedEntry()

MainBarTest::testDisallowedEntry ( )

Definition at line 113 of file MainBarTest.php.

113 : void
114 {
115 $this->expectException(InvalidArgumentException::class);
116 $this->mainbar->withAdditionalEntry('test', 'wrong_param');
117 }

References ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testDisallowedToolEntry()

MainBarTest::testDisallowedToolEntry ( )

Definition at line 128 of file MainBarTest.php.

128 : void
129 {
130 $this->expectException(\TypeError::class);
131 $this->mainbar->withAdditionalToolEntry('test', 'wrong_param');
132 }

References ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testDouplicateIdEntry()

MainBarTest::testDouplicateIdEntry ( )

Definition at line 119 of file MainBarTest.php.

119 : void
120 {
121 $this->expectException(InvalidArgumentException::class);
122 $btn = $this->getButton();
123 $this->mainbar
124 ->withAdditionalEntry('test', $btn)
125 ->withAdditionalEntry('test', $btn);
126 }

References getButton(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testDouplicateIdToolEntry()

MainBarTest::testDouplicateIdToolEntry ( )

Definition at line 150 of file MainBarTest.php.

150 : void
151 {
152 $this->expectException(InvalidArgumentException::class);
153 $btn = $this->getButton();
154 $slate = $this->getSlate();
155 $this->mainbar
156 ->withToolsButton($btn)
157 ->withAdditionalToolEntry('test', $slate)
158 ->withAdditionalToolEntry('test', $slate);
159 }

References getButton(), getSlate(), and ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testRendering()

MainBarTest::testRendering ( )

Definition at line 223 of file MainBarTest.php.

223 : void
224 {
225 $r = $this->getDefaultRenderer();
226 $icon = $this->icon_factory->custom('', '');
227
228 $sf = $this->factory->slate();
229 $slate = $sf->combined('1', $icon)
230 ->withAdditionalEntry(
231 $sf->combined('1.1', $icon)
232 ->withAdditionalEntry(
233 $sf->combined('1.1.1', $icon)
234 )
235 );
236
237 $toolslate = $sf->legacy('Help', $icon, new I\Legacy\Legacy('Help', new I\SignalGenerator()));
238
239 $mb = $this->factory->mainBar()
240 ->withAdditionalEntry('test1', $this->getButton())
241 ->withAdditionalEntry('test2', $this->getButton())
242 ->withAdditionalEntry('slate', $slate)
243 ->withToolsButton($this->getButton())
244 ->withAdditionalToolEntry('tool1', $toolslate);
245
246 $html = $r->render($mb);
247
248 $expected = <<<EOT
249 <div class="il-maincontrols-mainbar" id="id_16">
250 <nav class="il-mainbar" aria-label="mainbar_aria_label">
251 <div class="il-mainbar-tools-button">
252 <button class="btn btn-bulky" id="id_14">
253 <img class="icon custom small" src="" alt=""/>
254 <span class="bulky-label">TestEntry</span>
255 </button>
256 </div>
257 <div class="il-mainbar-triggers">
258 <ul class="il-mainbar-entries" role="menubar" style="visibility: hidden">
259 <li role="none">
260 <button class="btn btn-bulky" data-action="#" id="id_1" role="menuitem">
261 <img class="icon custom small" src="" alt=""/>
262 <span class="bulky-label">TestEntry</span>
263 </button>
264 </li>
265 <li role="none">
266 <button class="btn btn-bulky" data-action="#" id="id_2" role="menuitem">
267 <img class="icon custom small" src="" alt=""/>
268 <span class="bulky-label">TestEntry</span>
269 </button>
270 </li>
271 <li role="none">
272 <button class="btn btn-bulky" id="id_3" role="menuitem">
273 <img class="icon custom small" src="" alt=""/>
274 <span class="bulky-label">1</span>
275 </button>
276 </li>
277 <li role="none">
278 <button class="btn btn-bulky" id="id_9" role="menuitem">
279 <span class="glyph" role="img">
280 <span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span>
281 </span>
282 <span class="bulky-label">mainbar_more_label</span>
283 </button>
284 </li>
285 </ul>
286 </div>
287 </nav>
288 <div class="il-mainbar-slates">
289 <div class="il-mainbar-tools-entries">
290 <ul class="il-mainbar-tools-entries-bg" role="menubar">
291 <li class="il-mainbar-tool-trigger-item" role="none">
292 <button class="btn btn-bulky" id="id_11" role="menuitem">
293 <img class="icon custom small" src="" alt=""/>
294 <span class="bulky-label">Help</span>
295 </button>
296 </li>
297 </ul>
298 </div>
299 <div class="il-maincontrols-slate disengaged" id="id_8" data-depth-level="1" role="menu">
300 <div class="il-maincontrols-slate-content" data-replace-marker="content">
301 <ul>
302 <li>
303 <button class="btn btn-bulky" id="id_4">
304 <img class="icon custom small" src="" alt=""/>
305 <span class="bulky-label">1.1</span>
306 </button>
307 <div class="il-maincontrols-slate disengaged" id="id_7" data-depth-level="2">
308 <div class="il-maincontrols-slate-content" data-replace-marker="content">
309 <ul>
310 <li>
311 <button class="btn btn-bulky" id="id_5">
312 <img class="icon custom small" src="" alt=""/>
313 <span class="bulky-label">1.1.1</span>
314 </button>
315 <div class="il-maincontrols-slate disengaged" id="id_6" data-depth-level="3">
316 <div class="il-maincontrols-slate-content" data-replace-marker="content"></div>
317 </div>
318 </li>
319 </ul>
320 </div>
321 </div>
322 </li>
323 </ul>
324 </div>
325 </div>
326 <div class="il-maincontrols-slate disengaged" id="id_10" data-depth-level="1" role="menu">
327 <div class="il-maincontrols-slate-content" data-replace-marker="content"></div>
328 </div>
329 <div class="il-maincontrols-slate disengaged" id="id_13" data-depth-level="1" role="menu">
330 <div class="il-maincontrols-slate-content" data-replace-marker="content">Help</div>
331 </div>
332 <div class="il-mainbar-close-slates">
333 <button class="btn btn-bulky" id="id_15">
334 <span class="glyph" role="img">
335 <span class="glyphicon glyphicon-triangle-left" aria-hidden="true"></span>
336 </span>
337 <span class="bulky-label">close</span>
338 </button>
339 </div>
340 </div>
341 </div>
342EOT;
343
344 $this->assertEquals(
345 $this->brutallyTrimHTML($expected),
346 $this->brutallyTrimHTML($html)
347 );
348 }
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355

References ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS\UI\examples\Symbol\Glyph\Close\close(), getButton(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ testSignalsPresent()

MainBarTest::testSignalsPresent ( )

Definition at line 176 of file MainBarTest.php.

176 : void
177 {
178 $this->assertInstanceOf(Signal::class, $this->mainbar->getEntryClickSignal());
179 $this->assertInstanceOf(Signal::class, $this->mainbar->getToolsClickSignal());
180 $this->assertInstanceOf(Signal::class, $this->mainbar->getToolsRemovalSignal());
181 $this->assertInstanceOf(Signal::class, $this->mainbar->getDisengageAllSignal());
182 }

References ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

◆ testWithInvalidActive()

MainBarTest::testWithInvalidActive ( )

Definition at line 170 of file MainBarTest.php.

170 : void
171 {
172 $this->expectException(InvalidArgumentException::class);
173 $this->mainbar->withActive('this-is-not-a-valid-entry');
174 }

References ILIAS\UI\examples\MainControls\MainBar\mainbar().

+ Here is the call graph for this function:

Field Documentation

◆ $button_factory

I Button Factory MainBarTest::$button_factory
protected

Definition at line 36 of file MainBarTest.php.

Referenced by getUIFactory().

◆ $factory

I MainControls Factory MainBarTest::$factory
protected

Definition at line 39 of file MainBarTest.php.

Referenced by getUIFactory().

◆ $icon_factory

I Symbol Icon Factory MainBarTest::$icon_factory
protected

Definition at line 38 of file MainBarTest.php.

◆ $link_factory

I Link Factory MainBarTest::$link_factory
protected

Definition at line 37 of file MainBarTest.php.

◆ $mainbar

C MainControls MainBar MainBarTest::$mainbar
protected

Definition at line 40 of file MainBarTest.php.


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