5require_once(
"libs/composer/vendor/autoload.php");
6require_once(__DIR__ .
"/../../../Base.php");
8use \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::EXPAND =>
"glyphicon glyphicon-triangle-right"
27 ,
G\Glyph::COLLAPSE =>
"glyphicon glyphicon-triangle-bottom"
28 ,
G\Glyph::ADD =>
"glyphicon glyphicon-plus-sign"
29 ,
G\Glyph::REMOVE =>
"glyphicon glyphicon-minus-sign"
30 ,
G\Glyph::UP =>
"glyphicon glyphicon-circle-arrow-up"
31 ,
G\Glyph::DOWN =>
"glyphicon glyphicon-circle-arrow-down"
32 ,
G\Glyph::BACK =>
"glyphicon glyphicon-chevron-left"
33 ,
G\Glyph::NEXT =>
"glyphicon glyphicon-chevron-right"
34 ,
G\Glyph::SORT_ASCENDING =>
"glyphicon glyphicon-arrow-up"
35 ,
G\Glyph::SORT_DESCENDING =>
"glyphicon glyphicon-arrow-down"
36 ,
G\Glyph::USER =>
"glyphicon glyphicon-user"
37 ,
G\Glyph::MAIL =>
"glyphicon glyphicon-envelope"
38 ,
G\Glyph::NOTIFICATION =>
"glyphicon glyphicon-bell"
39 ,
G\Glyph::TAG =>
"glyphicon glyphicon-tag"
40 ,
G\Glyph::NOTE =>
"glyphicon glyphicon-pushpin"
41 ,
G\Glyph::COMMENT =>
"glyphicon glyphicon-comment"
42 ,
G\Glyph::LIKE =>
"glyphicon il-glyphicon-like"
43 ,
G\Glyph::LOVE =>
"glyphicon il-glyphicon-love"
44 ,
G\Glyph::DISLIKE =>
"glyphicon il-glyphicon-dislike"
45 ,
G\Glyph::LAUGH =>
"glyphicon il-glyphicon-laugh"
46 ,
G\Glyph::ASTOUNDED =>
"glyphicon il-glyphicon-astounded"
47 ,
G\Glyph::SAD =>
"glyphicon il-glyphicon-sad"
48 ,
G\Glyph::ANGRY =>
"glyphicon il-glyphicon-angry"
49 ,
G\Glyph::ATTACHMENT =>
"glyphicon glyphicon-paperclip"
50 ,
G\Glyph::RESET =>
"glyphicon glyphicon-repeat"
51 ,
G\Glyph::APPLY =>
"glyphicon glyphicon-ok"
52 ,
G\Glyph::SEARCH =>
"glyphicon glyphicon-search"
53 ,
G\Glyph::HELP =>
"glyphicon glyphicon-question-sign"
54 ,
G\Glyph::CALENDAR =>
"glyphicon glyphicon-calendar"
55 ,
G\Glyph::TIME =>
"glyphicon glyphicon-time"
56 ,
G\Glyph::CLOSE =>
"glyphicon glyphicon-remove"
57 ,
G\Glyph::MORE =>
"glyphicon glyphicon-option-horizontal"
58 ,
G\Glyph::DISCLOSURE =>
"glyphicon glyphicon-option-vertical"
59 ,
G\Glyph::LANGUAGE =>
"glyphicon glyphicon-lang"
60 ,
G\Glyph::LOGIN =>
"glyphicon glyphicon-login"
61 ,
G\Glyph::LOGOUT =>
"glyphicon glyphicon-logout"
65 G\Glyph::SETTINGS =>
"settings"
66 ,
G\Glyph::EXPAND =>
"expand_content"
67 ,
G\Glyph::COLLAPSE =>
"collapse_content"
68 ,
G\Glyph::ADD =>
"add"
69 ,
G\Glyph::REMOVE =>
"remove"
71 ,
G\Glyph::DOWN =>
"down"
72 ,
G\Glyph::BACK =>
"back"
73 ,
G\Glyph::NEXT =>
"next"
74 ,
G\Glyph::SORT_ASCENDING =>
"sort_ascending"
75 ,
G\Glyph::SORT_DESCENDING =>
"sort_descending"
76 ,
G\Glyph::USER =>
"show_who_is_online"
77 ,
G\Glyph::MAIL =>
"mail"
78 ,
G\Glyph::NOTIFICATION =>
"notifications"
79 ,
G\Glyph::TAG =>
"tags"
80 ,
G\Glyph::NOTE =>
"notes"
81 ,
G\Glyph::COMMENT =>
"comments"
82 ,
G\Glyph::LIKE =>
"like"
83 ,
G\Glyph::LOVE =>
"love"
84 ,
G\Glyph::DISLIKE =>
"dislike"
85 ,
G\Glyph::LAUGH =>
"laugh"
86 ,
G\Glyph::ASTOUNDED =>
"astounded"
87 ,
G\Glyph::SAD =>
"sad"
88 ,
G\Glyph::ANGRY =>
"angry"
89 ,
G\Glyph::ATTACHMENT =>
"attachment"
90 ,
G\Glyph::RESET =>
"reset"
91 ,
G\Glyph::APPLY =>
"apply"
92 ,
G\Glyph::SEARCH =>
"search"
93 ,
G\Glyph::HELP =>
"help"
94 ,
G\Glyph::CALENDAR =>
"calendar"
95 ,
G\Glyph::TIME =>
"time"
96 ,
G\Glyph::CLOSE =>
"close"
97 ,
G\Glyph::MORE =>
"show_more"
98 ,
G\Glyph::DISCLOSURE =>
"disclose"
99 ,
G\Glyph::LANGUAGE =>
"switch_language"
100 ,
G\Glyph::LOGIN =>
"log_in"
101 ,
G\Glyph::LOGOUT =>
"log_out"
111 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Glyph\\Factory",
$f);
112 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Glyph\\Glyph",
$f->$factory_method(
"http://www.ilias.de"));
121 $g =
$f->$factory_method();
123 $this->assertNotNull($g);
124 $this->assertEquals($factory_method, $g->getType());
133 $g =
$f->$factory_method(
"http://www.ilias.de");
135 $this->assertNotNull($g);
136 $this->assertEquals(
"http://www.ilias.de", $g->getAction());
145 $g =
$f->$factory_method();
147 $this->assertNotNull($g);
148 $this->assertEquals(
null, $g->getAction());
157 $g =
$f->$factory_method();
158 $g2 =
$f->$factory_method()->withUnavailableAction();
160 $this->assertTrue($g->isActive());
161 $this->assertFalse($g2->isActive());
174 $g2 = $g->withHighlight();
176 $this->assertFalse($g->isHighlighted());
177 $this->assertTrue($g2->isHighlighted());
186 $g =
$f->$factory_method();
188 $this->assertCount(0, $g->getCounters());
203 $cf->$counter_type($number)
206 $counters = $g->getCounters();
207 $this->assertCount(1, $counters);
209 $this->assertEquals($counter_type,
$c->getType());
210 $this->assertEquals($number,
$c->getNumber());
223 $cf->status($number_s)
226 $cf->novelty($number_n)
229 $counters = $g->getCounters();
230 $this->assertCount(2, $counters);
231 $vals = array_map(
function (
$c) {
232 return array(
$c->getType(),
$c->getNumber());
234 $this->assertContains(array(
"status", $number_s), $vals);
235 $this->assertContains(array(
"novelty", $number_n), $vals);
249 $cf->status($number_s)
252 $cf->novelty($number_n1)
255 $cf->novelty($number_n2)
258 $counters = $g->getCounters();
259 $this->assertCount(2, $counters);
260 $vals = array_map(
function (
$c) {
261 return array(
$c->getType(),
$c->getNumber());
263 $this->assertContains(array(
"status", $number_s), $vals);
264 $this->assertContains(array(
"novelty", $number_n2), $vals);
278 $counters = $g->getCounters();
279 $this->assertCount(0, $counters);
284 $this->expectException(\InvalidArgumentException::class);
285 new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Glyph(
"FOO",
"http://www.ilias.de");
290 return array( array(
G\Glyph::SETTINGS)
291 , array(
G\Glyph::EXPAND)
292 , array(
G\Glyph::COLLAPSE)
293 , array(
G\Glyph::ADD)
294 , array(
G\Glyph::REMOVE)
296 , array(
G\Glyph::DOWN)
297 , array(
G\Glyph::BACK)
298 , array(
G\Glyph::NEXT)
299 , array(
G\Glyph::SORT_ASCENDING)
300 , array(
G\Glyph::SORT_DESCENDING)
301 , array(
G\Glyph::USER)
302 , array(
G\Glyph::MAIL)
303 , array(
G\Glyph::NOTIFICATION)
304 , array(
G\Glyph::TAG)
305 , array(
G\Glyph::NOTE)
306 , array(
G\Glyph::COMMENT)
307 , array(
G\Glyph::LIKE)
308 , array(
G\Glyph::LOVE)
309 , array(
G\Glyph::DISLIKE)
310 , array(
G\Glyph::LAUGH)
311 , array(
G\Glyph::ASTOUNDED)
312 , array(
G\Glyph::SAD)
313 , array(
G\Glyph::ANGRY)
314 , array(
G\Glyph::ATTACHMENT)
315 , array(
G\Glyph::RESET)
316 , array(
G\Glyph::APPLY)
317 , array(
G\Glyph::SEARCH)
318 , array(
G\Glyph::HELP)
319 , array(
G\Glyph::CALENDAR)
320 , array(
G\Glyph::TIME)
321 , array(
G\Glyph::CLOSE)
322 , array(
G\Glyph::MORE)
323 , array(
G\Glyph::DISCLOSURE)
324 , array(
G\Glyph::LANGUAGE)
325 , array(
G\Glyph::LOGIN)
326 , array(
G\Glyph::LOGOUT)
332 return array( array(
"status")
344 $c =
$f->$type(
"http://www.ilias.de");
348 $css_classes = self::$canonical_css_classes[
$type];
349 $aria_label = self::$aria_labels[
$type];
351 $expected =
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
352 $this->assertEquals($expected, $html);
362 $c =
$f->$type(
"http://www.ilias.de")->withUnavailableAction();
366 $css_classes = self::$canonical_css_classes[
$type];
367 $aria_label = self::$aria_labels[
$type];
369 $expected =
"<a class=\"glyph disabled\" aria-label=\"$aria_label\" " .
370 "aria-disabled=\"true\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
371 $this->assertEquals($expected, $html);
382 $c = $fg->mail(
"http://www.ilias.de")->withCounter($fc->$type(42));
386 $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
387 $aria_label = self::$aria_labels[G\Glyph::MAIL];
389 $expected =
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">" .
390 "<span class=\"$css_classes\" aria-hidden=\"true\"></span>" .
391 "<span class=\"il-counter\"><span class=\"badge badge-notify il-counter-$type\">42</span></span>" .
392 "<span class=\"il-counter-spacer\">42</span>" .
402 $c = $fg->mail(
"http://www.ilias.de")
403 ->withCounter($fc->novelty(42))
404 ->withCounter($fc->status(7));
408 $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
409 $aria_label = self::$aria_labels[G\Glyph::MAIL];
410 $expected =
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">" .
411 "<span class=\"$css_classes\" aria-hidden=\"true\"></span>" .
412 "<span class=\"il-counter\"><span class=\"badge badge-notify il-counter-status\">7</span></span>" .
413 "<span class=\"il-counter\"><span class=\"badge badge-notify il-counter-novelty\">42</span></span>" .
414 "<span class=\"il-counter-spacer\">42</span>" .
421 $this->expectException(\LogicException::class);
422 $r = new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Renderer(
431 $r->render(
$f->status(0), $this->getDefaultRenderer());
442 $c =
$f->$type(
"http://www.ilias.de")
443 ->withOnLoadCode(
function ($id) use (&$ids) {
450 $this->assertCount(1, $ids);
452 $css_classes = self::$canonical_css_classes[
$type];
453 $aria_label = self::$aria_labels[
$type];
456 $expected =
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\" id=\"$id\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
457 $this->assertEquals($expected, $html);
467 $c =
$f->$type(
"http://www.ilias.de");
468 $c =
$c->withAction(
"http://www.ilias.de/open-source-lms-ilias/");
472 $css_classes = self::$canonical_css_classes[
$type];
473 $aria_label = self::$aria_labels[
$type];
475 $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>";
476 $this->assertEquals($expected, $html);
An exception for terminatinating execution or to throw for unit testing.
Test on glyph implementation.
test_dont_render_counter()
test_render_with_on_load_code($type)
@dataProvider glyph_type_provider
test_render_simple($type)
@dataProvider glyph_type_provider
test_render_with_unavailable_action($type)
@dataProvider glyph_type_provider
test_with_highlight($counter_type)
@dataProvider counter_type_provider
test_glyph_types($factory_method)
@dataProvider glyph_type_provider
static $canonical_css_classes
test_no_counter($factory_method)
@dataProvider glyph_type_provider
test_render_withTwoCounters()
test_with_unavailable_action($factory_method)
@dataProvider glyph_type_provider
test_render_with_action($type)
@dataProvider glyph_type_provider
test_one_counter($counter_type)
@dataProvider counter_type_provider
test_render_withCounter($type)
@dataProvider counter_type_provider
test_immutability_withCounter()
test_implements_factory_interface($factory_method)
@dataProvider glyph_type_provider
test_glyph_no_action($factory_method)
@dataProvider glyph_type_provider
test_glyph_action($factory_method)
@dataProvider glyph_type_provider
Provides common functionality for UI tests.
assertHTMLEquals($expected_html_as_string, $html_as_string)
getDefaultRenderer(JavaScriptBinding $js_binding=null)