19 declare(strict_types=1);
21 require_once(
"vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../../Base.php");
40 return new I\Symbol\Glyph\Factory();
45 return new I\Counter\Factory();
49 G\Glyph::SETTINGS =>
"glyphicon glyphicon-cog",
50 G\Glyph::EXPAND =>
"glyphicon glyphicon-triangle-right",
51 G\Glyph::COLLAPSE =>
"glyphicon glyphicon-triangle-bottom",
52 G\Glyph::ADD =>
"glyphicon glyphicon-plus-sign",
53 G\Glyph::REMOVE =>
"glyphicon glyphicon-minus-sign",
54 G\Glyph::UP =>
"glyphicon glyphicon-circle-arrow-up",
55 G\Glyph::DOWN =>
"glyphicon glyphicon-circle-arrow-down",
56 G\Glyph::BACK =>
"glyphicon glyphicon-chevron-left",
57 G\Glyph::NEXT =>
"glyphicon glyphicon-chevron-right",
58 G\Glyph::SORT_ASCENDING =>
"glyphicon glyphicon-arrow-up",
59 G\Glyph::SORT_DESCENDING =>
"glyphicon glyphicon-arrow-down",
61 G\Glyph::MAIL =>
"glyphicon glyphicon-envelope",
62 G\Glyph::NOTIFICATION =>
"glyphicon glyphicon-bell",
64 G\Glyph::NOTE =>
"glyphicon glyphicon-pushpin",
65 G\Glyph::COMMENT =>
"glyphicon glyphicon-comment",
66 G\Glyph::BRIEFCASE =>
"glyphicon glyphicon-briefcase",
67 G\Glyph::LIKE =>
"glyphicon il-glyphicon-like",
68 G\Glyph::LOVE =>
"glyphicon il-glyphicon-love",
69 G\Glyph::DISLIKE =>
"glyphicon il-glyphicon-dislike",
70 G\Glyph::LAUGH =>
"glyphicon il-glyphicon-laugh",
71 G\Glyph::ASTOUNDED =>
"glyphicon il-glyphicon-astounded",
72 G\Glyph::SAD =>
"glyphicon il-glyphicon-sad",
73 G\Glyph::ANGRY =>
"glyphicon il-glyphicon-angry",
74 G\Glyph::EYEOPEN =>
"glyphicon glyphicon-eye-open",
75 G\Glyph::EYECLOSED =>
"glyphicon glyphicon-eye-close",
76 G\Glyph::ATTACHMENT =>
"glyphicon glyphicon-paperclip",
77 G\Glyph::RESET =>
"glyphicon glyphicon-reset",
78 G\Glyph::APPLY =>
"glyphicon glyphicon-apply",
79 G\Glyph::SEARCH =>
"glyphicon glyphicon-search",
80 G\Glyph::HELP =>
"glyphicon glyphicon-question-sign",
81 G\Glyph::CALENDAR =>
"glyphicon glyphicon-calendar",
82 G\Glyph::TIME =>
"glyphicon glyphicon-time",
83 G\Glyph::CLOSE =>
"glyphicon glyphicon-remove",
84 G\Glyph::MORE =>
"glyphicon glyphicon-option-horizontal",
85 G\Glyph::DISCLOSURE =>
"glyphicon glyphicon-option-vertical",
86 G\Glyph::LANGUAGE =>
"glyphicon glyphicon-lang",
87 G\Glyph::LOGIN =>
"glyphicon glyphicon-login",
88 G\Glyph::LOGOUT =>
"glyphicon glyphicon-logout",
89 G\Glyph::BULLETLIST =>
"glyphicon glyphicon-bulletlist",
90 G\Glyph::NUMBEREDLIST =>
"glyphicon glyphicon-numberedlist",
91 G\Glyph::LISTINDENT =>
"glyphicon glyphicon-listindent",
92 G\Glyph::LISTOUTDENT =>
"glyphicon glyphicon-listoutdent",
93 G\Glyph::FILTER =>
"glyphicon glyphicon-filter",
94 G\Glyph::COLLAPSE_HORIZONTAL =>
"glyphicon glyphicon-triangle-left",
95 G\Glyph::HEADER =>
"glyphicon glyphicon-header",
96 G\Glyph::ITALIC =>
"glyphicon glyphicon-italic",
97 G\Glyph::BOLD =>
"glyphicon glyphicon-bold",
98 G\Glyph::LINK =>
"glyphicon glyphicon-link",
99 G\Glyph::LAUNCH =>
"glyphicon glyphicon-launch",
100 G\Glyph::ENLARGE =>
"glyphicon glyphicon-enlarge",
101 G\Glyph::LIST_VIEW =>
"glyphicon glyphicon-listView",
102 G\Glyph::PREVIEW =>
"glyphicon glyphicon-preview",
103 G\Glyph::SORT =>
"glyphicon glyphicon-sort",
104 G\Glyph::COLUMN_SELECTION =>
"glyphicon glyphicon-columnSelection",
105 G\Glyph::TILE_VIEW =>
"glyphicon glyphicon-tileView",
106 G\Glyph::DRAG_HANDLE =>
"glyphicon glyphicon-dragHandle",
107 G\Glyph::CHECKED =>
"glyphicon glyphicon-checked",
108 G\Glyph::UNCHECKED =>
"glyphicon glyphicon-unchecked",
112 G\Glyph::SETTINGS =>
"settings",
113 G\Glyph::EXPAND =>
"expand_content",
114 G\Glyph::COLLAPSE =>
"collapse_content",
115 G\Glyph::ADD =>
"add",
116 G\Glyph::REMOVE =>
"remove",
118 G\Glyph::DOWN =>
"down",
119 G\Glyph::BACK =>
"back",
120 G\Glyph::NEXT =>
"next",
121 G\Glyph::SORT_ASCENDING =>
"sort_ascending",
122 G\Glyph::SORT_DESCENDING =>
"sort_descending",
124 G\Glyph::MAIL =>
"mail",
125 G\Glyph::NOTIFICATION =>
"notifications",
127 G\Glyph::NOTE =>
"notes",
128 G\Glyph::COMMENT =>
"comments",
129 G\Glyph::BRIEFCASE =>
"briefcase",
130 G\Glyph::LIKE =>
"like",
131 G\Glyph::LOVE =>
"love",
132 G\Glyph::DISLIKE =>
"dislike",
133 G\Glyph::LAUGH =>
"laugh",
134 G\Glyph::ASTOUNDED =>
"astounded",
135 G\Glyph::SAD =>
"sad",
136 G\Glyph::ANGRY =>
"angry",
137 G\Glyph::EYEOPEN =>
"eyeopened",
138 G\Glyph::EYECLOSED =>
"eyeclosed",
139 G\Glyph::ATTACHMENT =>
"attachment",
140 G\Glyph::RESET =>
"reset",
141 G\Glyph::APPLY =>
"apply",
142 G\Glyph::SEARCH =>
"search",
143 G\Glyph::HELP =>
"help",
144 G\Glyph::CALENDAR =>
"calendar",
145 G\Glyph::TIME =>
"time",
146 G\Glyph::CLOSE =>
"close",
147 G\Glyph::MORE =>
"show_more",
148 G\Glyph::DISCLOSURE =>
"disclose",
149 G\Glyph::LANGUAGE =>
"switch_language",
150 G\Glyph::LOGIN =>
"log_in",
151 G\Glyph::LOGOUT =>
"log_out",
152 G\Glyph::BULLETLIST =>
"bulletlist_action",
153 G\Glyph::NUMBEREDLIST =>
"numberedlist_action",
154 G\Glyph::LISTINDENT =>
"listindent",
155 G\Glyph::LISTOUTDENT =>
"listoutdent",
156 G\Glyph::FILTER =>
"filter",
157 G\Glyph::COLLAPSE_HORIZONTAL =>
"collapse/back",
158 G\Glyph::HEADER =>
"header_action",
159 G\Glyph::ITALIC =>
"italic_action",
160 G\Glyph::BOLD =>
"bold_action",
161 G\Glyph::LINK =>
"link_action",
162 G\Glyph::LAUNCH =>
"launch",
163 G\Glyph::ENLARGE =>
"enlarge",
164 G\Glyph::LIST_VIEW =>
"list_view",
165 G\Glyph::PREVIEW =>
"preview",
166 G\Glyph::SORT =>
"sort",
167 G\Glyph::COLUMN_SELECTION =>
"column_selection",
168 G\Glyph::TILE_VIEW =>
"tile_view",
169 G\Glyph::DRAG_HANDLE =>
"drag_handle",
170 G\Glyph::CHECKED =>
"checked",
171 G\Glyph::UNCHECKED =>
"unchecked",
174 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')] 179 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Glyph\\Factory",
$f);
180 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Glyph\\Glyph",
$f->$factory_method());
183 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')] 187 $g =
$f->$factory_method();
189 $this->assertNotNull($g);
190 $this->assertEquals($factory_method, $g->getType());
193 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')] 197 $g =
$f->$factory_method();
199 $this->assertNotNull($g);
200 $this->assertEquals(
null, $g->getAction());
203 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')] 207 $g =
$f->$factory_method();
208 $g2 =
$f->$factory_method()->withUnavailableAction();
210 $this->assertTrue($g->isActive());
211 $this->assertFalse($g2->isActive());
219 $g2 = $g->withHighlight();
221 $this->assertFalse($g->isHighlighted());
222 $this->assertTrue($g2->isHighlighted());
225 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')] 229 $g =
$f->$factory_method();
231 $this->assertCount(0, $g->getCounters());
234 #[\PHPUnit\Framework\Attributes\DataProvider('getCounterTypeProvider')] 244 $cf->$counter_type($number)
247 $counters = $g->getCounters();
248 $this->assertCount(1, $counters);
250 $this->assertEquals($counter_type,
$c->getType());
251 $this->assertEquals($number,
$c->getNumber());
264 $cf->status($number_s)
267 $cf->novelty($number_n)
270 $counters = $g->getCounters();
271 $this->assertCount(2, $counters);
273 return array(
$c->getType(),
$c->getNumber());
275 $this->assertContains(array(
"status", $number_s), $vals);
276 $this->assertContains(array(
"novelty", $number_n), $vals);
290 $cf->status($number_s)
293 $cf->novelty($number_n1)
296 $cf->novelty($number_n2)
299 $counters = $g->getCounters();
300 $this->assertCount(2, $counters);
302 return array(
$c->getType(),
$c->getNumber());
304 $this->assertContains(array(
"status", $number_s), $vals);
305 $this->assertContains(array(
"novelty", $number_n2), $vals);
319 $counters = $g->getCounters();
320 $this->assertCount(0, $counters);
325 $this->expectException(InvalidArgumentException::class);
326 new Glyph(
"FOO",
"FAA");
332 $constant_values = array_values($glyph_reflection->getConstants());
335 }, $constant_values);
346 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')] 350 $r = $this->getDefaultRenderer();
353 $html = $this->normalizeHTML(
$r->render(
$c));
355 $css_classes = self::$canonical_css_classes[$type];
356 $aria_label = self::$aria_labels[$type];
358 $expected =
'<a class="glyph" aria-label="' . $aria_label .
'"><span class="' . $css_classes .
'" aria-hidden="true"></span></a>';
359 $this->assertEquals($expected, $html);
362 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')] 366 $r = $this->getDefaultRenderer();
367 $c =
$f->$type()->withUnavailableAction();
369 $html = $this->normalizeHTML(
$r->render(
$c));
371 $css_classes = self::$canonical_css_classes[$type];
372 $aria_label = self::$aria_labels[$type];
375 <a class="glyph disabled" aria-label="' . $aria_label .
'" aria-disabled="true"> 376 <span class="' . $css_classes .
'" aria-hidden="true"></span> 378 $this->assertEquals($this->brutallyTrimHTML($expected), $this->brutallyTrimHTML($html));
381 #[\PHPUnit\Framework\Attributes\DataProvider('getCounterTypeProvider')] 386 $r = $this->getDefaultRenderer();
387 $c = $fg->mail()->withCounter($fc->$type(42));
389 $html = $this->normalizeHTML(
$r->render(
$c));
391 $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
392 $aria_label = self::$aria_labels[G\Glyph::MAIL];
395 <a class="glyph" aria-label="' . $aria_label .
'"> 396 <span class="' . $css_classes .
'" aria-hidden="true"></span> 397 <span class="il-counter"><span class="badge badge-notify il-counter-' . $type .
'">42</span></span> 398 <span class="il-counter-spacer">42</span> 400 $this->assertHTMLEquals($expected, $html);
407 $r = $this->getDefaultRenderer();
409 ->withCounter($fc->novelty(42))
410 ->withCounter($fc->status(7));
412 $html = $this->normalizeHTML(
$r->render(
$c));
414 $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
415 $aria_label = self::$aria_labels[G\Glyph::MAIL];
416 $expected =
'<a class="glyph" aria-label="' . $aria_label .
'">' .
417 '<span class="' . $css_classes .
'" aria-hidden="true"></span>' .
418 '<span class="il-counter"><span class="badge badge-notify il-counter-status">7</span></span>' .
419 '<span class="il-counter"><span class="badge badge-notify il-counter-novelty">42</span></span>' .
420 '<span class="il-counter-spacer">42</span>' .
422 $this->assertHTMLEquals($expected, $html);
427 $this->expectException(\LogicException::class);
429 $this->getUIFactory(),
430 $this->getTemplateFactory(),
432 $this->getJavaScriptBinding(),
434 $this->createMock(DataFactory::class),
435 $this->createMock(HelpTextRetriever::class),
436 $this->getUploadLimitResolver()
440 $r->render(
$f->status(0), $this->getDefaultRenderer());
443 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')] 447 $r = $this->getDefaultRenderer();
450 ->withOnLoadCode(
function (
$id) use (&$ids):
string {
455 $html = $this->normalizeHTML(
$r->render(
$c));
457 $this->assertCount(1, $ids);
459 $css_classes = self::$canonical_css_classes[$type];
460 $aria_label = self::$aria_labels[$type];
463 $expected =
'<a class="glyph" aria-label="' . $aria_label .
'" id="' .
$id .
'"><span class="' . $css_classes .
'" aria-hidden="true"></span></a>';
464 $this->assertEquals($expected, $html);
static array $canonical_css_classes
testOneCounter(string $counter_type)
static array $aria_labels
testRenderWithTwoCounters()
testRenderWithCounter(string $type)
testGlyphTypes(string $factory_method)
testImmutabilityWithCounter()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getGlyphTypeProvider()
testRenderWithOnLoadCode(string $type)
testRenderSimple(string $type)
testImplementsFactoryInterface(string $factory_method)
testWithUnavailableAction(string $factory_method)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
testRenderWithUnavailableAction(string $type)
testGlyphNoAction(string $factory_method)
testNoCounter(string $factory_method)
static getCounterTypeProvider()
Test on glyph implementation.