5 require_once(
"libs/composer/vendor/autoload.php");
6 require_once(__DIR__ .
"/../../Base.php");
8 use \ILIAS\UI\Component as
C;
9 use \ILIAS\UI\Implementation\Component as
I;
10 use \ILIAS\UI\Implementation\Component\MainControls\Slate\Legacy;
11 use \ILIAS\UI\Component\Signal;
21 $this->button_factory =
new I\Button\Factory($sig_gen);
22 $this->link_factory =
new I\Link\Factory();
23 $this->icon_factory =
new I\Symbol\Icon\Factory();
24 $counter_factory =
new I\Counter\Factory();
25 $slate_factory =
new I\MainControls\Slate\Factory(
29 new I\Symbol\Icon\Factory(),
30 new I\Symbol\Glyph\Factory(),
31 new I\Symbol\Avatar\Factory()
34 $this->factory =
new I\MainControls\Factory($sig_gen, $slate_factory);
36 $this->
mainbar = $this->factory->mainBar();
41 $this->assertInstanceOf(
42 "ILIAS\\UI\\Component\\MainControls\\MainBar",
49 $symbol = $this->icon_factory->custom(
'',
'');
50 return $this->button_factory->bulky($symbol,
'TestEntry',
'#');
55 $symbol = $this->icon_factory->custom(
'',
'');
56 $target = new \ILIAS\Data\URI(
"http://www.ilias.de");
57 return $this->link_factory->bulky($symbol,
'TestEntry', $target);
62 $mock = $this->getMockBuilder(Legacy::class)
63 ->disableOriginalConstructor()
64 ->setMethods([
"transformToLegacyComponent"])
67 $mock->method(
'transformToLegacyComponent')->willReturn(
'content');
76 ->withAdditionalEntry(
'testbtn', $btn)
77 ->withAdditionalEntry(
'testlnk', $lnk);
79 $entries = $mb->getEntries();
84 $this->assertEquals($expected, $entries);
90 $this->expectException(\InvalidArgumentException::class);
91 $mb = $this->
mainbar->withAdditionalEntry(
'test',
'wrong_param');
96 $this->expectException(\InvalidArgumentException::class);
99 ->withAdditionalEntry(
'test', $btn)
100 ->withAdditionalEntry(
'test', $btn);
105 $this->expectException(\TypeError::class);
106 $mb = $this->
mainbar->withAdditionalToolEntry(
'test',
'wrong_param');
111 $this->expectException(\LogicException::class);
112 $mb = $this->
mainbar->withAdditionalToolEntry(
'test', $this->
getSlate());
120 ->withAdditionalToolEntry(
'test', $slate);
121 $entries = $mb->getToolEntries();
122 $this->assertEquals($slate, $entries[
'test']);
127 $this->expectException(\InvalidArgumentException::class);
130 $mb = $this->
mainbar->withToolsButton($btn)
131 ->withAdditionalToolEntry(
'test', $slate)
132 ->withAdditionalToolEntry(
'test', $slate);
140 $mb = $mb->withActive(
'testbtn');
141 $this->assertEquals(
'testbtn', $mb->getActive());
146 $this->expectException(\InvalidArgumentException::class);
148 ->withActive(
'this-is-not-a-valid-entry');
153 $this->assertInstanceOf(Signal::class, $this->
mainbar->getEntryClickSignal());
154 $this->assertInstanceOf(Signal::class, $this->
mainbar->getToolsClickSignal());
155 $this->assertInstanceOf(Signal::class, $this->
mainbar->getToolsRemovalSignal());
156 $this->assertInstanceOf(Signal::class, $this->
mainbar->getDisengageAllSignal());
161 $factory =
new class extends NoUIFactory {
162 public function button()
164 return $this->button_factory;
166 public function symbol() : C\Symbol\Factory
168 $f_icon =
new I\Symbol\Icon\Factory();
169 $f_glyph =
new I\Symbol\Glyph\Factory();
170 $f_avatar =
new I\Symbol\Avatar\Factory();
172 return new I\Symbol\Factory($f_icon, $f_glyph, $f_avatar);
174 public function mainControls() : C\MainControls\Factory
177 $counter_factory =
new I\Counter\Factory();
178 $symbol_factory =
new I\Symbol\Factory(
179 new I\Symbol\Icon\Factory(),
180 new I\Symbol\Glyph\Factory(),
181 new I\Symbol\Avatar\Factory()
183 $slate_factory =
new I\MainControls\Slate\Factory($sig_gen, $counter_factory, $symbol_factory);
184 return new I\MainControls\Factory($sig_gen, $slate_factory);
186 public function legacy($legacy)
189 return new I\Legacy\Legacy($legacy, $sig_gen);
192 $factory->button_factory = $this->button_factory;
198 $html = str_replace([
"\n",
"\r",
"\t"],
"", $html);
199 $html = preg_replace(
'# {2,}#',
" ", $html);
200 $html = preg_replace(
'/<!--(.|\s)*?-->/',
'', $html);
207 $icon = $this->icon_factory->custom(
'',
'');
209 $sf = $this->factory->slate();
210 $slate = $sf->combined(
'1', $icon,
'')
211 ->withAdditionalEntry(
212 $sf->combined(
'1.1', $icon,
'')
213 ->withAdditionalEntry(
214 $sf->combined(
'1.1.1', $icon,
'')
218 $mb = $this->factory->mainBar()
220 $this->button_factory->bulky($icon,
'more',
'')
222 ->withAdditionalEntry(
'test1', $this->
getButton())
223 ->withAdditionalEntry(
'test2', $this->
getButton())
224 ->withAdditionalEntry(
'slate', $slate);
226 $html = $r->render($mb);
229 <div
class=
"il-maincontrols-mainbar" id=
"id_12">
230 <nav
class=
"il-mainbar" aria-label=
"mainbar_aria_label">
231 <div
class=
"il-mainbar-triggers">
232 <div
class=
"il-mainbar-entries" role=
"menubar" style=
"visibility: hidden">
233 <button
class=
"btn btn-bulky" data-action=
"#" id=
"id_1" ><div
class=
"icon custom small" aria-label=
""><img src=
"" /></div><span
class=
"bulky-label">TestEntry</span></button>
234 <button
class=
"btn btn-bulky" data-action=
"#" id=
"id_2" ><div
class=
"icon custom small" aria-label=
""><img src=
"" /></div><span
class=
"bulky-label">TestEntry</span></button>
235 <button
class=
"btn btn-bulky" id=
"id_3" role=
"menuitem" aria-haspopup=
"true" ><div
class=
"icon custom small" aria-label=
""><img src=
"" /></div><span
class=
"bulky-label">1</span></button>
236 <button
class=
"btn btn-bulky" id=
"id_9" role=
"menuitem" aria-haspopup=
"true" ><span
class=
"glyph" aria-label=
"show_more"><span
class=
"glyphicon glyphicon-option-horizontal" aria-hidden=
"true"></span></span><span
class=
"bulky-label">
more</span></button>
241 <div
class=
"il-mainbar-slates">
242 <div
class=
"il-mainbar-tools-entries">
243 <div
class=
"il-mainbar-tools-entries-bg"></div>
245 <div
class=
"il-maincontrols-slate disengaged" id=
"id_8" data-depth-level=
"1" role=
"menu">
246 <div
class=
"il-maincontrols-slate-content" data-replace-marker=
"content">
247 <button
class=
"btn btn-bulky" id=
"id_4" ><div
class=
"icon custom small" aria-label=
""><img src=
"" /></div><span
class=
"bulky-label">1.1</span></button>
249 <div
class=
"il-maincontrols-slate disengaged" id=
"id_7" data-depth-level=
"2">
250 <div
class=
"il-maincontrols-slate-content" data-replace-marker=
"content">
251 <button
class=
"btn btn-bulky" id=
"id_5" ><div
class=
"icon custom small" aria-label=
""><img src=
"" /></div><span
class=
"bulky-label">1.1.1</span></button>
253 <div
class=
"il-maincontrols-slate disengaged" id=
"id_6" data-depth-level=
"3">
254 <div
class=
"il-maincontrols-slate-content" data-replace-marker=
"content"></div>
262 <div
class=
"il-maincontrols-slate disengaged" id=
"id_10" data-depth-level=
"1" role=
"menu">
263 <div
class=
"il-maincontrols-slate-content" data-replace-marker=
"content"></div>
266 <div
class=
"il-mainbar-close-slates">
267 <button
class=
"btn btn-bulky" id=
"id_11" ><span
class=
"glyph" href=
"#" aria-label=
"back"><span
class=
"glyphicon glyphicon-chevron-left" aria-hidden=
"true"></span></span><span
class=
"bulky-label">
close</span></button>
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Provides common functionality for UI tests.
testAddToolEntryWithoutToolsButton()
testDisallowedToolEntry()
testActive($mb)
testAddEntry
testDouplicateIdToolEntry()