19declare(strict_types=1);
21require_once(
"vendor/composer/vendor/autoload.php");
22require_once(__DIR__ .
"/../../../Base.php");
31use PHPUnit\Framework\Attributes\DataProvider;
42 return new I\Symbol\Glyph\Factory($this->createRelayArgumentLanguageStub());
47 return new I\Counter\Factory();
51 G\Glyph::SETTINGS =>
"glyphicon glyphicon-cog",
52 G\Glyph::EXPAND =>
"glyphicon glyphicon-triangle-right",
53 G\Glyph::COLLAPSE =>
"glyphicon glyphicon-triangle-bottom",
54 G\Glyph::ADD =>
"glyphicon glyphicon-plus-sign",
55 G\Glyph::REMOVE =>
"glyphicon glyphicon-minus-sign",
56 G\Glyph::UP =>
"glyphicon glyphicon-circle-arrow-up",
57 G\Glyph::DOWN =>
"glyphicon glyphicon-circle-arrow-down",
58 G\Glyph::BACK =>
"glyphicon glyphicon-chevron-left",
59 G\Glyph::NEXT =>
"glyphicon glyphicon-chevron-right",
60 G\Glyph::SORT_ASCENDING =>
"glyphicon glyphicon-arrow-up",
61 G\Glyph::SORT_DESCENDING =>
"glyphicon glyphicon-arrow-down",
62 G\Glyph::USER =>
"glyphicon glyphicon-user",
63 G\Glyph::MAIL =>
"glyphicon glyphicon-envelope",
64 G\Glyph::NOTIFICATION =>
"glyphicon glyphicon-bell",
66 G\Glyph::NOTE =>
"glyphicon glyphicon-pushpin",
67 G\Glyph::COMMENT =>
"glyphicon glyphicon-comment",
68 G\Glyph::BRIEFCASE =>
"glyphicon glyphicon-briefcase",
69 G\Glyph::LIKE =>
"glyphicon il-glyphicon-like",
70 G\Glyph::LOVE =>
"glyphicon il-glyphicon-love",
71 G\Glyph::DISLIKE =>
"glyphicon il-glyphicon-dislike",
72 G\Glyph::LAUGH =>
"glyphicon il-glyphicon-laugh",
73 G\Glyph::ASTOUNDED =>
"glyphicon il-glyphicon-astounded",
74 G\Glyph::SAD =>
"glyphicon il-glyphicon-sad",
75 G\Glyph::ANGRY =>
"glyphicon il-glyphicon-angry",
76 G\Glyph::EYEOPEN =>
"glyphicon glyphicon-eye-open",
77 G\Glyph::EYECLOSED =>
"glyphicon glyphicon-eye-close",
78 G\Glyph::ATTACHMENT =>
"glyphicon glyphicon-paperclip",
79 G\Glyph::RESET =>
"glyphicon glyphicon-reset",
80 G\Glyph::APPLY =>
"glyphicon glyphicon-apply",
81 G\Glyph::SEARCH =>
"glyphicon glyphicon-search",
82 G\Glyph::HELP =>
"glyphicon glyphicon-question-sign",
83 G\Glyph::CALENDAR =>
"glyphicon glyphicon-calendar",
84 G\Glyph::TIME =>
"glyphicon glyphicon-time",
85 G\Glyph::CLOSE =>
"glyphicon glyphicon-remove",
86 G\Glyph::MORE =>
"glyphicon glyphicon-option-horizontal",
87 G\Glyph::DISCLOSURE =>
"glyphicon glyphicon-option-vertical",
88 G\Glyph::LANGUAGE =>
"glyphicon glyphicon-lang",
89 G\Glyph::LOGIN =>
"glyphicon glyphicon-login",
90 G\Glyph::LOGOUT =>
"glyphicon glyphicon-logout",
91 G\Glyph::BULLETLIST =>
"glyphicon glyphicon-bulletlist",
92 G\Glyph::NUMBEREDLIST =>
"glyphicon glyphicon-numberedlist",
93 G\Glyph::LISTINDENT =>
"glyphicon glyphicon-listindent",
94 G\Glyph::LISTOUTDENT =>
"glyphicon glyphicon-listoutdent",
95 G\Glyph::FILTER =>
"glyphicon glyphicon-filter",
96 G\Glyph::COLLAPSE_HORIZONTAL =>
"glyphicon glyphicon-triangle-left",
97 G\Glyph::HEADER =>
"glyphicon glyphicon-header",
98 G\Glyph::ITALIC =>
"glyphicon glyphicon-italic",
99 G\Glyph::BOLD =>
"glyphicon glyphicon-bold",
100 G\Glyph::LINK =>
"glyphicon glyphicon-link",
101 G\Glyph::LAUNCH =>
"glyphicon glyphicon-launch",
102 G\Glyph::ENLARGE =>
"glyphicon glyphicon-enlarge",
103 G\Glyph::LIST_VIEW =>
"glyphicon glyphicon-listView",
104 G\Glyph::PREVIEW =>
"glyphicon glyphicon-preview",
105 G\Glyph::SORT =>
"glyphicon glyphicon-sort",
106 G\Glyph::COLUMN_SELECTION =>
"glyphicon glyphicon-columnSelection",
107 G\Glyph::TILE_VIEW =>
"glyphicon glyphicon-tileView",
108 G\Glyph::DRAG_HANDLE =>
"glyphicon glyphicon-dragHandle",
109 G\Glyph::CHECKED =>
"glyphicon glyphicon-checked",
110 G\Glyph::UNCHECKED =>
"glyphicon glyphicon-unchecked",
111 G\Glyph::PRESENTER =>
"glyphicon glyphicon-presenter",
112 G\Glyph::OWNER =>
"glyphicon glyphicon-owner",
113 G\Glyph::DATE =>
"glyphicon glyphicon-date",
114 G\Glyph::LOCATION =>
"glyphicon glyphicon-location",
115 G\Glyph::COPY =>
"glyphicon glyphicon-copy",
117 G\Glyph::SHARE =>
"glyphicon glyphicon-share",
121 G\Glyph::SETTINGS =>
"settings",
122 G\Glyph::EXPAND =>
"expand_content",
123 G\Glyph::COLLAPSE =>
"collapse_content",
124 G\Glyph::ADD =>
"add",
125 G\Glyph::REMOVE =>
"remove",
127 G\Glyph::DOWN =>
"down",
128 G\Glyph::BACK =>
"back",
129 G\Glyph::NEXT =>
"next",
130 G\Glyph::SORT_ASCENDING =>
"sort_ascending",
131 G\Glyph::SORT_DESCENDING =>
"sort_descending",
132 G\Glyph::USER =>
"show_who_is_online",
133 G\Glyph::MAIL =>
"mail",
134 G\Glyph::NOTIFICATION =>
"notifications",
136 G\Glyph::NOTE =>
"notes",
137 G\Glyph::COMMENT =>
"comments",
138 G\Glyph::BRIEFCASE =>
"briefcase",
139 G\Glyph::LIKE =>
"like",
140 G\Glyph::LOVE =>
"love",
141 G\Glyph::DISLIKE =>
"dislike",
142 G\Glyph::LAUGH =>
"laugh",
143 G\Glyph::ASTOUNDED =>
"astounded",
144 G\Glyph::SAD =>
"sad",
145 G\Glyph::ANGRY =>
"angry",
146 G\Glyph::EYEOPEN =>
"eyeopened",
147 G\Glyph::EYECLOSED =>
"eyeclosed",
148 G\Glyph::ATTACHMENT =>
"attachment",
149 G\Glyph::RESET =>
"reset",
150 G\Glyph::APPLY =>
"apply",
151 G\Glyph::SEARCH =>
"search",
152 G\Glyph::HELP =>
"help",
153 G\Glyph::CALENDAR =>
"calendar",
154 G\Glyph::TIME =>
"time",
155 G\Glyph::CLOSE =>
"close",
156 G\Glyph::MORE =>
"show_more",
157 G\Glyph::DISCLOSURE =>
"disclose",
158 G\Glyph::LANGUAGE =>
"switch_language",
159 G\Glyph::LOGIN =>
"log_in",
160 G\Glyph::LOGOUT =>
"log_out",
161 G\Glyph::BULLETLIST =>
"bulletlist_action",
162 G\Glyph::NUMBEREDLIST =>
"numberedlist_action",
163 G\Glyph::LISTINDENT =>
"listindent",
164 G\Glyph::LISTOUTDENT =>
"listoutdent",
165 G\Glyph::FILTER =>
"filter",
166 G\Glyph::COLLAPSE_HORIZONTAL =>
"collapse/back",
167 G\Glyph::HEADER =>
"header_action",
168 G\Glyph::ITALIC =>
"italic_action",
169 G\Glyph::BOLD =>
"bold_action",
170 G\Glyph::LINK =>
"link_action",
171 G\Glyph::LAUNCH =>
"launch",
172 G\Glyph::ENLARGE =>
"enlarge",
173 G\Glyph::LIST_VIEW =>
"list_view",
174 G\Glyph::PREVIEW =>
"preview",
175 G\Glyph::SORT =>
"sort",
176 G\Glyph::COLUMN_SELECTION =>
"column_selection",
177 G\Glyph::TILE_VIEW =>
"tile_view",
178 G\Glyph::DRAG_HANDLE =>
"drag_handle",
179 G\Glyph::CHECKED =>
"checked",
180 G\Glyph::UNCHECKED =>
"unchecked",
181 G\Glyph::PRESENTER =>
"presenter",
182 G\Glyph::OWNER =>
"owner",
183 G\Glyph::DATE =>
"date",
184 G\Glyph::LOCATION =>
"location",
185 G\Glyph::COPY =>
"copy",
187 G\Glyph::SHARE =>
"share",
190 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')]
195 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Glyph\\Factory",
$f);
196 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Glyph\\Glyph",
$f->$factory_method());
199 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')]
203 $g =
$f->$factory_method();
205 $this->assertNotNull($g);
206 $this->assertEquals($factory_method, $g->getType());
209 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')]
213 $g =
$f->$factory_method();
215 $this->assertNotNull($g);
223 $g2 = $g->withHighlight();
225 $this->assertFalse($g->isHighlighted());
226 $this->assertTrue($g2->isHighlighted());
229 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')]
233 $g =
$f->$factory_method();
235 $this->assertCount(0, $g->getCounters());
238 #[\PHPUnit\Framework\Attributes\DataProvider('getCounterTypeProvider')]
248 $cf->$counter_type($number)
251 $counters = $g->getCounters();
252 $this->assertCount(1, $counters);
254 $this->assertEquals($counter_type,
$c->getType());
255 $this->assertEquals($number,
$c->getNumber());
268 $cf->status($number_s)
271 $cf->novelty($number_n)
274 $counters = $g->getCounters();
275 $this->assertCount(2, $counters);
276 $vals = array_map(
function (
$c) {
277 return array(
$c->getType(),
$c->getNumber());
279 $this->assertContains(array(
"status", $number_s), $vals);
280 $this->assertContains(array(
"novelty", $number_n), $vals);
294 $cf->status($number_s)
297 $cf->novelty($number_n1)
300 $cf->novelty($number_n2)
303 $counters = $g->getCounters();
304 $this->assertCount(2, $counters);
305 $vals = array_map(
function (
$c) {
306 return array(
$c->getType(),
$c->getNumber());
308 $this->assertContains(array(
"status", $number_s), $vals);
309 $this->assertContains(array(
"novelty", $number_n2), $vals);
323 $counters = $g->getCounters();
324 $this->assertCount(0, $counters);
329 $this->expectException(InvalidArgumentException::class);
330 new Glyph(
"FOO",
"FAA");
335 $glyph_reflection =
new ReflectionClass(
G\Glyph::class);
336 $constant_values = array_values($glyph_reflection->getConstants());
337 return array_map(
function ($val) {
339 }, $constant_values);
350 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')]
354 $r = $this->getDefaultRenderer();
357 $html = $this->normalizeHTML($r->render(
$c));
359 $css_classes = self::$canonical_css_classes[$type];
360 $aria_label = self::$aria_labels[$type];
362 $expected =
'<span class="glyph" aria-label="' . $aria_label .
'" role="img"><span class="' . $css_classes .
'" aria-hidden="true"></span></span>';
363 $this->assertEquals($expected, $html);
366 #[\PHPUnit\Framework\Attributes\DataProvider('getCounterTypeProvider')]
371 $r = $this->getDefaultRenderer();
372 $c = $fg->mail()->withCounter($fc->$type(42));
374 $html = $this->normalizeHTML($r->render(
$c));
380 <span class="glyph" aria-label="' . $aria_label .
'" role="img">
381 <span class="' . $css_classes .
'" aria-hidden="true"></span>
382 <span class="il-counter"><span class="badge badge-notify il-counter-' . $type .
'">42</span></span>
383 <span class="il-counter-spacer">42</span>
385 $this->assertHTMLEquals($expected, $html);
392 $r = $this->getDefaultRenderer();
394 ->withCounter($fc->novelty(42))
395 ->withCounter($fc->status(7));
397 $html = $this->normalizeHTML($r->render(
$c));
401 $expected =
'<span class="glyph" aria-label="' . $aria_label .
'" role="img">' .
402 '<span class="' . $css_classes .
'" aria-hidden="true"></span>' .
403 '<span class="il-counter"><span class="badge badge-notify il-counter-status">7</span></span>' .
404 '<span class="il-counter"><span class="badge badge-notify il-counter-novelty">42</span></span>' .
405 '<span class="il-counter-spacer">42</span>' .
407 $this->assertHTMLEquals($expected, $html);
412 $this->expectException(\LogicException::class);
415 $this->getTemplateFactory(),
417 $this->getJavaScriptBinding(),
419 $this->createMock(DataFactory::class),
420 $this->createMock(HelpTextRetriever::class),
421 $this->getUploadLimitResolver(),
422 $this->getRefinery(),
426 $r->render(
$f->status(0), $this->getDefaultRenderer());
429 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')]
433 $r = $this->getDefaultRenderer();
436 ->withOnLoadCode(
function (
$id) use (&$ids):
string {
441 $html = $this->normalizeHTML($r->render(
$c));
443 $this->assertCount(1, $ids);
445 $css_classes = self::$canonical_css_classes[$type];
446 $aria_label = self::$aria_labels[$type];
449 $expected =
'<span class="glyph" aria-label="' . $aria_label .
'" role="img" id="' .
$id .
'"><span class="' . $css_classes .
'" aria-hidden="true"></span></span>';
450 $this->assertEquals($expected, $html);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Test on glyph implementation.
testGlyphTypes(string $factory_method)
testGlyphNoAction(string $factory_method)
testNoCounter(string $factory_method)
testRenderWithTwoCounters()
testImplementsFactoryInterface(string $factory_method)
static getCounterTypeProvider()
static array $canonical_css_classes
testRenderWithOnLoadCode(string $type)
testOneCounter(string $counter_type)
testRenderSimple(string $type)
testRenderWithCounter(string $type)
testImmutabilityWithCounter()
static array $aria_labels
static getGlyphTypeProvider()
Provides common functionality for UI tests.
This describes a facility that the UI framework can use to retrieve some help text.
@ QR_CODE
Transfer information by copying its contents to the computers clipboard.