19declare(strict_types=1);
21require_once(
"vendor/composer/vendor/autoload.php");
22require_once(__DIR__ .
"/../../../Base.php");
31use PHPUnit\Framework\Attributes\DataProvider;
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);
207 $g2 = $g->withHighlight();
209 $this->assertFalse($g->isHighlighted());
210 $this->assertTrue($g2->isHighlighted());
213 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')]
217 $g =
$f->$factory_method();
219 $this->assertCount(0, $g->getCounters());
222 #[\PHPUnit\Framework\Attributes\DataProvider('getCounterTypeProvider')]
232 $cf->$counter_type($number)
235 $counters = $g->getCounters();
236 $this->assertCount(1, $counters);
238 $this->assertEquals($counter_type,
$c->getType());
239 $this->assertEquals($number,
$c->getNumber());
252 $cf->status($number_s)
255 $cf->novelty($number_n)
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_n), $vals);
278 $cf->status($number_s)
281 $cf->novelty($number_n1)
284 $cf->novelty($number_n2)
287 $counters = $g->getCounters();
288 $this->assertCount(2, $counters);
289 $vals = array_map(
function (
$c) {
290 return array(
$c->getType(),
$c->getNumber());
292 $this->assertContains(array(
"status", $number_s), $vals);
293 $this->assertContains(array(
"novelty", $number_n2), $vals);
307 $counters = $g->getCounters();
308 $this->assertCount(0, $counters);
313 $this->expectException(InvalidArgumentException::class);
314 new Glyph(
"FOO",
"FAA");
319 $glyph_reflection =
new ReflectionClass(
G\Glyph::class);
320 $constant_values = array_values($glyph_reflection->getConstants());
321 return array_map(
function ($val) {
323 }, $constant_values);
334 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')]
338 $r = $this->getDefaultRenderer();
341 $html = $this->normalizeHTML($r->render(
$c));
343 $css_classes = self::$canonical_css_classes[$type];
344 $aria_label = self::$aria_labels[$type];
346 $expected =
'<span class="glyph" aria-label="' . $aria_label .
'" role="img"><span class="' . $css_classes .
'" aria-hidden="true"></span></span>';
347 $this->assertEquals($expected, $html);
350 #[\PHPUnit\Framework\Attributes\DataProvider('getCounterTypeProvider')]
355 $r = $this->getDefaultRenderer();
356 $c = $fg->mail()->withCounter($fc->$type(42));
358 $html = $this->normalizeHTML($r->render(
$c));
364 <span class="glyph" aria-label="' . $aria_label .
'" role="img">
365 <span class="' . $css_classes .
'" aria-hidden="true"></span>
366 <span class="il-counter"><span class="badge badge-notify il-counter-' . $type .
'">42</span></span>
367 <span class="il-counter-spacer">42</span>
369 $this->assertHTMLEquals($expected, $html);
376 $r = $this->getDefaultRenderer();
378 ->withCounter($fc->novelty(42))
379 ->withCounter($fc->status(7));
381 $html = $this->normalizeHTML($r->render(
$c));
385 $expected =
'<span class="glyph" aria-label="' . $aria_label .
'" role="img">' .
386 '<span class="' . $css_classes .
'" aria-hidden="true"></span>' .
387 '<span class="il-counter"><span class="badge badge-notify il-counter-status">7</span></span>' .
388 '<span class="il-counter"><span class="badge badge-notify il-counter-novelty">42</span></span>' .
389 '<span class="il-counter-spacer">42</span>' .
391 $this->assertHTMLEquals($expected, $html);
396 $this->expectException(\LogicException::class);
398 $this->getUIFactory(),
399 $this->getTemplateFactory(),
401 $this->getJavaScriptBinding(),
403 $this->createMock(DataFactory::class),
404 $this->createMock(HelpTextRetriever::class),
405 $this->getUploadLimitResolver()
409 $r->render(
$f->status(0), $this->getDefaultRenderer());
412 #[\PHPUnit\Framework\Attributes\DataProvider('getGlyphTypeProvider')]
416 $r = $this->getDefaultRenderer();
419 ->withOnLoadCode(
function (
$id) use (&$ids):
string {
424 $html = $this->normalizeHTML($r->render(
$c));
426 $this->assertCount(1, $ids);
428 $css_classes = self::$canonical_css_classes[$type];
429 $aria_label = self::$aria_labels[$type];
432 $expected =
'<span class="glyph" aria-label="' . $aria_label .
'" role="img" id="' .
$id .
'"><span class="' . $css_classes .
'" aria-hidden="true"></span></span>';
433 $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.