19 declare(strict_types=1);
21 require_once(
"vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../Base.php");
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(
58 $this->
factory =
new I\MainControls\Factory($sig_gen, $slate_factory);
65 $this->assertInstanceOf(
66 "ILIAS\\UI\\Component\\MainControls\\MainBar",
73 $symbol = $this->icon_factory->custom(
'',
'');
74 return $this->button_factory->bulky($symbol,
'TestEntry',
'#');
79 $symbol = $this->icon_factory->custom(
'',
'');
80 $target =
new Data\URI(
"http://www.ilias.de");
81 return $this->link_factory->bulky($symbol,
'TestEntry', $target);
89 $mock = $this->getMockBuilder(Legacy::class)
90 ->disableOriginalConstructor()
101 ->withAdditionalEntry(
'testbtn', $btn)
102 ->withAdditionalEntry(
'testlnk', $lnk);
104 $entries = $mb->getEntries();
109 $this->assertEquals($expected, $entries);
115 $this->expectException(InvalidArgumentException::class);
116 $this->
mainbar->withAdditionalEntry(
'test',
'wrong_param');
121 $this->expectException(InvalidArgumentException::class);
124 ->withAdditionalEntry(
'test', $btn)
125 ->withAdditionalEntry(
'test', $btn);
130 $this->expectException(\TypeError::class);
131 $this->
mainbar->withAdditionalToolEntry(
'test',
'wrong_param');
136 $this->expectException(LogicException::class);
145 ->withAdditionalToolEntry(
'test', $slate);
146 $entries = $mb->getToolEntries();
147 $this->assertEquals($slate, $entries[
'test']);
152 $this->expectException(InvalidArgumentException::class);
156 ->withToolsButton($btn)
157 ->withAdditionalToolEntry(
'test', $slate)
158 ->withAdditionalToolEntry(
'test', $slate);
166 $mb = $mb->withActive(
'testbtn');
167 $this->assertEquals(
'testbtn', $mb->getActive());
172 $this->expectException(InvalidArgumentException::class);
173 $this->
mainbar->withActive(
'this-is-not-a-valid-entry');
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());
189 public function button(): I\Button\Factory
193 public function symbol(): I\Symbol\Factory
195 $f_icon =
new I\Symbol\Icon\Factory();
196 $f_glyph =
new I\Symbol\Glyph\Factory();
197 $f_avatar =
new I\Symbol\Avatar\Factory();
199 return new I\Symbol\Factory($f_icon, $f_glyph, $f_avatar);
201 public function mainControls(): I\MainControls\Factory
203 $sig_gen =
new I\SignalGenerator();
204 $counter_factory =
new I\Counter\Factory();
205 $symbol_factory =
new I\Symbol\Factory(
210 $slate_factory =
new I\MainControls\Slate\Factory($sig_gen, $counter_factory, $symbol_factory);
211 return new I\MainControls\Factory($sig_gen, $slate_factory);
213 public function legacy(): I\Legacy\Factory
215 $sig_gen =
new I\SignalGenerator();
216 return new I\Legacy\Factory($sig_gen);
225 $r = $this->getDefaultRenderer();
226 $icon = $this->icon_factory->custom(
'',
'');
229 $slate = $sf->combined(
'1', $icon)
230 ->withAdditionalEntry(
231 $sf->combined(
'1.1', $icon)
232 ->withAdditionalEntry(
233 $sf->combined(
'1.1.1', $icon)
237 $toolslate = $sf->legacy(
'Help', $icon,
new I\
Legacy\Content(
'Help',
new I\SignalGenerator()));
239 $mb = $this->
factory->mainBar()
240 ->withAdditionalEntry(
'test1', $this->
getButton())
241 ->withAdditionalEntry(
'test2', $this->
getButton())
242 ->withAdditionalEntry(
'slate', $slate)
244 ->withAdditionalToolEntry(
'tool1', $toolslate);
246 $html =
$r->render($mb);
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>
257 <div
class=
"il-mainbar-triggers">
258 <ul
class=
"il-mainbar-entries" role=
"menubar" style=
"visibility: hidden">
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>
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>
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>
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>
282 <span
class=
"bulky-label">mainbar_more_label</span>
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>
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">
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>
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">
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>
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>
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>
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>
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>
337 <span
class=
"bulky-label">
close</span>
345 $this->brutallyTrimHTML($expected),
346 $this->brutallyTrimHTML($html)
button(string $caption, string $cmd)
I Button Factory $button_factory
C MainControls MainBar $mainbar
mainbar()
expected output: > ILIAS shows a link "Full Screen Page Layout".
I Symbol Icon Factory $icon_factory
I Link Factory $link_factory
close()
description: > Example for rendring a close glyph.
legacy()
expected output: > ILIAS shows the rendered Component.
testAddToolEntryWithoutToolsButton()
testDisallowedToolEntry()
I MainControls Factory $factory
testDouplicateIdToolEntry()
testActive(C\MainControls\MainBar $mb)
testAddEntry