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);
161 #[\PHPUnit\Framework\Attributes\Depends('testAddEntry')] 164 $mb = $mb->withActive(
'testbtn');
165 $this->assertEquals(
'testbtn', $mb->getActive());
170 $this->expectException(InvalidArgumentException::class);
171 $this->
mainbar->withActive(
'this-is-not-a-valid-entry');
176 $this->assertInstanceOf(Signal::class, $this->
mainbar->getEntryClickSignal());
177 $this->assertInstanceOf(Signal::class, $this->
mainbar->getToolsClickSignal());
178 $this->assertInstanceOf(Signal::class, $this->
mainbar->getToolsRemovalSignal());
179 $this->assertInstanceOf(Signal::class, $this->
mainbar->getDisengageAllSignal());
187 public function button(): I\Button\Factory
191 public function symbol(): I\Symbol\Factory
193 $f_icon =
new I\Symbol\Icon\Factory();
194 $f_glyph =
new I\Symbol\Glyph\Factory();
195 $f_avatar =
new I\Symbol\Avatar\Factory();
197 return new I\Symbol\Factory($f_icon, $f_glyph, $f_avatar);
199 public function mainControls(): I\MainControls\Factory
201 $sig_gen =
new I\SignalGenerator();
202 $counter_factory =
new I\Counter\Factory();
203 $symbol_factory =
new I\Symbol\Factory(
208 $slate_factory =
new I\MainControls\Slate\Factory($sig_gen, $counter_factory, $symbol_factory);
209 return new I\MainControls\Factory($sig_gen, $slate_factory);
211 public function legacy(): I\Legacy\Factory
213 $sig_gen =
new I\SignalGenerator();
214 return new I\Legacy\Factory($sig_gen);
223 $r = $this->getDefaultRenderer();
224 $icon = $this->icon_factory->custom(
'',
'');
227 $slate = $sf->combined(
'1', $icon)
228 ->withAdditionalEntry(
229 $sf->combined(
'1.1', $icon)
230 ->withAdditionalEntry(
231 $sf->combined(
'1.1.1', $icon)
235 $toolslate = $sf->legacy(
'Help', $icon,
new I\
Legacy\Content(
'Help',
new I\SignalGenerator()));
237 $mb = $this->
factory->mainBar()
238 ->withAdditionalEntry(
'test1', $this->
getButton())
239 ->withAdditionalEntry(
'test2', $this->
getButton())
240 ->withAdditionalEntry(
'slate', $slate)
242 ->withAdditionalToolEntry(
'tool1', $toolslate);
244 $html =
$r->render($mb);
247 <div
class=
"il-maincontrols-mainbar" id=
"id_16">
248 <nav
class=
"il-mainbar" aria-label=
"mainbar_aria_label">
249 <div
class=
"il-mainbar-tools-button">
250 <
button class=
"btn btn-bulky" id=
"id_14">
251 <img
class=
"icon custom small" src=
"" alt=
""/>
252 <span
class=
"bulky-label">TestEntry</span>
255 <div
class=
"il-mainbar-triggers">
256 <ul
class=
"il-mainbar-entries" role=
"menubar" style=
"visibility: hidden">
258 <
button class=
"btn btn-bulky" data-action=
"#" id=
"id_1" role=
"menuitem">
259 <img
class=
"icon custom small" src=
"" alt=
""/>
260 <span
class=
"bulky-label">TestEntry</span>
264 <
button class=
"btn btn-bulky" data-action=
"#" id=
"id_2" role=
"menuitem">
265 <img
class=
"icon custom small" src=
"" alt=
""/>
266 <span
class=
"bulky-label">TestEntry</span>
270 <
button class=
"btn btn-bulky" id=
"id_3" role=
"menuitem">
271 <img
class=
"icon custom small" src=
"" alt=
""/>
272 <span
class=
"bulky-label">1</span>
276 <
button class=
"btn btn-bulky" id=
"id_9" role=
"menuitem">
277 <span
class=
"glyph" role=
"img">
278 <span
class=
"glyphicon glyphicon-option-horizontal" aria-hidden=
"true"></span>
280 <span
class=
"bulky-label">mainbar_more_label</span>
286 <div
class=
"il-mainbar-slates">
287 <div
class=
"il-mainbar-tools-entries">
288 <ul
class=
"il-mainbar-tools-entries-bg" role=
"menubar">
289 <li
class=
"il-mainbar-tool-trigger-item" role=
"none">
290 <
button class=
"btn btn-bulky" id=
"id_11" role=
"menuitem">
291 <img
class=
"icon custom small" src=
"" alt=
""/>
292 <span
class=
"bulky-label">Help</span>
297 <div
class=
"il-maincontrols-slate disengaged" id=
"id_8" data-depth-level=
"1" role=
"menu">
298 <div
class=
"il-maincontrols-slate-content" data-replace-marker=
"content">
301 <
button class=
"btn btn-bulky" id=
"id_4">
302 <img
class=
"icon custom small" src=
"" alt=
""/>
303 <span
class=
"bulky-label">1.1</span>
305 <div
class=
"il-maincontrols-slate disengaged" id=
"id_7" data-depth-level=
"2">
306 <div
class=
"il-maincontrols-slate-content" data-replace-marker=
"content">
309 <button
class=
"btn btn-bulky" id=
"id_5">
310 <img
class=
"icon custom small" src=
"" alt=
""/>
311 <span
class=
"bulky-label">1.1.1</span>
313 <div
class=
"il-maincontrols-slate disengaged" id=
"id_6" data-depth-level=
"3">
314 <div
class=
"il-maincontrols-slate-content" data-replace-marker=
"content"></div>
324 <div
class=
"il-maincontrols-slate disengaged" id=
"id_10" data-depth-level=
"1" role=
"menu">
325 <div
class=
"il-maincontrols-slate-content" data-replace-marker=
"content"></div>
327 <div
class=
"il-maincontrols-slate disengaged" id=
"id_13" data-depth-level=
"1" role=
"menu">
328 <div
class=
"il-maincontrols-slate-content" data-replace-marker=
"content">Help</div>
330 <div
class=
"il-mainbar-close-slates">
331 <button
class=
"btn btn-bulky" id=
"id_15">
332 <span
class=
"glyph" role=
"img">
333 <span
class=
"glyphicon glyphicon-triangle-left" aria-hidden=
"true"></span>
335 <span
class=
"bulky-label">
close</span>
343 $this->brutallyTrimHTML($expected),
344 $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)