ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
GlyphTest Class Reference

Test on glyph implementation. More...

+ Inheritance diagram for GlyphTest:
+ Collaboration diagram for GlyphTest:

Public Member Functions

 getGlyphFactory ()
 
 getCounterFactory ()
 
 test_implements_factory_interface ($factory_method)
 glyph_type_provider More...
 
 test_glyph_types ($factory_method)
 glyph_type_provider More...
 
 test_glyph_action ($factory_method)
 glyph_type_provider More...
 
 test_glyph_no_action ($factory_method)
 glyph_type_provider More...
 
 test_with_unavailable_action ($factory_method)
 glyph_type_provider More...
 
 test_with_highlight ($counter_type)
 counter_type_provider More...
 
 test_no_counter ($factory_method)
 glyph_type_provider More...
 
 test_one_counter ($counter_type)
 counter_type_provider More...
 
 test_two_counters ()
 
 test_only_two_counters ()
 
 test_immutability_withCounter ()
 
 test_known_glyphs_only ()
 
 glyph_type_provider ()
 
 counter_type_provider ()
 
 test_render_simple ($type)
 glyph_type_provider More...
 
 test_render_with_unavailable_action ($type)
 glyph_type_provider More...
 
 test_render_withCounter ($type)
 counter_type_provider More...
 
 test_render_withTwoCounters ()
 
 test_dont_render_counter ()
 
 test_render_with_on_load_code ($type)
 glyph_type_provider More...
 
 test_render_with_action ($type)
 glyph_type_provider More...
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Static Public Attributes

static $canonical_css_classes
 
static $aria_labels
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Test on glyph implementation.

Definition at line 13 of file GlyphTest.php.

Member Function Documentation

◆ counter_type_provider()

GlyphTest::counter_type_provider ( )

Definition at line 312 of file GlyphTest.php.

313  {
314  return array( array("status")
315  , array("novelty")
316  );
317  }

◆ getCounterFactory()

GlyphTest::getCounterFactory ( )

Definition at line 20 of file GlyphTest.php.

Referenced by test_dont_render_counter(), test_immutability_withCounter(), test_one_counter(), test_only_two_counters(), test_render_withCounter(), test_render_withTwoCounters(), and test_two_counters().

21  {
22  return new \ILIAS\UI\Implementation\Component\Counter\Factory();
23  }
+ Here is the caller graph for this function:

◆ getGlyphFactory()

◆ glyph_type_provider()

GlyphTest::glyph_type_provider ( )

Definition at line 303 of file GlyphTest.php.

304  {
305  $glyph_reflection = new ReflectionClass(G\Glyph::class);
306  $constant_values = array_values($glyph_reflection->getConstants());
307  return array_map(function ($val) {
308  return [$val];
309  }, $constant_values);
310  }

◆ test_dont_render_counter()

GlyphTest::test_dont_render_counter ( )

Definition at line 401 of file GlyphTest.php.

References Vendor\Package\$f, getCounterFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), ILIAS_UI_TestBase\getJavaScriptBinding(), ILIAS_UI_TestBase\getLanguage(), ILIAS_UI_TestBase\getRefinery(), ILIAS_UI_TestBase\getTemplateFactory(), and ILIAS_UI_TestBase\getUIFactory().

402  {
403  $this->expectException(\LogicException::class);
404  $r = new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Renderer(
405  $this->getUIFactory(),
406  $this->getTemplateFactory(),
407  $this->getLanguage(),
408  $this->getJavaScriptBinding(),
409  $this->getRefinery(),
410  new ilImagePathResolver()
411  );
412  $f = $this->getCounterFactory();
413 
414  $r->render($f->status(0), $this->getDefaultRenderer());
415  }
getJavaScriptBinding()
Definition: Base.php:294
getCounterFactory()
Definition: GlyphTest.php:20
getTemplateFactory()
Definition: Base.php:279
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_glyph_action()

GlyphTest::test_glyph_action (   $factory_method)

glyph_type_provider

Definition at line 147 of file GlyphTest.php.

References Vendor\Package\$f, and getGlyphFactory().

148  {
149  $f = $this->getGlyphFactory();
150  $g = $f->$factory_method("http://www.ilias.de");
151 
152  $this->assertNotNull($g);
153  $this->assertEquals("http://www.ilias.de", $g->getAction());
154  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_glyph_no_action()

GlyphTest::test_glyph_no_action (   $factory_method)

glyph_type_provider

Definition at line 159 of file GlyphTest.php.

References Vendor\Package\$f, and getGlyphFactory().

160  {
161  $f = $this->getGlyphFactory();
162  $g = $f->$factory_method();
163 
164  $this->assertNotNull($g);
165  $this->assertEquals(null, $g->getAction());
166  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_glyph_types()

GlyphTest::test_glyph_types (   $factory_method)

glyph_type_provider

Definition at line 135 of file GlyphTest.php.

References Vendor\Package\$f, and getGlyphFactory().

136  {
137  $f = $this->getGlyphFactory();
138  $g = $f->$factory_method();
139 
140  $this->assertNotNull($g);
141  $this->assertEquals($factory_method, $g->getType());
142  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_immutability_withCounter()

GlyphTest::test_immutability_withCounter ( )

Definition at line 282 of file GlyphTest.php.

References getCounterFactory(), and getGlyphFactory().

283  {
284  $gf = $this->getGlyphFactory();
285  $cf = $this->getCounterFactory();
286 
287  $g = $gf->mail();
288  $g2 = $g
289  ->withCounter(
290  $cf->novelty(0)
291  );
292 
293  $counters = $g->getCounters();
294  $this->assertCount(0, $counters);
295  }
getCounterFactory()
Definition: GlyphTest.php:20
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_implements_factory_interface()

GlyphTest::test_implements_factory_interface (   $factory_method)

glyph_type_provider

Definition at line 124 of file GlyphTest.php.

References Vendor\Package\$f, and getGlyphFactory().

125  {
126  $f = $this->getGlyphFactory();
127 
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"));
130  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_known_glyphs_only()

GlyphTest::test_known_glyphs_only ( )

Definition at line 297 of file GlyphTest.php.

298  {
299  $this->expectException(\InvalidArgumentException::class);
300  new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Glyph("FOO", "http://www.ilias.de");
301  }

◆ test_no_counter()

GlyphTest::test_no_counter (   $factory_method)

glyph_type_provider

Definition at line 198 of file GlyphTest.php.

References Vendor\Package\$f, and getGlyphFactory().

199  {
200  $f = $this->getGlyphFactory();
201  $g = $f->$factory_method();
202 
203  $this->assertCount(0, $g->getCounters());
204  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_one_counter()

GlyphTest::test_one_counter (   $counter_type)

counter_type_provider

Definition at line 209 of file GlyphTest.php.

References $c, getCounterFactory(), and getGlyphFactory().

210  {
211  $gf = $this->getGlyphFactory();
212  $cf = $this->getCounterFactory();
213  $number = 1;
214 
215  $g = $gf
216  ->mail()
217  ->withCounter(
218  $cf->$counter_type($number)
219  );
220 
221  $counters = $g->getCounters();
222  $this->assertCount(1, $counters);
223  $c = $counters[0];
224  $this->assertEquals($counter_type, $c->getType());
225  $this->assertEquals($number, $c->getNumber());
226  }
$c
Definition: cli.php:37
getCounterFactory()
Definition: GlyphTest.php:20
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_only_two_counters()

GlyphTest::test_only_two_counters ( )

Definition at line 253 of file GlyphTest.php.

References $c, getCounterFactory(), and getGlyphFactory().

254  {
255  $gf = $this->getGlyphFactory();
256  $cf = $this->getCounterFactory();
257  $number_s = 1;
258  $number_n1 = 2;
259  $number_n2 = 2;
260 
261  $g = $gf
262  ->mail()
263  ->withCounter(
264  $cf->status($number_s)
265  )
266  ->withCounter(
267  $cf->novelty($number_n1)
268  )
269  ->withCounter(
270  $cf->novelty($number_n2)
271  );
272 
273  $counters = $g->getCounters();
274  $this->assertCount(2, $counters);
275  $vals = array_map(function ($c) {
276  return array($c->getType(), $c->getNumber());
277  }, $counters);
278  $this->assertContains(array("status", $number_s), $vals);
279  $this->assertContains(array("novelty", $number_n2), $vals);
280  }
$c
Definition: cli.php:37
getCounterFactory()
Definition: GlyphTest.php:20
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_render_simple()

GlyphTest::test_render_simple (   $type)

glyph_type_provider

Definition at line 322 of file GlyphTest.php.

References $c, Vendor\Package\$f, $type, ILIAS_UI_TestBase\getDefaultRenderer(), getGlyphFactory(), and ILIAS_UI_TestBase\normalizeHTML().

323  {
324  $f = $this->getGlyphFactory();
325  $r = $this->getDefaultRenderer();
326  $c = $f->$type("http://www.ilias.de");
327 
328  $html = $this->normalizeHTML($r->render($c));
329 
330  $css_classes = self::$canonical_css_classes[$type];
331  $aria_label = self::$aria_labels[$type];
332 
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);
335  }
$c
Definition: cli.php:37
$type
normalizeHTML($html)
Definition: Base.php:363
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_render_with_action()

GlyphTest::test_render_with_action (   $type)

glyph_type_provider

Definition at line 446 of file GlyphTest.php.

References $c, Vendor\Package\$f, $type, ILIAS_UI_TestBase\getDefaultRenderer(), getGlyphFactory(), and ILIAS_UI_TestBase\normalizeHTML().

447  {
448  $f = $this->getGlyphFactory();
449  $r = $this->getDefaultRenderer();
450  $c = $f->$type("http://www.ilias.de");
451  $c = $c->withAction("http://www.ilias.de/open-source-lms-ilias/");
452 
453  $html = $this->normalizeHTML($r->render($c));
454 
455  $css_classes = self::$canonical_css_classes[$type];
456  $aria_label = self::$aria_labels[$type];
457 
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);
460  }
$c
Definition: cli.php:37
$type
normalizeHTML($html)
Definition: Base.php:363
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_render_with_on_load_code()

GlyphTest::test_render_with_on_load_code (   $type)

glyph_type_provider

Definition at line 420 of file GlyphTest.php.

References $c, Vendor\Package\$f, $type, ILIAS_UI_TestBase\getDefaultRenderer(), getGlyphFactory(), and ILIAS_UI_TestBase\normalizeHTML().

421  {
422  $f = $this->getGlyphFactory();
423  $r = $this->getDefaultRenderer();
424  $ids = array();
425  $c = $f->$type("http://www.ilias.de")
426  ->withOnLoadCode(function ($id) use (&$ids) {
427  $ids[] = $id;
428  return "";
429  });
430 
431  $html = $this->normalizeHTML($r->render($c));
432 
433  $this->assertCount(1, $ids);
434 
435  $css_classes = self::$canonical_css_classes[$type];
436  $aria_label = self::$aria_labels[$type];
437 
438  $id = $ids[0];
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);
441  }
$c
Definition: cli.php:37
$type
normalizeHTML($html)
Definition: Base.php:363
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_render_with_unavailable_action()

GlyphTest::test_render_with_unavailable_action (   $type)

glyph_type_provider

Definition at line 340 of file GlyphTest.php.

References $c, Vendor\Package\$f, $type, ILIAS_UI_TestBase\getDefaultRenderer(), getGlyphFactory(), and ILIAS_UI_TestBase\normalizeHTML().

341  {
342  $f = $this->getGlyphFactory();
343  $r = $this->getDefaultRenderer();
344  $c = $f->$type("http://www.ilias.de")->withUnavailableAction();
345 
346  $html = $this->normalizeHTML($r->render($c));
347 
348  $css_classes = self::$canonical_css_classes[$type];
349  $aria_label = self::$aria_labels[$type];
350 
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);
354  }
$c
Definition: cli.php:37
$type
normalizeHTML($html)
Definition: Base.php:363
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_render_withCounter()

GlyphTest::test_render_withCounter (   $type)

counter_type_provider

Definition at line 359 of file GlyphTest.php.

References $c, ILIAS_UI_TestBase\assertHTMLEquals(), getCounterFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), getGlyphFactory(), ILIAS\UI\Component\Symbol\Glyph\Glyph\MAIL, and ILIAS_UI_TestBase\normalizeHTML().

360  {
361  $fg = $this->getGlyphFactory();
362  $fc = $this->getCounterFactory();
363  $r = $this->getDefaultRenderer();
364  $c = $fg->mail("http://www.ilias.de")->withCounter($fc->$type(42));
365 
366  $html = $this->normalizeHTML($r->render($c));
367 
368  $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
369  $aria_label = self::$aria_labels[G\Glyph::MAIL];
370 
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>" .
375  "</a>";
376  $this->assertHTMLEquals($expected, $html);
377  }
$c
Definition: cli.php:37
normalizeHTML($html)
Definition: Base.php:363
getCounterFactory()
Definition: GlyphTest.php:20
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_render_withTwoCounters()

GlyphTest::test_render_withTwoCounters ( )

Definition at line 379 of file GlyphTest.php.

References $c, ILIAS_UI_TestBase\assertHTMLEquals(), getCounterFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), getGlyphFactory(), ILIAS\UI\Component\Symbol\Glyph\Glyph\MAIL, and ILIAS_UI_TestBase\normalizeHTML().

380  {
381  $fg = $this->getGlyphFactory();
382  $fc = $this->getCounterFactory();
383  $r = $this->getDefaultRenderer();
384  $c = $fg->mail("http://www.ilias.de")
385  ->withCounter($fc->novelty(42))
386  ->withCounter($fc->status(7));
387 
388  $html = $this->normalizeHTML($r->render($c));
389 
390  $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
391  $aria_label = self::$aria_labels[G\Glyph::MAIL];
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>" .
397  "</a>";
398  $this->assertHTMLEquals($expected, $html);
399  }
$c
Definition: cli.php:37
normalizeHTML($html)
Definition: Base.php:363
getCounterFactory()
Definition: GlyphTest.php:20
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_two_counters()

GlyphTest::test_two_counters ( )

Definition at line 228 of file GlyphTest.php.

References $c, getCounterFactory(), and getGlyphFactory().

229  {
230  $gf = $this->getGlyphFactory();
231  $cf = $this->getCounterFactory();
232  $number_s = 1;
233  $number_n = 2;
234 
235  $g = $gf
236  ->mail()
237  ->withCounter(
238  $cf->status($number_s)
239  )
240  ->withCounter(
241  $cf->novelty($number_n)
242  );
243 
244  $counters = $g->getCounters();
245  $this->assertCount(2, $counters);
246  $vals = array_map(function ($c) {
247  return array($c->getType(), $c->getNumber());
248  }, $counters);
249  $this->assertContains(array("status", $number_s), $vals);
250  $this->assertContains(array("novelty", $number_n), $vals);
251  }
$c
Definition: cli.php:37
getCounterFactory()
Definition: GlyphTest.php:20
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_with_highlight()

GlyphTest::test_with_highlight (   $counter_type)

counter_type_provider

Definition at line 184 of file GlyphTest.php.

References getGlyphFactory().

185  {
186  $gf = $this->getGlyphFactory();
187 
188  $g = $gf->mail();
189  $g2 = $g->withHighlight();
190 
191  $this->assertFalse($g->isHighlighted());
192  $this->assertTrue($g2->isHighlighted());
193  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_with_unavailable_action()

GlyphTest::test_with_unavailable_action (   $factory_method)

glyph_type_provider

Definition at line 171 of file GlyphTest.php.

References Vendor\Package\$f, and getGlyphFactory().

172  {
173  $f = $this->getGlyphFactory();
174  $g = $f->$factory_method();
175  $g2 = $f->$factory_method()->withUnavailableAction();
176 
177  $this->assertTrue($g->isActive());
178  $this->assertFalse($g2->isActive());
179  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

Field Documentation

◆ $aria_labels

GlyphTest::$aria_labels
static

Definition at line 73 of file GlyphTest.php.

◆ $canonical_css_classes

GlyphTest::$canonical_css_classes
static

Definition at line 25 of file GlyphTest.php.


The documentation for this class was generated from the following file: