ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 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 330 of file GlyphTest.php.

331  {
332  return array( array("status")
333  , array("novelty")
334  );
335  }

◆ 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 288 of file GlyphTest.php.

289  {
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)
295  , array(G\Glyph::UP)
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)
327  );
328  }

◆ test_dont_render_counter()

GlyphTest::test_dont_render_counter ( )

Definition at line 419 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().

420  {
421  $this->expectException(\LogicException::class);
422  $r = new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Renderer(
423  $this->getUIFactory(),
424  $this->getTemplateFactory(),
425  $this->getLanguage(),
426  $this->getJavaScriptBinding(),
427  $this->getRefinery()
428  );
429  $f = $this->getCounterFactory();
430 
431  $r->render($f->status(0), $this->getDefaultRenderer());
432  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
getJavaScriptBinding()
Definition: Base.php:256
getCounterFactory()
Definition: GlyphTest.php:20
getTemplateFactory()
Definition: Base.php:241
+ Here is the call graph for this function:

◆ test_glyph_action()

GlyphTest::test_glyph_action (   $factory_method)

glyph_type_provider

Definition at line 130 of file GlyphTest.php.

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

131  {
132  $f = $this->getGlyphFactory();
133  $g = $f->$factory_method("http://www.ilias.de");
134 
135  $this->assertNotNull($g);
136  $this->assertEquals("http://www.ilias.de", $g->getAction());
137  }
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 142 of file GlyphTest.php.

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

143  {
144  $f = $this->getGlyphFactory();
145  $g = $f->$factory_method();
146 
147  $this->assertNotNull($g);
148  $this->assertEquals(null, $g->getAction());
149  }
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 118 of file GlyphTest.php.

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

119  {
120  $f = $this->getGlyphFactory();
121  $g = $f->$factory_method();
122 
123  $this->assertNotNull($g);
124  $this->assertEquals($factory_method, $g->getType());
125  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_immutability_withCounter()

GlyphTest::test_immutability_withCounter ( )

Definition at line 267 of file GlyphTest.php.

References getCounterFactory(), and getGlyphFactory().

268  {
269  $gf = $this->getGlyphFactory();
270  $cf = $this->getCounterFactory();
271 
272  $g = $gf->mail();
273  $g2 = $g
274  ->withCounter(
275  $cf->novelty(0)
276  );
277 
278  $counters = $g->getCounters();
279  $this->assertCount(0, $counters);
280  }
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 107 of file GlyphTest.php.

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

108  {
109  $f = $this->getGlyphFactory();
110 
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"));
113  }
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 282 of file GlyphTest.php.

283  {
284  $this->expectException(\InvalidArgumentException::class);
285  new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Glyph("FOO", "http://www.ilias.de");
286  }

◆ test_no_counter()

GlyphTest::test_no_counter (   $factory_method)

glyph_type_provider

Definition at line 183 of file GlyphTest.php.

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

184  {
185  $f = $this->getGlyphFactory();
186  $g = $f->$factory_method();
187 
188  $this->assertCount(0, $g->getCounters());
189  }
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 194 of file GlyphTest.php.

References Vendor\Package\$c, getCounterFactory(), and getGlyphFactory().

195  {
196  $gf = $this->getGlyphFactory();
197  $cf = $this->getCounterFactory();
198  $number = 1;
199 
200  $g = $gf
201  ->mail()
202  ->withCounter(
203  $cf->$counter_type($number)
204  );
205 
206  $counters = $g->getCounters();
207  $this->assertCount(1, $counters);
208  $c = $counters[0];
209  $this->assertEquals($counter_type, $c->getType());
210  $this->assertEquals($number, $c->getNumber());
211  }
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 238 of file GlyphTest.php.

References Vendor\Package\$c, getCounterFactory(), and getGlyphFactory().

239  {
240  $gf = $this->getGlyphFactory();
241  $cf = $this->getCounterFactory();
242  $number_s = 1;
243  $number_n1 = 2;
244  $number_n2 = 2;
245 
246  $g = $gf
247  ->mail()
248  ->withCounter(
249  $cf->status($number_s)
250  )
251  ->withCounter(
252  $cf->novelty($number_n1)
253  )
254  ->withCounter(
255  $cf->novelty($number_n2)
256  );
257 
258  $counters = $g->getCounters();
259  $this->assertCount(2, $counters);
260  $vals = array_map(function ($c) {
261  return array($c->getType(), $c->getNumber());
262  }, $counters);
263  $this->assertContains(array("status", $number_s), $vals);
264  $this->assertContains(array("novelty", $number_n2), $vals);
265  }
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 340 of file GlyphTest.php.

References Vendor\Package\$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");
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\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
352  $this->assertEquals($expected, $html);
353  }
$type
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
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 463 of file GlyphTest.php.

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

464  {
465  $f = $this->getGlyphFactory();
466  $r = $this->getDefaultRenderer();
467  $c = $f->$type("http://www.ilias.de");
468  $c = $c->withAction("http://www.ilias.de/open-source-lms-ilias/");
469 
470  $html = $this->normalizeHTML($r->render($c));
471 
472  $css_classes = self::$canonical_css_classes[$type];
473  $aria_label = self::$aria_labels[$type];
474 
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);
477  }
$type
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
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 437 of file GlyphTest.php.

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

438  {
439  $f = $this->getGlyphFactory();
440  $r = $this->getDefaultRenderer();
441  $ids = array();
442  $c = $f->$type("http://www.ilias.de")
443  ->withOnLoadCode(function ($id) use (&$ids) {
444  $ids[] = $id;
445  return "";
446  });
447 
448  $html = $this->normalizeHTML($r->render($c));
449 
450  $this->assertCount(1, $ids);
451 
452  $css_classes = self::$canonical_css_classes[$type];
453  $aria_label = self::$aria_labels[$type];
454 
455  $id = $ids[0];
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);
458  }
$type
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
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 358 of file GlyphTest.php.

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

359  {
360  $f = $this->getGlyphFactory();
361  $r = $this->getDefaultRenderer();
362  $c = $f->$type("http://www.ilias.de")->withUnavailableAction();
363 
364  $html = $this->normalizeHTML($r->render($c));
365 
366  $css_classes = self::$canonical_css_classes[$type];
367  $aria_label = self::$aria_labels[$type];
368 
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);
372  }
$type
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
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 377 of file GlyphTest.php.

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

378  {
379  $fg = $this->getGlyphFactory();
380  $fc = $this->getCounterFactory();
381  $r = $this->getDefaultRenderer();
382  $c = $fg->mail("http://www.ilias.de")->withCounter($fc->$type(42));
383 
384  $html = $this->normalizeHTML($r->render($c));
385 
386  $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
387  $aria_label = self::$aria_labels[G\Glyph::MAIL];
388 
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>" .
393  "</a>";
394  $this->assertHTMLEquals($expected, $html);
395  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getCounterFactory()
Definition: GlyphTest.php:20
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_render_withTwoCounters()

GlyphTest::test_render_withTwoCounters ( )

Definition at line 397 of file GlyphTest.php.

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

398  {
399  $fg = $this->getGlyphFactory();
400  $fc = $this->getCounterFactory();
401  $r = $this->getDefaultRenderer();
402  $c = $fg->mail("http://www.ilias.de")
403  ->withCounter($fc->novelty(42))
404  ->withCounter($fc->status(7));
405 
406  $html = $this->normalizeHTML($r->render($c));
407 
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>" .
415  "</a>";
416  $this->assertHTMLEquals($expected, $html);
417  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getCounterFactory()
Definition: GlyphTest.php:20
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_two_counters()

GlyphTest::test_two_counters ( )

Definition at line 213 of file GlyphTest.php.

References Vendor\Package\$c, getCounterFactory(), and getGlyphFactory().

214  {
215  $gf = $this->getGlyphFactory();
216  $cf = $this->getCounterFactory();
217  $number_s = 1;
218  $number_n = 2;
219 
220  $g = $gf
221  ->mail()
222  ->withCounter(
223  $cf->status($number_s)
224  )
225  ->withCounter(
226  $cf->novelty($number_n)
227  );
228 
229  $counters = $g->getCounters();
230  $this->assertCount(2, $counters);
231  $vals = array_map(function ($c) {
232  return array($c->getType(), $c->getNumber());
233  }, $counters);
234  $this->assertContains(array("status", $number_s), $vals);
235  $this->assertContains(array("novelty", $number_n), $vals);
236  }
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 167 of file GlyphTest.php.

References getGlyphFactory().

168  {
169  $gf = $this->getGlyphFactory();
170 
171  $g = $gf
172  ->mail()
173  ;
174  $g2 = $g->withHighlight();
175 
176  $this->assertFalse($g->isHighlighted());
177  $this->assertTrue($g2->isHighlighted());
178  }
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 154 of file GlyphTest.php.

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

155  {
156  $f = $this->getGlyphFactory();
157  $g = $f->$factory_method();
158  $g2 = $f->$factory_method()->withUnavailableAction();
159 
160  $this->assertTrue($g->isActive());
161  $this->assertFalse($g2->isActive());
162  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

Field Documentation

◆ $aria_labels

GlyphTest::$aria_labels
static

Definition at line 64 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: