5 require_once(
"libs/composer/vendor/autoload.php");
6 require_once(__DIR__ .
"/../../../Base.php");
8 use \ILIAS\UI\Component\Symbol\Glyph as
G;
17 return new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Factory();
22 return new \ILIAS\UI\Implementation\Component\Counter\Factory();
26 G\Glyph::SETTINGS =>
"glyphicon glyphicon-cog" 27 ,
G\Glyph::EXPAND =>
"glyphicon glyphicon-triangle-right" 28 ,
G\Glyph::COLLAPSE =>
"glyphicon glyphicon-triangle-bottom" 29 ,
G\Glyph::ADD =>
"glyphicon glyphicon-plus-sign" 30 ,
G\Glyph::REMOVE =>
"glyphicon glyphicon-minus-sign" 31 ,
G\Glyph::UP =>
"glyphicon glyphicon-circle-arrow-up" 32 ,
G\Glyph::DOWN =>
"glyphicon glyphicon-circle-arrow-down" 33 ,
G\Glyph::BACK =>
"glyphicon glyphicon-chevron-left" 34 ,
G\Glyph::NEXT =>
"glyphicon glyphicon-chevron-right" 35 ,
G\Glyph::SORT_ASCENDING =>
"glyphicon glyphicon-arrow-up" 36 ,
G\Glyph::SORT_DESCENDING =>
"glyphicon glyphicon-arrow-down" 37 ,
G\Glyph::USER =>
"glyphicon glyphicon-user" 38 ,
G\Glyph::MAIL =>
"glyphicon glyphicon-envelope" 39 ,
G\Glyph::NOTIFICATION =>
"glyphicon glyphicon-bell" 40 ,
G\Glyph::TAG =>
"glyphicon glyphicon-tag" 41 ,
G\Glyph::NOTE =>
"glyphicon glyphicon-pushpin" 42 ,
G\Glyph::COMMENT =>
"glyphicon glyphicon-comment" 43 ,
G\Glyph::BRIEFCASE =>
"glyphicon glyphicon-briefcase" 44 ,
G\Glyph::LIKE =>
"glyphicon il-glyphicon-like" 45 ,
G\Glyph::LOVE =>
"glyphicon il-glyphicon-love" 46 ,
G\Glyph::DISLIKE =>
"glyphicon il-glyphicon-dislike" 47 ,
G\Glyph::LAUGH =>
"glyphicon il-glyphicon-laugh" 48 ,
G\Glyph::ASTOUNDED =>
"glyphicon il-glyphicon-astounded" 49 ,
G\Glyph::SAD =>
"glyphicon il-glyphicon-sad" 50 ,
G\Glyph::ANGRY =>
"glyphicon il-glyphicon-angry" 51 ,
G\Glyph::EYEOPEN =>
"glyphicon glyphicon-eye-open" 52 ,
G\Glyph::EYECLOSED =>
"glyphicon glyphicon-eye-close" 53 ,
G\Glyph::ATTACHMENT =>
"glyphicon glyphicon-paperclip" 54 ,
G\Glyph::RESET =>
"glyphicon glyphicon-repeat" 55 ,
G\Glyph::APPLY =>
"glyphicon glyphicon-ok" 56 ,
G\Glyph::SEARCH =>
"glyphicon glyphicon-search" 57 ,
G\Glyph::HELP =>
"glyphicon glyphicon-question-sign" 58 ,
G\Glyph::CALENDAR =>
"glyphicon glyphicon-calendar" 59 ,
G\Glyph::TIME =>
"glyphicon glyphicon-time" 60 ,
G\Glyph::CLOSE =>
"glyphicon glyphicon-remove" 61 ,
G\Glyph::MORE =>
"glyphicon glyphicon-option-horizontal" 62 ,
G\Glyph::DISCLOSURE =>
"glyphicon glyphicon-option-vertical" 63 ,
G\Glyph::LANGUAGE =>
"glyphicon glyphicon-lang" 64 ,
G\Glyph::LOGIN =>
"glyphicon glyphicon-login" 65 ,
G\Glyph::LOGOUT =>
"glyphicon glyphicon-logout" 66 ,
G\Glyph::BULLETLIST =>
"glyphicon glyphicon-bulletlist" 67 ,
G\Glyph::NUMBEREDLIST =>
"glyphicon glyphicon-numberedlist" 68 ,
G\Glyph::LISTINDENT =>
"glyphicon glyphicon-listindent" 69 ,
G\Glyph::LISTOUTDENT =>
"glyphicon glyphicon-listoutdent" 70 ,
G\Glyph::FILTER =>
"glyphicon glyphicon-filter" 74 G\Glyph::SETTINGS =>
"settings" 75 ,
G\Glyph::EXPAND =>
"expand_content" 76 ,
G\Glyph::COLLAPSE =>
"collapse_content" 77 ,
G\Glyph::ADD =>
"add" 78 ,
G\Glyph::REMOVE =>
"remove" 80 ,
G\Glyph::DOWN =>
"down" 81 ,
G\Glyph::BACK =>
"back" 82 ,
G\Glyph::NEXT =>
"next" 83 ,
G\Glyph::SORT_ASCENDING =>
"sort_ascending" 84 ,
G\Glyph::SORT_DESCENDING =>
"sort_descending" 85 ,
G\Glyph::USER =>
"show_who_is_online" 86 ,
G\Glyph::MAIL =>
"mail" 87 ,
G\Glyph::NOTIFICATION =>
"notifications" 88 ,
G\Glyph::TAG =>
"tags" 89 ,
G\Glyph::NOTE =>
"notes" 90 ,
G\Glyph::COMMENT =>
"comments" 91 ,
G\Glyph::BRIEFCASE =>
"briefcase" 92 ,
G\Glyph::LIKE =>
"like" 93 ,
G\Glyph::LOVE =>
"love" 94 ,
G\Glyph::DISLIKE =>
"dislike" 95 ,
G\Glyph::LAUGH =>
"laugh" 96 ,
G\Glyph::ASTOUNDED =>
"astounded" 97 ,
G\Glyph::SAD =>
"sad" 98 ,
G\Glyph::ANGRY =>
"angry" 99 ,
G\Glyph::EYEOPEN =>
"eyeopened" 100 ,
G\Glyph::EYECLOSED =>
"eyeclosed" 101 ,
G\Glyph::ATTACHMENT =>
"attachment" 102 ,
G\Glyph::RESET =>
"reset" 103 ,
G\Glyph::APPLY =>
"apply" 104 ,
G\Glyph::SEARCH =>
"search" 105 ,
G\Glyph::HELP =>
"help" 106 ,
G\Glyph::CALENDAR =>
"calendar" 107 ,
G\Glyph::TIME =>
"time" 108 ,
G\Glyph::CLOSE =>
"close" 109 ,
G\Glyph::MORE =>
"show_more" 110 ,
G\Glyph::DISCLOSURE =>
"disclose" 111 ,
G\Glyph::LANGUAGE =>
"switch_language" 112 ,
G\Glyph::LOGIN =>
"log_in" 113 ,
G\Glyph::LOGOUT =>
"log_out" 114 ,
G\Glyph::BULLETLIST =>
"bulletlist" 115 ,
G\Glyph::NUMBEREDLIST =>
"numberedlist" 116 ,
G\Glyph::LISTINDENT =>
"listindent" 117 ,
G\Glyph::LISTOUTDENT =>
"listoutdent" 118 ,
G\Glyph::FILTER =>
"filter" 128 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Glyph\\Factory",
$f);
129 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Glyph\\Glyph",
$f->$factory_method(
"http://www.ilias.de"));
138 $g =
$f->$factory_method();
140 $this->assertNotNull($g);
141 $this->assertEquals($factory_method, $g->getType());
150 $g =
$f->$factory_method(
"http://www.ilias.de");
152 $this->assertNotNull($g);
153 $this->assertEquals(
"http://www.ilias.de", $g->getAction());
162 $g =
$f->$factory_method();
164 $this->assertNotNull($g);
165 $this->assertEquals(null, $g->getAction());
174 $g =
$f->$factory_method();
175 $g2 =
$f->$factory_method()->withUnavailableAction();
177 $this->assertTrue($g->isActive());
178 $this->assertFalse($g2->isActive());
189 $g2 = $g->withHighlight();
191 $this->assertFalse($g->isHighlighted());
192 $this->assertTrue($g2->isHighlighted());
201 $g =
$f->$factory_method();
203 $this->assertCount(0, $g->getCounters());
218 $cf->$counter_type($number)
221 $counters = $g->getCounters();
222 $this->assertCount(1, $counters);
224 $this->assertEquals($counter_type,
$c->getType());
225 $this->assertEquals($number,
$c->getNumber());
238 $cf->status($number_s)
241 $cf->novelty($number_n)
244 $counters = $g->getCounters();
245 $this->assertCount(2, $counters);
246 $vals = array_map(
function (
$c) {
247 return array(
$c->getType(),
$c->getNumber());
249 $this->assertContains(array(
"status", $number_s), $vals);
250 $this->assertContains(array(
"novelty", $number_n), $vals);
264 $cf->status($number_s)
267 $cf->novelty($number_n1)
270 $cf->novelty($number_n2)
273 $counters = $g->getCounters();
274 $this->assertCount(2, $counters);
275 $vals = array_map(
function (
$c) {
276 return array(
$c->getType(),
$c->getNumber());
278 $this->assertContains(array(
"status", $number_s), $vals);
279 $this->assertContains(array(
"novelty", $number_n2), $vals);
293 $counters = $g->getCounters();
294 $this->assertCount(0, $counters);
299 $this->expectException(\InvalidArgumentException::class);
300 new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Glyph(
"FOO",
"http://www.ilias.de");
306 $constant_values = array_values($glyph_reflection->getConstants());
307 return array_map(
function ($val) {
309 }, $constant_values);
314 return array( array(
"status")
326 $c =
$f->$type(
"http://www.ilias.de");
330 $css_classes = self::$canonical_css_classes[
$type];
331 $aria_label = self::$aria_labels[
$type];
333 $expected =
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
334 $this->assertEquals($expected, $html);
344 $c =
$f->$type(
"http://www.ilias.de")->withUnavailableAction();
348 $css_classes = self::$canonical_css_classes[
$type];
349 $aria_label = self::$aria_labels[
$type];
351 $expected =
"<a class=\"glyph disabled\" aria-label=\"$aria_label\" " .
352 "aria-disabled=\"true\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
353 $this->assertEquals($expected, $html);
364 $c = $fg->mail(
"http://www.ilias.de")->withCounter($fc->$type(42));
371 $expected =
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">" .
372 "<span class=\"$css_classes\" aria-hidden=\"true\"></span>" .
373 "<span class=\"il-counter\"><span class=\"badge badge-notify il-counter-$type\">42</span></span>" .
374 "<span class=\"il-counter-spacer\">42</span>" .
384 $c = $fg->mail(
"http://www.ilias.de")
385 ->withCounter($fc->novelty(42))
386 ->withCounter($fc->status(7));
392 $expected =
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">" .
393 "<span class=\"$css_classes\" aria-hidden=\"true\"></span>" .
394 "<span class=\"il-counter\"><span class=\"badge badge-notify il-counter-status\">7</span></span>" .
395 "<span class=\"il-counter\"><span class=\"badge badge-notify il-counter-novelty\">42</span></span>" .
396 "<span class=\"il-counter-spacer\">42</span>" .
403 $this->expectException(\LogicException::class);
404 $r = new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Renderer(
425 $c =
$f->$type(
"http://www.ilias.de")
426 ->withOnLoadCode(
function ($id) use (&$ids) {
433 $this->assertCount(1, $ids);
435 $css_classes = self::$canonical_css_classes[
$type];
436 $aria_label = self::$aria_labels[
$type];
439 $expected =
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\" id=\"$id\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
440 $this->assertEquals($expected, $html);
450 $c =
$f->$type(
"http://www.ilias.de");
451 $c =
$c->withAction(
"http://www.ilias.de/open-source-lms-ilias/");
455 $css_classes = self::$canonical_css_classes[
$type];
456 $aria_label = self::$aria_labels[
$type];
458 $expected =
"<a class=\"glyph\" href=\"http://www.ilias.de/open-source-lms-ilias/\" aria-label=\"$aria_label\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
459 $this->assertEquals($expected, $html);
test_glyph_no_action($factory_method)
glyph_type_provider
test_render_simple($type)
glyph_type_provider
test_dont_render_counter()
test_with_highlight($counter_type)
counter_type_provider
test_render_withCounter($type)
counter_type_provider
test_implements_factory_interface($factory_method)
glyph_type_provider
Provides common functionality for UI tests.
test_one_counter($counter_type)
counter_type_provider
test_glyph_types($factory_method)
glyph_type_provider
test_render_with_action($type)
glyph_type_provider
assertHTMLEquals($expected_html_as_string, $html_as_string)
test_no_counter($factory_method)
glyph_type_provider
test_with_unavailable_action($factory_method)
glyph_type_provider
static $canonical_css_classes
test_render_with_on_load_code($type)
glyph_type_provider
test_glyph_action($factory_method)
glyph_type_provider
test_render_with_unavailable_action($type)
glyph_type_provider
test_render_withTwoCounters()
test_immutability_withCounter()
Test on glyph implementation.
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])