ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
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)
 
 testGlyphTypes (string $factory_method)
 
 testGlyphNoAction (string $factory_method)
 
 testWithUnavailableAction (string $factory_method)
 
 testWithHighlight ()
 
 testNoCounter (string $factory_method)
 
 testOneCounter (string $counter_type)
 
 testTwoCounters ()
 
 testOnlyTwoCounters ()
 
 testImmutabilityWithCounter ()
 
 testKnownGlyphsOnly ()
 
 testRenderSimple (string $type)
 
 testRenderWithUnavailableAction (string $type)
 
 testRenderWithCounter (string $type)
 
 testRenderWithTwoCounters ()
 
 testDontRenderCounter ()
 
 testRenderWithOnLoadCode (string $type)
 

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

Member Function Documentation

◆ getCounterFactory()

GlyphTest::getCounterFactory ( )

Definition at line 43 of file GlyphTest.php.

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

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

◆ getCounterTypeProvider()

static GlyphTest::getCounterTypeProvider ( )
static

Definition at line 338 of file GlyphTest.php.

338  : array
339  {
340  return [
341  ["status"],
342  ["novelty"]
343  ];
344  }

◆ getGlyphFactory()

◆ getGlyphTypeProvider()

static GlyphTest::getGlyphTypeProvider ( )
static

Definition at line 329 of file GlyphTest.php.

329  : array
330  {
331  $glyph_reflection = new ReflectionClass(G\Glyph::class);
332  $constant_values = array_values($glyph_reflection->getConstants());
333  return array_map(function ($val) {
334  return [$val];
335  }, $constant_values);
336  }

◆ testDontRenderCounter()

GlyphTest::testDontRenderCounter ( )

Definition at line 425 of file GlyphTest.php.

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

425  : void
426  {
427  $this->expectException(\LogicException::class);
428  $r = new Renderer(
429  $this->getUIFactory(),
430  $this->getTemplateFactory(),
431  $this->getLanguage(),
432  $this->getJavaScriptBinding(),
433  new ilImagePathResolver(),
434  $this->createMock(DataFactory::class),
435  $this->createMock(HelpTextRetriever::class),
436  $this->getUploadLimitResolver()
437  );
438  $f = $this->getCounterFactory();
439 
440  $r->render($f->status(0), $this->getDefaultRenderer());
441  }
getLanguage()
getCounterFactory()
Definition: GlyphTest.php:43
$r
+ Here is the call graph for this function:

◆ testGlyphNoAction()

GlyphTest::testGlyphNoAction ( string  $factory_method)

Definition at line 194 of file GlyphTest.php.

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

194  : void
195  {
196  $f = $this->getGlyphFactory();
197  $g = $f->$factory_method();
198 
199  $this->assertNotNull($g);
200  $this->assertEquals(null, $g->getAction());
201  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getGlyphFactory()
Definition: GlyphTest.php:38
+ Here is the call graph for this function:

◆ testGlyphTypes()

GlyphTest::testGlyphTypes ( string  $factory_method)

Definition at line 184 of file GlyphTest.php.

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

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

◆ testImmutabilityWithCounter()

GlyphTest::testImmutabilityWithCounter ( )

Definition at line 308 of file GlyphTest.php.

References getCounterFactory(), and getGlyphFactory().

308  : void
309  {
310  $gf = $this->getGlyphFactory();
311  $cf = $this->getCounterFactory();
312 
313  $g = $gf->mail();
314  $g
315  ->withCounter(
316  $cf->novelty(0)
317  );
318 
319  $counters = $g->getCounters();
320  $this->assertCount(0, $counters);
321  }
getCounterFactory()
Definition: GlyphTest.php:43
getGlyphFactory()
Definition: GlyphTest.php:38
+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

GlyphTest::testImplementsFactoryInterface ( string  $factory_method)

Definition at line 175 of file GlyphTest.php.

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

175  : void
176  {
177  $f = $this->getGlyphFactory();
178 
179  $this->assertInstanceOf("ILIAS\\UI\\Component\\Symbol\\Glyph\\Factory", $f);
180  $this->assertInstanceOf("ILIAS\\UI\\Component\\Symbol\\Glyph\\Glyph", $f->$factory_method());
181  }
getGlyphFactory()
Definition: GlyphTest.php:38
+ Here is the call graph for this function:

◆ testKnownGlyphsOnly()

GlyphTest::testKnownGlyphsOnly ( )

Definition at line 323 of file GlyphTest.php.

323  : void
324  {
325  $this->expectException(InvalidArgumentException::class);
326  new Glyph("FOO", "FAA");
327  }

◆ testNoCounter()

GlyphTest::testNoCounter ( string  $factory_method)

Definition at line 226 of file GlyphTest.php.

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

226  : void
227  {
228  $f = $this->getGlyphFactory();
229  $g = $f->$factory_method();
230 
231  $this->assertCount(0, $g->getCounters());
232  }
getGlyphFactory()
Definition: GlyphTest.php:38
+ Here is the call graph for this function:

◆ testOneCounter()

GlyphTest::testOneCounter ( string  $counter_type)

Definition at line 235 of file GlyphTest.php.

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

235  : void
236  {
237  $gf = $this->getGlyphFactory();
238  $cf = $this->getCounterFactory();
239  $number = 1;
240 
241  $g = $gf
242  ->mail()
243  ->withCounter(
244  $cf->$counter_type($number)
245  );
246 
247  $counters = $g->getCounters();
248  $this->assertCount(1, $counters);
249  $c = $counters[0];
250  $this->assertEquals($counter_type, $c->getType());
251  $this->assertEquals($number, $c->getNumber());
252  }
$c
Definition: deliver.php:25
getCounterFactory()
Definition: GlyphTest.php:43
getGlyphFactory()
Definition: GlyphTest.php:38
+ Here is the call graph for this function:

◆ testOnlyTwoCounters()

GlyphTest::testOnlyTwoCounters ( )

Definition at line 279 of file GlyphTest.php.

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

279  : void
280  {
281  $gf = $this->getGlyphFactory();
282  $cf = $this->getCounterFactory();
283  $number_s = 1;
284  $number_n1 = 2;
285  $number_n2 = 2;
286 
287  $g = $gf
288  ->mail()
289  ->withCounter(
290  $cf->status($number_s)
291  )
292  ->withCounter(
293  $cf->novelty($number_n1)
294  )
295  ->withCounter(
296  $cf->novelty($number_n2)
297  );
298 
299  $counters = $g->getCounters();
300  $this->assertCount(2, $counters);
301  $vals = array_map(function ($c) {
302  return array($c->getType(), $c->getNumber());
303  }, $counters);
304  $this->assertContains(array("status", $number_s), $vals);
305  $this->assertContains(array("novelty", $number_n2), $vals);
306  }
$c
Definition: deliver.php:25
getCounterFactory()
Definition: GlyphTest.php:43
getGlyphFactory()
Definition: GlyphTest.php:38
+ Here is the call graph for this function:

◆ testRenderSimple()

GlyphTest::testRenderSimple ( string  $type)

Definition at line 347 of file GlyphTest.php.

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

347  : void
348  {
349  $f = $this->getGlyphFactory();
350  $r = $this->getDefaultRenderer();
351  $c = $f->$type();
352 
353  $html = $this->normalizeHTML($r->render($c));
354 
355  $css_classes = self::$canonical_css_classes[$type];
356  $aria_label = self::$aria_labels[$type];
357 
358  $expected = '<a class="glyph" aria-label="' . $aria_label . '"><span class="' . $css_classes . '" aria-hidden="true"></span></a>';
359  $this->assertEquals($expected, $html);
360  }
$c
Definition: deliver.php:25
getGlyphFactory()
Definition: GlyphTest.php:38
$r
+ Here is the call graph for this function:

◆ testRenderWithCounter()

GlyphTest::testRenderWithCounter ( string  $type)

Definition at line 382 of file GlyphTest.php.

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

382  : void
383  {
384  $fg = $this->getGlyphFactory();
385  $fc = $this->getCounterFactory();
386  $r = $this->getDefaultRenderer();
387  $c = $fg->mail()->withCounter($fc->$type(42));
388 
389  $html = $this->normalizeHTML($r->render($c));
390 
391  $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
392  $aria_label = self::$aria_labels[G\Glyph::MAIL];
393 
394  $expected = '
395  <a class="glyph" aria-label="' . $aria_label . '">
396  <span class="' . $css_classes . '" aria-hidden="true"></span>
397  <span class="il-counter"><span class="badge badge-notify il-counter-' . $type . '">42</span></span>
398  <span class="il-counter-spacer">42</span>
399  </a>';
400  $this->assertHTMLEquals($expected, $html);
401  }
$c
Definition: deliver.php:25
getCounterFactory()
Definition: GlyphTest.php:43
getGlyphFactory()
Definition: GlyphTest.php:38
$r
+ Here is the call graph for this function:

◆ testRenderWithOnLoadCode()

GlyphTest::testRenderWithOnLoadCode ( string  $type)

Definition at line 444 of file GlyphTest.php.

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

444  : void
445  {
446  $f = $this->getGlyphFactory();
447  $r = $this->getDefaultRenderer();
448  $ids = array();
449  $c = $f->$type()
450  ->withOnLoadCode(function ($id) use (&$ids): string {
451  $ids[] = $id;
452  return "";
453  });
454 
455  $html = $this->normalizeHTML($r->render($c));
456 
457  $this->assertCount(1, $ids);
458 
459  $css_classes = self::$canonical_css_classes[$type];
460  $aria_label = self::$aria_labels[$type];
461 
462  $id = $ids[0];
463  $expected = '<a class="glyph" aria-label="' . $aria_label . '" id="' . $id . '"><span class="' . $css_classes . '" aria-hidden="true"></span></a>';
464  $this->assertEquals($expected, $html);
465  }
$c
Definition: deliver.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getGlyphFactory()
Definition: GlyphTest.php:38
$r
+ Here is the call graph for this function:

◆ testRenderWithTwoCounters()

GlyphTest::testRenderWithTwoCounters ( )

Definition at line 403 of file GlyphTest.php.

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

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

◆ testRenderWithUnavailableAction()

GlyphTest::testRenderWithUnavailableAction ( string  $type)

Definition at line 363 of file GlyphTest.php.

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

363  : void
364  {
365  $f = $this->getGlyphFactory();
366  $r = $this->getDefaultRenderer();
367  $c = $f->$type()->withUnavailableAction();
368 
369  $html = $this->normalizeHTML($r->render($c));
370 
371  $css_classes = self::$canonical_css_classes[$type];
372  $aria_label = self::$aria_labels[$type];
373 
374  $expected = '
375  <a class="glyph disabled" aria-label="' . $aria_label . '" aria-disabled="true">
376  <span class="' . $css_classes . '" aria-hidden="true"></span>
377  </a>';
378  $this->assertEquals($this->brutallyTrimHTML($expected), $this->brutallyTrimHTML($html));
379  }
$c
Definition: deliver.php:25
getGlyphFactory()
Definition: GlyphTest.php:38
$r
+ Here is the call graph for this function:

◆ testTwoCounters()

GlyphTest::testTwoCounters ( )

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_s = 1;
259  $number_n = 2;
260 
261  $g = $gf
262  ->mail()
263  ->withCounter(
264  $cf->status($number_s)
265  )
266  ->withCounter(
267  $cf->novelty($number_n)
268  );
269 
270  $counters = $g->getCounters();
271  $this->assertCount(2, $counters);
272  $vals = array_map(function ($c) {
273  return array($c->getType(), $c->getNumber());
274  }, $counters);
275  $this->assertContains(array("status", $number_s), $vals);
276  $this->assertContains(array("novelty", $number_n), $vals);
277  }
$c
Definition: deliver.php:25
getCounterFactory()
Definition: GlyphTest.php:43
getGlyphFactory()
Definition: GlyphTest.php:38
+ Here is the call graph for this function:

◆ testWithHighlight()

GlyphTest::testWithHighlight ( )

Definition at line 214 of file GlyphTest.php.

References getGlyphFactory().

214  : void
215  {
216  $gf = $this->getGlyphFactory();
217 
218  $g = $gf->mail();
219  $g2 = $g->withHighlight();
220 
221  $this->assertFalse($g->isHighlighted());
222  $this->assertTrue($g2->isHighlighted());
223  }
getGlyphFactory()
Definition: GlyphTest.php:38
+ Here is the call graph for this function:

◆ testWithUnavailableAction()

GlyphTest::testWithUnavailableAction ( string  $factory_method)

Definition at line 204 of file GlyphTest.php.

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

204  : void
205  {
206  $f = $this->getGlyphFactory();
207  $g = $f->$factory_method();
208  $g2 = $f->$factory_method()->withUnavailableAction();
209 
210  $this->assertTrue($g->isActive());
211  $this->assertFalse($g2->isActive());
212  }
getGlyphFactory()
Definition: GlyphTest.php:38
+ Here is the call graph for this function:

Field Documentation

◆ $aria_labels

array GlyphTest::$aria_labels
static

Definition at line 111 of file GlyphTest.php.

◆ $canonical_css_classes

array GlyphTest::$canonical_css_classes
static

Definition at line 48 of file GlyphTest.php.


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