19declare(strict_types=1);
21require_once(__DIR__ .
"/../../../../../../vendor/composer/vendor/autoload.php");
22require_once(__DIR__ .
"/../../Base.php");
30 use I\Component\ComponentHelper;
40 return "Component Dummy";
52 public function panelSecondary(): I\Component\Panel\Secondary\Factory
54 return new I\Component\Panel\Secondary\Factory();
56 public function dropdown(): I\Component\Dropdown\Factory
58 return new I\Component\Dropdown\Factory();
60 public function viewControl(): I\Component\ViewControl\Factory
64 public function button(): I\Component\Button\Factory
66 return new I\Component\Button\Factory();
68 public function symbol(): I\Component\Symbol\Factory
70 return new I\Component\Symbol\Factory(
81 return new I\Component\Panel\Factory(
82 $this->createMock(
I\
Component\Panel\Listing\Factory::class),
83 $this->createMock(
I\
Component\Panel\Secondary\Factory::class),
91 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Panel\\Factory",
$f);
92 $this->assertInstanceOf(
93 "ILIAS\\UI\\Component\\Panel\\Standard",
96 $this->assertInstanceOf(
97 "ILIAS\\UI\\Component\\Panel\\Sub",
100 $this->assertInstanceOf(
101 "ILIAS\\UI\\Component\\Panel\\Report",
111 $this->assertEquals(
"Title", $p->getTitle());
118 $p =
$f->standard(
"Title", array(
$c));
120 $this->assertEquals($p->getContent(), array(
$c));
129 $actions =
new I\Component\Dropdown\Standard(array(
134 $p = $p->withActions($actions);
136 $this->assertEquals($p->getActions(), $actions);
145 $actions =
new I\Component\Dropdown\Standard(array(
150 $p = $p->withActions($actions);
152 $this->assertEquals($p->getActions(), $actions);
161 $card =
new I\Component\Card\Card(
"Card Title");
163 $p = $p->withFurtherInformation($card);
165 $this->assertEquals($p->getFurtherInformation(), $card);
174 $legacy =
new I\Component\Legacy\Content(
"Legacy content",
new SignalGenerator());
175 $secondary =
new I\Component\Panel\Secondary\Legacy(
"Legacy panel title", $legacy);
177 $p = $p->withFurtherInformation($secondary);
179 $this->assertEquals($p->getFurtherInformation(), $secondary);
186 $p = $fp->report(
"Title", $fp->sub(
"Title", array(
new ComponentDummy())));
188 $actions =
new I\Component\Dropdown\Standard(array(
193 $p = $p->withActions($actions);
195 $this->assertEquals($p->getActions(), $actions);
202 $p =
$f->report(
"Title", array($sub));
204 $this->assertEquals(
"Title", $p->getTitle());
211 $p =
$f->report(
"Title", [$sub]);
213 $this->assertEquals($p->getContent(), array($sub));
219 $r = $this->getDefaultRenderer();
221 $actions =
new I\Component\Dropdown\Standard(array(
226 $p =
$f->standard(
"Title", array())->withActions($actions);
228 $html = $r->render($p);
230 $expected_html = <<<EOT
231<div
class=
"panel panel-primary panel-flex">
232 <div
class=
"panel-heading ilHeader">
233 <div
class=
"panel-title"><h2>
Title</h2></div>
234 <div
class=
"panel-controls">
235 <div
class=
"dropdown" id=
"id_3"><
button class=
"btn btn-default dropdown-toggle" type=
"button" aria-label=
"actions" aria-haspopup=
"true" aria-expanded=
"false" aria-controls=
"id_3_menu"><span
class=
"caret"></span></
button>
236 <ul
id=
"id_3_menu" class=
"dropdown-menu">
237 <li><
button class=
"btn btn-link" data-action=
"https://www.ilias.de" id=
"id_1">
ILIAS</
button></li>
238 <li><
button class=
"btn btn-link" data-action=
"https://www.github.com" id=
"id_2">GitHub</
button></li>
243 <div
class=
"panel-body"></div>
246 $this->assertHTMLEquals($expected_html, $html);
252 $r = $this->getDefaultRenderer();
254 $actions =
new I\Component\Dropdown\Standard(array(
259 $p = $fp->sub(
"Title", array())->withActions($actions);
260 $card =
new I\Component\Card\Card(
"Card Title");
262 $p = $p->withFurtherInformation($card);
263 $html = $this->brutallyTrimHTML($r->render($p));
265 $expected_html = <<<EOT
266<div
class=
"panel panel-sub panel-flex">
267 <div
class=
"panel-heading ilBlockHeader">
269 <div
class=
"panel-controls">
270 <div
class=
"dropdown" id=
"id_3"><
button class=
"btn btn-default dropdown-toggle" type=
"button" aria-label=
"actions" aria-haspopup=
"true" aria-expanded=
"false" aria-controls=
"id_3_menu"><span
class=
"caret"></span></
button>
271 <ul
id=
"id_3_menu" class=
"dropdown-menu">
272 <li><
button class=
"btn btn-link" data-action=
"https://www.ilias.de" id=
"id_1">
ILIAS</
button></li>
273 <li><
button class=
"btn btn-link" data-action=
"https://www.github.com" id=
"id_2">GitHub</
button></li>
278 <div
class=
"panel-body">
280 <div
class=
"col-sm-8"></div>
281 <div
class=
"col-sm-4">
282 <div
class=
"il-card thumbnail">
283 <div
class=
"card-no-highlight"></div>
284 <div
class=
"caption card-title">Card
Title</div>
292 $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
298 $r = $this->getDefaultRenderer();
300 $p = $fp->sub(
"Title", array());
301 $legacy =
new I\Component\Legacy\Content(
"Legacy content",
new SignalGenerator());
302 $secondary =
new I\Component\Panel\Secondary\Legacy(
"Legacy panel title", $legacy);
303 $p = $p->withFurtherInformation($secondary);
304 $html = $r->render($p);
306 $expected_html = <<<EOT
307<div
class=
"panel panel-sub panel-flex">
308 <div
class=
"panel-heading ilBlockHeader">
310 <div
class=
"panel-controls"></div>
312 <div
class=
"panel-body">
314 <div
class=
"col-sm-8"></div>
315 <div
class=
"col-sm-4">
316 <div
class=
"panel panel-secondary panel-flex">
317 <div
class=
"panel-heading ilHeader">
318 <div
class=
"panel-title"><h2>Legacy panel title</h2></div>
319 <div
class=
"panel-controls"></div>
321 <div
class=
"panel-body">Legacy content</div>
329 $this->assertHTMLEquals(
330 $this->brutallyTrimHTML($expected_html),
331 $this->brutallyTrimHTML($html)
338 $r = $this->getDefaultRenderer();
340 $actions =
new I\Component\Dropdown\Standard(array(
345 $sub = $fp->sub(
"Title", array());
346 $card =
new I\Component\Card\Card(
"Card Title");
347 $sub = $sub->withFurtherInformation($card);
348 $report = $fp->report(
"Title", $sub)->withActions($actions);
350 $html = $this->brutallyTrimHTML($r->render($report));
352 $expected_html = <<<EOT
353<div
class=
"panel panel-primary il-panel-report panel-flex">
354 <div
class=
"panel-heading ilHeader">
355 <div
class=
"panel-title"><h2>
Title</h2></div>
356 <div
class=
"panel-controls">
357 <div
class=
"dropdown" id=
"id_3"><
button class=
"btn btn-default dropdown-toggle" type=
"button" aria-label=
"actions" aria-haspopup=
"true" aria-expanded=
"false" aria-controls=
"id_3_menu"><span
class=
"caret"></span></
button>
358 <ul
id=
"id_3_menu" class=
"dropdown-menu">
359 <li><
button class=
"btn btn-link" data-action=
"https://www.ilias.de" id=
"id_1">
ILIAS</
button></li>
360 <li><
button class=
"btn btn-link" data-action=
"https://www.github.com" id=
"id_2">GitHub</
button></li>
365 <div
class=
"panel-body">
366 <div
class=
"panel panel-sub panel-flex">
367 <div
class=
"panel-heading ilBlockHeader">
369 <div
class=
"panel-controls"></div>
371 <div
class=
"panel-body"><div
class=
"row">
372 <div
class=
"col-sm-8"></div>
373 <div
class=
"col-sm-4">
374 <div
class=
"il-card thumbnail">
375 <div
class=
"card-no-highlight"></div>
376 <div
class=
"caption card-title">Card
Title</div>
386 $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
395 $sortation = $this->
getUIFactory()->viewControl()->sortation($sort_options,
'a');
397 $p =
$f->standard(
"Title", [])
398 ->withViewControls([$sortation])
401 $this->assertEquals($p->getViewControls(), [$sortation]);
410 $sortation = $this->
getUIFactory()->viewControl()->sortation($sort_options,
'a');
412 $p =
$f->report(
"Title", [])
413 ->withViewControls([$sortation])
416 $this->assertEquals($p->getViewControls(), [$sortation]);
425 $mode = $this->
getUIFactory()->viewControl()->mode($modes,
'Presentation Mode');
428 $r = $this->getDefaultRenderer();
431 $p =
$f->report(
"Title", [])
432 ->withViewControls([$mode]);
434 $html = $r->render($p);
436 $expected_html = <<<EOT
437<div
class=
"panel panel-primary il-panel-report panel-flex">
438 <div
class=
"panel-heading ilHeader">
439 <div
class=
"panel-title"><h2>
Title</h2></div>
440 <div
class=
"panel-viewcontrols l-bar__space-keeper">
441 <div
class=
"il-viewcontrol-mode l-bar__element" aria-label=
"Presentation Mode" role=
"group">
442 <
button class=
"btn btn-default engaged" aria-pressed=
"true" data-action=
"a" id=
"id_1">
A</
button>
443 <
button class=
"btn btn-default" aria-pressed=
"false" data-action=
"b" id=
"id_2">
B</
button>
446 <div
class=
"panel-controls"></div>
448 <div
class=
"panel-body"></div>
452 $this->brutallyTrimHTML($expected_html),
453 $this->brutallyTrimHTML($html)
464 $sortation = $this->
getUIFactory()->viewControl()->sortation($sort_options,
'b');
467 $r = $this->getDefaultRenderer();
470 $p =
$f->standard(
"Title", [])
471 ->withViewControls([$sortation]);
473 $html = $r->render($p);
475 $expected_html = <<<EOT
476<div
class=
"panel panel-primary panel-flex">
477 <div
class=
"panel-heading ilHeader">
478 <div
class=
"panel-title"><h2>
Title</h2></div>
479 <div
class=
"panel-viewcontrols l-bar__space-keeper">
480 <div
class=
"dropdown il-viewcontrol il-viewcontrol-sortation l-bar__element" id=
"id_1">
481 <
button class=
"btn btn-default dropdown-toggle" type=
"button" data-toggle=
"dropdown" aria-label=
"sortation" aria-haspopup=
"true" aria-expanded=
"false" aria-controls=
"id_1_ctrl">
482 <span
class=
"label">vc_sort
B</span>
483 <span
class=
"glyphicon-sort"></span>
485 <ul
id=
"id_1_ctrl" class=
"dropdown-menu">
486 <li><
button class=
"btn btn-link" data-action=
"?sortation=a" id=
"id_2">
A</
button></li>
487 <li
class=
"selected"><
button class=
"btn btn-link" data-action=
"?sortation=b" id=
"id_3">
B</
button></li>
491 <div
class=
"panel-controls"></div>
493 <div
class=
"panel-body"></div>
497 $this->brutallyTrimHTML($expected_html),
498 $this->brutallyTrimHTML($html)
504 $pagination = $this->
getUIFactory()->viewControl()->pagination()
505 ->withTargetURL(
'http://ilias.de',
'page')
506 ->withTotalEntries(10)
508 ->withCurrentPage(1);
511 $r = $this->getDefaultRenderer();
514 $p =
$f->standard(
"Title", [])
515 ->withViewControls([$pagination]);
517 $html = $r->render($p);
519 $expected_html = <<<EOT
520<div
class=
"panel panel-primary panel-flex">
521 <div
class=
"panel-heading ilHeader">
522 <div
class=
"panel-title"><h2>
Title</h2></div>
523 <div
class=
"panel-viewcontrols l-bar__space-keeper">
524 <div
class=
"il-viewcontrol-pagination l-bar__element">
525 <
button class=
"btn btn-default" data-action=
"http://ilias.de?page=0" id=
"id_6">
526 <span
class=
"glyph" aria-label=
"back" role=
"img"><span
class=
"glyphicon glyphicon-chevron-left" aria-hidden=
"true"></span></span>
528 <
button class=
"btn btn-link" data-action=
"http://ilias.de?page=0" id=
"id_1">1</
button>
529 <
button class=
"btn btn-link engaged" aria-pressed=
"true" data-action=
"http://ilias.de?page=1" id=
"id_2">2</
button>
530 <
button class=
"btn btn-link" data-action=
"http://ilias.de?page=2" id=
"id_3">3</
button>
531 <
button class=
"btn btn-link" data-action=
"http://ilias.de?page=3" id=
"id_4">4</
button>
532 <
button class=
"btn btn-link" data-action=
"http://ilias.de?page=4" id=
"id_5">5</
button>
533 <
button class=
"btn btn-default" data-action=
"http://ilias.de?page=2" id=
"id_7">
534 <span
class=
"glyph" aria-label=
"next" role=
"img"><span
class=
"glyphicon glyphicon-chevron-right" aria-hidden=
"true"></span></span>
538 <div
class=
"panel-controls"></div>
540 <div
class=
"panel-body"></div>
544 $this->brutallyTrimHTML($expected_html),
545 $this->brutallyTrimHTML($html)
getCanonicalName()
Get the canonical name of the component.
Provides common functionality for UI tests.
Test on button implementation.
testRenderWithPagination()
testRenderWithSortation()
testSubWithSecondaryPanel()
testStandardWithActions()
testStandardWithViewControls()
testRenderSubWithSecondaryPanel()
testReportWithViewControls()
testImplementsFactoryInterface()
testRenderReportWithMode()
A component is the most general form of an entity in the UI.
button(string $caption, string $cmd)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.