19 declare(strict_types=1);
21 require_once(
"vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../../Base.php");
39 return new I\Symbol\Glyph\Factory();
44 return new I\Counter\Factory();
48 G\Glyph::SETTINGS =>
"glyphicon glyphicon-cog",
49 G\Glyph::EXPAND =>
"glyphicon glyphicon-triangle-right",
50 G\Glyph::COLLAPSE =>
"glyphicon glyphicon-triangle-bottom",
51 G\Glyph::ADD =>
"glyphicon glyphicon-plus-sign",
52 G\Glyph::REMOVE =>
"glyphicon glyphicon-minus-sign",
53 G\Glyph::UP =>
"glyphicon glyphicon-circle-arrow-up",
54 G\Glyph::DOWN =>
"glyphicon glyphicon-circle-arrow-down",
55 G\Glyph::BACK =>
"glyphicon glyphicon-chevron-left",
56 G\Glyph::NEXT =>
"glyphicon glyphicon-chevron-right",
57 G\Glyph::SORT_ASCENDING =>
"glyphicon glyphicon-arrow-up",
58 G\Glyph::SORT_DESCENDING =>
"glyphicon glyphicon-arrow-down",
60 G\Glyph::MAIL =>
"glyphicon glyphicon-envelope",
61 G\Glyph::NOTIFICATION =>
"glyphicon glyphicon-bell",
63 G\Glyph::NOTE =>
"glyphicon glyphicon-pushpin",
64 G\Glyph::COMMENT =>
"glyphicon glyphicon-comment",
65 G\Glyph::BRIEFCASE =>
"glyphicon glyphicon-briefcase",
66 G\Glyph::LIKE =>
"glyphicon il-glyphicon-like",
67 G\Glyph::LOVE =>
"glyphicon il-glyphicon-love",
68 G\Glyph::DISLIKE =>
"glyphicon il-glyphicon-dislike",
69 G\Glyph::LAUGH =>
"glyphicon il-glyphicon-laugh",
70 G\Glyph::ASTOUNDED =>
"glyphicon il-glyphicon-astounded",
71 G\Glyph::SAD =>
"glyphicon il-glyphicon-sad",
72 G\Glyph::ANGRY =>
"glyphicon il-glyphicon-angry",
73 G\Glyph::EYEOPEN =>
"glyphicon glyphicon-eye-open",
74 G\Glyph::EYECLOSED =>
"glyphicon glyphicon-eye-close",
75 G\Glyph::ATTACHMENT =>
"glyphicon glyphicon-paperclip",
76 G\Glyph::RESET =>
"glyphicon glyphicon-reset",
77 G\Glyph::APPLY =>
"glyphicon glyphicon-apply",
78 G\Glyph::SEARCH =>
"glyphicon glyphicon-search",
79 G\Glyph::HELP =>
"glyphicon glyphicon-question-sign",
80 G\Glyph::CALENDAR =>
"glyphicon glyphicon-calendar",
81 G\Glyph::TIME =>
"glyphicon glyphicon-time",
82 G\Glyph::CLOSE =>
"glyphicon glyphicon-remove",
83 G\Glyph::MORE =>
"glyphicon glyphicon-option-horizontal",
84 G\Glyph::DISCLOSURE =>
"glyphicon glyphicon-option-vertical",
85 G\Glyph::LANGUAGE =>
"glyphicon glyphicon-lang",
86 G\Glyph::LOGIN =>
"glyphicon glyphicon-login",
87 G\Glyph::LOGOUT =>
"glyphicon glyphicon-logout",
88 G\Glyph::BULLETLIST =>
"glyphicon glyphicon-bulletlist",
89 G\Glyph::NUMBEREDLIST =>
"glyphicon glyphicon-numberedlist",
90 G\Glyph::LISTINDENT =>
"glyphicon glyphicon-listindent",
91 G\Glyph::LISTOUTDENT =>
"glyphicon glyphicon-listoutdent",
92 G\Glyph::FILTER =>
"glyphicon glyphicon-filter",
93 G\Glyph::COLLAPSE_HORIZONTAL =>
"glyphicon glyphicon-triangle-left",
94 G\Glyph::HEADER =>
"glyphicon glyphicon-header",
95 G\Glyph::ITALIC =>
"glyphicon glyphicon-italic",
96 G\Glyph::BOLD =>
"glyphicon glyphicon-bold",
97 G\Glyph::LINK =>
"glyphicon glyphicon-link",
98 G\Glyph::LAUNCH =>
"glyphicon glyphicon-launch",
99 G\Glyph::ENLARGE =>
"glyphicon glyphicon-enlarge",
100 G\Glyph::LIST_VIEW =>
"glyphicon glyphicon-listView",
101 G\Glyph::PREVIEW =>
"glyphicon glyphicon-preview",
102 G\Glyph::SORT =>
"glyphicon glyphicon-sort",
103 G\Glyph::COLUMN_SELECTION =>
"glyphicon glyphicon-columnSelection",
104 G\Glyph::TILE_VIEW =>
"glyphicon glyphicon-tileView",
105 G\Glyph::DRAG_HANDLE =>
"glyphicon glyphicon-dragHandle",
109 G\Glyph::SETTINGS =>
"settings",
110 G\Glyph::EXPAND =>
"expand_content",
111 G\Glyph::COLLAPSE =>
"collapse_content",
112 G\Glyph::ADD =>
"add",
113 G\Glyph::REMOVE =>
"remove",
115 G\Glyph::DOWN =>
"down",
116 G\Glyph::BACK =>
"back",
117 G\Glyph::NEXT =>
"next",
118 G\Glyph::SORT_ASCENDING =>
"sort_ascending",
119 G\Glyph::SORT_DESCENDING =>
"sort_descending",
121 G\Glyph::MAIL =>
"mail",
122 G\Glyph::NOTIFICATION =>
"notifications",
124 G\Glyph::NOTE =>
"notes",
125 G\Glyph::COMMENT =>
"comments",
126 G\Glyph::BRIEFCASE =>
"briefcase",
127 G\Glyph::LIKE =>
"like",
128 G\Glyph::LOVE =>
"love",
129 G\Glyph::DISLIKE =>
"dislike",
130 G\Glyph::LAUGH =>
"laugh",
131 G\Glyph::ASTOUNDED =>
"astounded",
132 G\Glyph::SAD =>
"sad",
133 G\Glyph::ANGRY =>
"angry",
134 G\Glyph::EYEOPEN =>
"eyeopened",
135 G\Glyph::EYECLOSED =>
"eyeclosed",
136 G\Glyph::ATTACHMENT =>
"attachment",
137 G\Glyph::RESET =>
"reset",
138 G\Glyph::APPLY =>
"apply",
139 G\Glyph::SEARCH =>
"search",
140 G\Glyph::HELP =>
"help",
141 G\Glyph::CALENDAR =>
"calendar",
142 G\Glyph::TIME =>
"time",
143 G\Glyph::CLOSE =>
"close",
144 G\Glyph::MORE =>
"show_more",
145 G\Glyph::DISCLOSURE =>
"disclose",
146 G\Glyph::LANGUAGE =>
"switch_language",
147 G\Glyph::LOGIN =>
"log_in",
148 G\Glyph::LOGOUT =>
"log_out",
149 G\Glyph::BULLETLIST =>
"bulletlist_action",
150 G\Glyph::NUMBEREDLIST =>
"numberedlist_action",
151 G\Glyph::LISTINDENT =>
"listindent",
152 G\Glyph::LISTOUTDENT =>
"listoutdent",
153 G\Glyph::FILTER =>
"filter",
154 G\Glyph::COLLAPSE_HORIZONTAL =>
"collapse/back",
155 G\Glyph::HEADER =>
"header_action",
156 G\Glyph::ITALIC =>
"italic_action",
157 G\Glyph::BOLD =>
"bold_action",
158 G\Glyph::LINK =>
"link_action",
159 G\Glyph::LAUNCH =>
"launch",
160 G\Glyph::ENLARGE =>
"enlarge",
161 G\Glyph::LIST_VIEW =>
"list_view",
162 G\Glyph::PREVIEW =>
"preview",
163 G\Glyph::SORT =>
"sort",
164 G\Glyph::COLUMN_SELECTION =>
"column_selection",
165 G\Glyph::TILE_VIEW =>
"tile_view",
166 G\Glyph::DRAG_HANDLE =>
"drag_handle",
176 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Glyph\\Factory",
$f);
177 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Glyph\\Glyph",
$f->$factory_method(
"http://www.ilias.de"));
186 $g =
$f->$factory_method();
188 $this->assertNotNull($g);
189 $this->assertEquals($factory_method, $g->getType());
198 $g =
$f->$factory_method(
"http://www.ilias.de");
200 $this->assertNotNull($g);
201 $this->assertEquals(
"http://www.ilias.de", $g->getAction());
210 $g =
$f->$factory_method();
212 $this->assertNotNull($g);
213 $this->assertEquals(
null, $g->getAction());
222 $g =
$f->$factory_method();
223 $g2 =
$f->$factory_method()->withUnavailableAction();
225 $this->assertTrue($g->isActive());
226 $this->assertFalse($g2->isActive());
234 $g2 = $g->withHighlight();
236 $this->assertFalse($g->isHighlighted());
237 $this->assertTrue($g2->isHighlighted());
246 $g =
$f->$factory_method();
248 $this->assertCount(0, $g->getCounters());
263 $cf->$counter_type($number)
266 $counters = $g->getCounters();
267 $this->assertCount(1, $counters);
269 $this->assertEquals($counter_type,
$c->getType());
270 $this->assertEquals($number,
$c->getNumber());
283 $cf->status($number_s)
286 $cf->novelty($number_n)
289 $counters = $g->getCounters();
290 $this->assertCount(2, $counters);
292 return array(
$c->getType(),
$c->getNumber());
294 $this->assertContains(array(
"status", $number_s), $vals);
295 $this->assertContains(array(
"novelty", $number_n), $vals);
309 $cf->status($number_s)
312 $cf->novelty($number_n1)
315 $cf->novelty($number_n2)
318 $counters = $g->getCounters();
319 $this->assertCount(2, $counters);
321 return array(
$c->getType(),
$c->getNumber());
323 $this->assertContains(array(
"status", $number_s), $vals);
324 $this->assertContains(array(
"novelty", $number_n2), $vals);
338 $counters = $g->getCounters();
339 $this->assertCount(0, $counters);
344 $this->expectException(InvalidArgumentException::class);
345 new Glyph(
"FOO",
"http://www.ilias.de");
351 $constant_values = array_values($glyph_reflection->getConstants());
354 }, $constant_values);
371 $r = $this->getDefaultRenderer();
372 $c =
$f->$type(
"http://www.ilias.de");
374 $html = $this->normalizeHTML(
$r->render(
$c));
376 $css_classes = self::$canonical_css_classes[$type];
377 $aria_label = self::$aria_labels[$type];
379 $expected =
'<a tabindex="0" class="glyph" href="http://www.ilias.de" aria-label="' . $aria_label .
'"><span class="' . $css_classes .
'" aria-hidden="true"></span></a>';
380 $this->assertEquals($expected, $html);
389 $r = $this->getDefaultRenderer();
390 $c =
$f->$type(
"http://www.ilias.de")->withUnavailableAction();
392 $html = $this->normalizeHTML(
$r->render(
$c));
394 $css_classes = self::$canonical_css_classes[$type];
395 $aria_label = self::$aria_labels[$type];
398 <a class="glyph disabled" aria-label="' . $aria_label .
'" aria-disabled="true"> 399 <span class="' . $css_classes .
'" aria-hidden="true"></span> 401 $this->assertEquals($this->brutallyTrimHTML($expected), $this->brutallyTrimHTML($html));
411 $r = $this->getDefaultRenderer();
412 $c = $fg->mail(
"http://www.ilias.de")->withCounter($fc->$type(42));
414 $html = $this->normalizeHTML(
$r->render(
$c));
416 $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
417 $aria_label = self::$aria_labels[G\Glyph::MAIL];
420 <a tabindex="0" class="glyph" href="http://www.ilias.de" aria-label="' . $aria_label .
'"> 421 <span class="' . $css_classes .
'" aria-hidden="true"></span> 422 <span class="il-counter"><span class="badge badge-notify il-counter-' . $type .
'">42</span></span> 423 <span class="il-counter-spacer">42</span> 425 $this->assertHTMLEquals($expected, $html);
432 $r = $this->getDefaultRenderer();
433 $c = $fg->mail(
"http://www.ilias.de")
434 ->withCounter($fc->novelty(42))
435 ->withCounter($fc->status(7));
437 $html = $this->normalizeHTML(
$r->render(
$c));
439 $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
440 $aria_label = self::$aria_labels[G\Glyph::MAIL];
441 $expected =
"<a tabindex=\"0\" class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">" .
442 "<span class=\"$css_classes\" aria-hidden=\"true\"></span>" .
443 "<span class=\"il-counter\"><span class=\"badge badge-notify il-counter-status\">7</span></span>" .
444 "<span class=\"il-counter\"><span class=\"badge badge-notify il-counter-novelty\">42</span></span>" .
445 "<span class=\"il-counter-spacer\">42</span>" .
447 $this->assertHTMLEquals($expected, $html);
452 $this->expectException(\LogicException::class);
454 $this->getUIFactory(),
455 $this->getTemplateFactory(),
457 $this->getJavaScriptBinding(),
459 $this->createMock(DataFactory::class),
460 $this->createMock(HelpTextRetriever::class),
461 $this->getUploadLimitResolver()
465 $r->render(
$f->status(0), $this->getDefaultRenderer());
474 $r = $this->getDefaultRenderer();
476 $c =
$f->$type(
"http://www.ilias.de")
477 ->withOnLoadCode(
function (
$id) use (&$ids):
string {
482 $html = $this->normalizeHTML(
$r->render(
$c));
484 $this->assertCount(1, $ids);
486 $css_classes = self::$canonical_css_classes[$type];
487 $aria_label = self::$aria_labels[$type];
490 $expected =
"<a tabindex=\"0\" class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\" id=\"$id\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
491 $this->assertEquals($expected, $html);
500 $r = $this->getDefaultRenderer();
501 $c =
$f->$type(
"http://www.ilias.de");
502 $c =
$c->withAction(
"http://www.ilias.de/open-source-lms-ilias/");
504 $html = $this->normalizeHTML(
$r->render(
$c));
506 $css_classes = self::$canonical_css_classes[$type];
507 $aria_label = self::$aria_labels[$type];
509 $expected =
"<a tabindex=\"0\" class=\"glyph\" href=\"http://www.ilias.de/open-source-lms-ilias/\" aria-label=\"$aria_label\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
510 $this->assertEquals($expected, $html);
516 $r = $this->getDefaultRenderer();
520 $this->assertFalse(
$c->isTabbable());
523 $c =
$f->user()->withAction(
"#");
524 $this->assertTrue($c->isTabbable());
527 $c =
$f->user()->withOnClick(
new I\
Signal(
"id_1",
"click"));
528 $this->assertTrue($c->isTabbable());
531 $c =
$f->user()->withAction(
"#")->withOnClick(
new I\
Signal(
"id_1",
"click"));
532 $this->assertTrue($c->isTabbable());
535 $c =
$f->user()->withAction(
"#")->withOnClick(
new I\
Signal(
"id_1",
"click"))->withUnavailableAction();
536 $this->assertFalse($c->isTabbable());
542 $r = $this->getDefaultRenderer();
546 $expected =
'<a class="glyph" aria-label="show_who_is_online"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></a>';
547 $html = $this->normalizeHTML(
$r->render(
$c));
548 $this->assertEquals($expected, $html);
551 $c =
$f->user()->withAction(
"#");
552 $expected =
'<a tabindex="0" class="glyph" href="#" aria-label="show_who_is_online"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></a>';
553 $html = $this->normalizeHTML(
$r->render(
$c));
554 $this->assertEquals($expected, $html);
static array $canonical_css_classes
testOneCounter(string $counter_type)
getCounterTypeProvider
static array $aria_labels
testRenderWithTwoCounters()
testRenderWithCounter(string $type)
getCounterTypeProvider
testGlyphTypes(string $factory_method)
getGlyphTypeProvider
testImmutabilityWithCounter()
testRenderWithAction(string $type)
getGlyphTypeProvider
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
testGlyphAction(string $factory_method)
getGlyphTypeProvider
testTabbableGlyphRender()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getGlyphTypeProvider()
testRenderWithOnLoadCode(string $type)
getGlyphTypeProvider
testRenderSimple(string $type)
getGlyphTypeProvider
testImplementsFactoryInterface(string $factory_method)
getGlyphTypeProvider
testWithUnavailableAction(string $factory_method)
getGlyphTypeProvider
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
testRenderWithUnavailableAction(string $type)
getGlyphTypeProvider
testGlyphNoAction(string $factory_method)
getGlyphTypeProvider
testNoCounter(string $factory_method)
getGlyphTypeProvider
static getCounterTypeProvider()
Test on glyph implementation.