ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
GlyphTest Class Reference

Test on glyph implementation. More...

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

Public Member Functions

 getGlyphFactory ()
 
 getCounterFactory ()
 
 testImplementsFactoryInterface (string $factory_method)
 getGlyphTypeProvider More...
 
 testGlyphTypes (string $factory_method)
 getGlyphTypeProvider More...
 
 testGlyphAction (string $factory_method)
 getGlyphTypeProvider More...
 
 testGlyphNoAction (string $factory_method)
 getGlyphTypeProvider More...
 
 testWithUnavailableAction (string $factory_method)
 getGlyphTypeProvider More...
 
 testWithHighlight ()
 
 testNoCounter (string $factory_method)
 getGlyphTypeProvider More...
 
 testOneCounter (string $counter_type)
 getCounterTypeProvider More...
 
 testTwoCounters ()
 
 testOnlyTwoCounters ()
 
 testImmutabilityWithCounter ()
 
 testKnownGlyphsOnly ()
 
 testRenderSimple (string $type)
 getGlyphTypeProvider More...
 
 testRenderWithUnavailableAction (string $type)
 getGlyphTypeProvider More...
 
 testRenderWithCounter (string $type)
 getCounterTypeProvider More...
 
 testRenderWithTwoCounters ()
 
 testDontRenderCounter ()
 
 testRenderWithOnLoadCode (string $type)
 getGlyphTypeProvider More...
 
 testRenderWithAction (string $type)
 getGlyphTypeProvider More...
 
 testIsTabbable ()
 
 testTabbableGlyphRender ()
 

Static Public Member Functions

static getGlyphTypeProvider ()
 
static getCounterTypeProvider ()
 

Static Public Attributes

static array $canonical_css_classes
 
static array $aria_labels
 

Detailed Description

Test on glyph implementation.

Definition at line 35 of file GlyphTest.php.

Member Function Documentation

◆ getCounterFactory()

GlyphTest::getCounterFactory ( )

Definition at line 42 of file GlyphTest.php.

Referenced by testDontRenderCounter(), testImmutabilityWithCounter(), testOneCounter(), testOnlyTwoCounters(), testRenderWithCounter(), testRenderWithTwoCounters(), and testTwoCounters().

42  : C\Factory
43  {
44  return new I\Counter\Factory();
45  }
+ Here is the caller graph for this function:

◆ getCounterTypeProvider()

static GlyphTest::getCounterTypeProvider ( )
static

Definition at line 357 of file GlyphTest.php.

357  : array
358  {
359  return [
360  ["status"],
361  ["novelty"]
362  ];
363  }

◆ getGlyphFactory()

◆ getGlyphTypeProvider()

static GlyphTest::getGlyphTypeProvider ( )
static

Definition at line 348 of file GlyphTest.php.

348  : array
349  {
350  $glyph_reflection = new ReflectionClass(G\Glyph::class);
351  $constant_values = array_values($glyph_reflection->getConstants());
352  return array_map(function ($val) {
353  return [$val];
354  }, $constant_values);
355  }

◆ testDontRenderCounter()

GlyphTest::testDontRenderCounter ( )

Definition at line 450 of file GlyphTest.php.

References Vendor\Package\$f, $r, getCounterFactory(), and getLanguage().

450  : void
451  {
452  $this->expectException(\LogicException::class);
453  $r = new Renderer(
454  $this->getUIFactory(),
455  $this->getTemplateFactory(),
456  $this->getLanguage(),
457  $this->getJavaScriptBinding(),
458  new ilImagePathResolver(),
459  $this->createMock(DataFactory::class),
460  $this->createMock(HelpTextRetriever::class),
461  $this->getUploadLimitResolver()
462  );
463  $f = $this->getCounterFactory();
464 
465  $r->render($f->status(0), $this->getDefaultRenderer());
466  }
getLanguage()
getCounterFactory()
Definition: GlyphTest.php:42
$r
+ Here is the call graph for this function:

◆ testGlyphAction()

GlyphTest::testGlyphAction ( string  $factory_method)

getGlyphTypeProvider

Definition at line 195 of file GlyphTest.php.

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

195  : void
196  {
197  $f = $this->getGlyphFactory();
198  $g = $f->$factory_method("http://www.ilias.de");
199 
200  $this->assertNotNull($g);
201  $this->assertEquals("http://www.ilias.de", $g->getAction());
202  }
getGlyphFactory()
Definition: GlyphTest.php:37
+ Here is the call graph for this function:

◆ testGlyphNoAction()

GlyphTest::testGlyphNoAction ( string  $factory_method)

getGlyphTypeProvider

Definition at line 207 of file GlyphTest.php.

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

207  : void
208  {
209  $f = $this->getGlyphFactory();
210  $g = $f->$factory_method();
211 
212  $this->assertNotNull($g);
213  $this->assertEquals(null, $g->getAction());
214  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getGlyphFactory()
Definition: GlyphTest.php:37
+ Here is the call graph for this function:

◆ testGlyphTypes()

GlyphTest::testGlyphTypes ( string  $factory_method)

getGlyphTypeProvider

Definition at line 183 of file GlyphTest.php.

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

183  : void
184  {
185  $f = $this->getGlyphFactory();
186  $g = $f->$factory_method();
187 
188  $this->assertNotNull($g);
189  $this->assertEquals($factory_method, $g->getType());
190  }
getGlyphFactory()
Definition: GlyphTest.php:37
+ Here is the call graph for this function:

◆ testImmutabilityWithCounter()

GlyphTest::testImmutabilityWithCounter ( )

Definition at line 327 of file GlyphTest.php.

References getCounterFactory(), and getGlyphFactory().

327  : void
328  {
329  $gf = $this->getGlyphFactory();
330  $cf = $this->getCounterFactory();
331 
332  $g = $gf->mail();
333  $g
334  ->withCounter(
335  $cf->novelty(0)
336  );
337 
338  $counters = $g->getCounters();
339  $this->assertCount(0, $counters);
340  }
getCounterFactory()
Definition: GlyphTest.php:42
getGlyphFactory()
Definition: GlyphTest.php:37
+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

GlyphTest::testImplementsFactoryInterface ( string  $factory_method)

getGlyphTypeProvider

Definition at line 172 of file GlyphTest.php.

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

172  : void
173  {
174  $f = $this->getGlyphFactory();
175 
176  $this->assertInstanceOf("ILIAS\\UI\\Component\\Symbol\\Glyph\\Factory", $f);
177  $this->assertInstanceOf("ILIAS\\UI\\Component\\Symbol\\Glyph\\Glyph", $f->$factory_method("http://www.ilias.de"));
178  }
getGlyphFactory()
Definition: GlyphTest.php:37
+ Here is the call graph for this function:

◆ testIsTabbable()

GlyphTest::testIsTabbable ( )

Definition at line 513 of file GlyphTest.php.

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

513  : void
514  {
515  $f = $this->getGlyphFactory();
516  $r = $this->getDefaultRenderer();
517 
518  // Glyph without Action or Signal
519  $c = $f->user();
520  $this->assertFalse($c->isTabbable());
521 
522  // Glyph with Action
523  $c = $f->user()->withAction("#");
524  $this->assertTrue($c->isTabbable());
525 
526  // Glyph with Signal
527  $c = $f->user()->withOnClick(new I\Signal("id_1", "click"));
528  $this->assertTrue($c->isTabbable());
529 
530  // Glyph with Action and Signal
531  $c = $f->user()->withAction("#")->withOnClick(new I\Signal("id_1", "click"));
532  $this->assertTrue($c->isTabbable());
533 
534  // Glyph with Action and Signal but Inactive
535  $c = $f->user()->withAction("#")->withOnClick(new I\Signal("id_1", "click"))->withUnavailableAction();
536  $this->assertFalse($c->isTabbable());
537  }
$c
Definition: deliver.php:25
getGlyphFactory()
Definition: GlyphTest.php:37
$r
+ Here is the call graph for this function:

◆ testKnownGlyphsOnly()

GlyphTest::testKnownGlyphsOnly ( )

Definition at line 342 of file GlyphTest.php.

342  : void
343  {
344  $this->expectException(InvalidArgumentException::class);
345  new Glyph("FOO", "http://www.ilias.de");
346  }

◆ testNoCounter()

GlyphTest::testNoCounter ( string  $factory_method)

getGlyphTypeProvider

Definition at line 243 of file GlyphTest.php.

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

243  : void
244  {
245  $f = $this->getGlyphFactory();
246  $g = $f->$factory_method();
247 
248  $this->assertCount(0, $g->getCounters());
249  }
getGlyphFactory()
Definition: GlyphTest.php:37
+ Here is the call graph for this function:

◆ testOneCounter()

GlyphTest::testOneCounter ( string  $counter_type)

getCounterTypeProvider

Definition at line 254 of file GlyphTest.php.

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

254  : void
255  {
256  $gf = $this->getGlyphFactory();
257  $cf = $this->getCounterFactory();
258  $number = 1;
259 
260  $g = $gf
261  ->mail()
262  ->withCounter(
263  $cf->$counter_type($number)
264  );
265 
266  $counters = $g->getCounters();
267  $this->assertCount(1, $counters);
268  $c = $counters[0];
269  $this->assertEquals($counter_type, $c->getType());
270  $this->assertEquals($number, $c->getNumber());
271  }
$c
Definition: deliver.php:25
getCounterFactory()
Definition: GlyphTest.php:42
getGlyphFactory()
Definition: GlyphTest.php:37
+ Here is the call graph for this function:

◆ testOnlyTwoCounters()

GlyphTest::testOnlyTwoCounters ( )

Definition at line 298 of file GlyphTest.php.

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

298  : void
299  {
300  $gf = $this->getGlyphFactory();
301  $cf = $this->getCounterFactory();
302  $number_s = 1;
303  $number_n1 = 2;
304  $number_n2 = 2;
305 
306  $g = $gf
307  ->mail()
308  ->withCounter(
309  $cf->status($number_s)
310  )
311  ->withCounter(
312  $cf->novelty($number_n1)
313  )
314  ->withCounter(
315  $cf->novelty($number_n2)
316  );
317 
318  $counters = $g->getCounters();
319  $this->assertCount(2, $counters);
320  $vals = array_map(function ($c) {
321  return array($c->getType(), $c->getNumber());
322  }, $counters);
323  $this->assertContains(array("status", $number_s), $vals);
324  $this->assertContains(array("novelty", $number_n2), $vals);
325  }
$c
Definition: deliver.php:25
getCounterFactory()
Definition: GlyphTest.php:42
getGlyphFactory()
Definition: GlyphTest.php:37
+ Here is the call graph for this function:

◆ testRenderSimple()

GlyphTest::testRenderSimple ( string  $type)

getGlyphTypeProvider

Definition at line 368 of file GlyphTest.php.

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

368  : void
369  {
370  $f = $this->getGlyphFactory();
371  $r = $this->getDefaultRenderer();
372  $c = $f->$type("http://www.ilias.de");
373 
374  $html = $this->normalizeHTML($r->render($c));
375 
376  $css_classes = self::$canonical_css_classes[$type];
377  $aria_label = self::$aria_labels[$type];
378 
379  $expected = '<a tabindex="0" class="glyph" href="http://www.ilias.de" aria-label="' . $aria_label . '"><span class="' . $css_classes . '" aria-hidden="true"></span></a>';
380  $this->assertEquals($expected, $html);
381  }
$c
Definition: deliver.php:25
getGlyphFactory()
Definition: GlyphTest.php:37
$r
+ Here is the call graph for this function:

◆ testRenderWithAction()

GlyphTest::testRenderWithAction ( string  $type)

getGlyphTypeProvider

Definition at line 497 of file GlyphTest.php.

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

497  : void
498  {
499  $f = $this->getGlyphFactory();
500  $r = $this->getDefaultRenderer();
501  $c = $f->$type("http://www.ilias.de");
502  $c = $c->withAction("http://www.ilias.de/open-source-lms-ilias/");
503 
504  $html = $this->normalizeHTML($r->render($c));
505 
506  $css_classes = self::$canonical_css_classes[$type];
507  $aria_label = self::$aria_labels[$type];
508 
509  $expected = "<a tabindex=\"0\" class=\"glyph\" href=\"http://www.ilias.de/open-source-lms-ilias/\" aria-label=\"$aria_label\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
510  $this->assertEquals($expected, $html);
511  }
$c
Definition: deliver.php:25
getGlyphFactory()
Definition: GlyphTest.php:37
$r
+ Here is the call graph for this function:

◆ testRenderWithCounter()

GlyphTest::testRenderWithCounter ( string  $type)

getCounterTypeProvider

Definition at line 407 of file GlyphTest.php.

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

407  : void
408  {
409  $fg = $this->getGlyphFactory();
410  $fc = $this->getCounterFactory();
411  $r = $this->getDefaultRenderer();
412  $c = $fg->mail("http://www.ilias.de")->withCounter($fc->$type(42));
413 
414  $html = $this->normalizeHTML($r->render($c));
415 
416  $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
417  $aria_label = self::$aria_labels[G\Glyph::MAIL];
418 
419  $expected = '
420  <a tabindex="0" class="glyph" href="http://www.ilias.de" aria-label="' . $aria_label . '">
421  <span class="' . $css_classes . '" aria-hidden="true"></span>
422  <span class="il-counter"><span class="badge badge-notify il-counter-' . $type . '">42</span></span>
423  <span class="il-counter-spacer">42</span>
424  </a>';
425  $this->assertHTMLEquals($expected, $html);
426  }
$c
Definition: deliver.php:25
getCounterFactory()
Definition: GlyphTest.php:42
getGlyphFactory()
Definition: GlyphTest.php:37
$r
+ Here is the call graph for this function:

◆ testRenderWithOnLoadCode()

GlyphTest::testRenderWithOnLoadCode ( string  $type)

getGlyphTypeProvider

Definition at line 471 of file GlyphTest.php.

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

471  : void
472  {
473  $f = $this->getGlyphFactory();
474  $r = $this->getDefaultRenderer();
475  $ids = array();
476  $c = $f->$type("http://www.ilias.de")
477  ->withOnLoadCode(function ($id) use (&$ids): string {
478  $ids[] = $id;
479  return "";
480  });
481 
482  $html = $this->normalizeHTML($r->render($c));
483 
484  $this->assertCount(1, $ids);
485 
486  $css_classes = self::$canonical_css_classes[$type];
487  $aria_label = self::$aria_labels[$type];
488 
489  $id = $ids[0];
490  $expected = "<a tabindex=\"0\" class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\" id=\"$id\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
491  $this->assertEquals($expected, $html);
492  }
$c
Definition: deliver.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getGlyphFactory()
Definition: GlyphTest.php:37
$r
+ Here is the call graph for this function:

◆ testRenderWithTwoCounters()

GlyphTest::testRenderWithTwoCounters ( )

Definition at line 428 of file GlyphTest.php.

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

428  : void
429  {
430  $fg = $this->getGlyphFactory();
431  $fc = $this->getCounterFactory();
432  $r = $this->getDefaultRenderer();
433  $c = $fg->mail("http://www.ilias.de")
434  ->withCounter($fc->novelty(42))
435  ->withCounter($fc->status(7));
436 
437  $html = $this->normalizeHTML($r->render($c));
438 
439  $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
440  $aria_label = self::$aria_labels[G\Glyph::MAIL];
441  $expected = "<a tabindex=\"0\" class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">" .
442  "<span class=\"$css_classes\" aria-hidden=\"true\"></span>" .
443  "<span class=\"il-counter\"><span class=\"badge badge-notify il-counter-status\">7</span></span>" .
444  "<span class=\"il-counter\"><span class=\"badge badge-notify il-counter-novelty\">42</span></span>" .
445  "<span class=\"il-counter-spacer\">42</span>" .
446  "</a>";
447  $this->assertHTMLEquals($expected, $html);
448  }
$c
Definition: deliver.php:25
getCounterFactory()
Definition: GlyphTest.php:42
getGlyphFactory()
Definition: GlyphTest.php:37
$r
+ Here is the call graph for this function:

◆ testRenderWithUnavailableAction()

GlyphTest::testRenderWithUnavailableAction ( string  $type)

getGlyphTypeProvider

Definition at line 386 of file GlyphTest.php.

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

386  : void
387  {
388  $f = $this->getGlyphFactory();
389  $r = $this->getDefaultRenderer();
390  $c = $f->$type("http://www.ilias.de")->withUnavailableAction();
391 
392  $html = $this->normalizeHTML($r->render($c));
393 
394  $css_classes = self::$canonical_css_classes[$type];
395  $aria_label = self::$aria_labels[$type];
396 
397  $expected = '
398  <a class="glyph disabled" aria-label="' . $aria_label . '" aria-disabled="true">
399  <span class="' . $css_classes . '" aria-hidden="true"></span>
400  </a>';
401  $this->assertEquals($this->brutallyTrimHTML($expected), $this->brutallyTrimHTML($html));
402  }
$c
Definition: deliver.php:25
getGlyphFactory()
Definition: GlyphTest.php:37
$r
+ Here is the call graph for this function:

◆ testTabbableGlyphRender()

GlyphTest::testTabbableGlyphRender ( )

Definition at line 539 of file GlyphTest.php.

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

539  : void
540  {
541  $f = $this->getGlyphFactory();
542  $r = $this->getDefaultRenderer();
543 
544  // Glyph without Action or Signal (not Tabbable)
545  $c = $f->user();
546  $expected = '<a class="glyph" aria-label="show_who_is_online"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></a>';
547  $html = $this->normalizeHTML($r->render($c));
548  $this->assertEquals($expected, $html);
549 
550  // Glyph with Action (Tabbable)
551  $c = $f->user()->withAction("#");
552  $expected = '<a tabindex="0" class="glyph" href="#" aria-label="show_who_is_online"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></a>';
553  $html = $this->normalizeHTML($r->render($c));
554  $this->assertEquals($expected, $html);
555  }
$c
Definition: deliver.php:25
getGlyphFactory()
Definition: GlyphTest.php:37
$r
+ Here is the call graph for this function:

◆ testTwoCounters()

GlyphTest::testTwoCounters ( )

Definition at line 273 of file GlyphTest.php.

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

273  : void
274  {
275  $gf = $this->getGlyphFactory();
276  $cf = $this->getCounterFactory();
277  $number_s = 1;
278  $number_n = 2;
279 
280  $g = $gf
281  ->mail()
282  ->withCounter(
283  $cf->status($number_s)
284  )
285  ->withCounter(
286  $cf->novelty($number_n)
287  );
288 
289  $counters = $g->getCounters();
290  $this->assertCount(2, $counters);
291  $vals = array_map(function ($c) {
292  return array($c->getType(), $c->getNumber());
293  }, $counters);
294  $this->assertContains(array("status", $number_s), $vals);
295  $this->assertContains(array("novelty", $number_n), $vals);
296  }
$c
Definition: deliver.php:25
getCounterFactory()
Definition: GlyphTest.php:42
getGlyphFactory()
Definition: GlyphTest.php:37
+ Here is the call graph for this function:

◆ testWithHighlight()

GlyphTest::testWithHighlight ( )

Definition at line 229 of file GlyphTest.php.

References getGlyphFactory().

229  : void
230  {
231  $gf = $this->getGlyphFactory();
232 
233  $g = $gf->mail();
234  $g2 = $g->withHighlight();
235 
236  $this->assertFalse($g->isHighlighted());
237  $this->assertTrue($g2->isHighlighted());
238  }
getGlyphFactory()
Definition: GlyphTest.php:37
+ Here is the call graph for this function:

◆ testWithUnavailableAction()

GlyphTest::testWithUnavailableAction ( string  $factory_method)

getGlyphTypeProvider

Definition at line 219 of file GlyphTest.php.

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

219  : void
220  {
221  $f = $this->getGlyphFactory();
222  $g = $f->$factory_method();
223  $g2 = $f->$factory_method()->withUnavailableAction();
224 
225  $this->assertTrue($g->isActive());
226  $this->assertFalse($g2->isActive());
227  }
getGlyphFactory()
Definition: GlyphTest.php:37
+ Here is the call graph for this function:

Field Documentation

◆ $aria_labels

array GlyphTest::$aria_labels
static

Definition at line 108 of file GlyphTest.php.

◆ $canonical_css_classes

array GlyphTest::$canonical_css_classes
static

Definition at line 47 of file GlyphTest.php.


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