ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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)
 
 testWithHighlight ()
 
 testNoCounter (string $factory_method)
 
 testOneCounter (string $counter_type)
 
 testTwoCounters ()
 
 testOnlyTwoCounters ()
 
 testImmutabilityWithCounter ()
 
 testKnownGlyphsOnly ()
 
 testRenderSimple (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 45 of file GlyphTest.php.

45 : C\Factory
46 {
47 return new I\Counter\Factory();
48 }

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

+ Here is the caller graph for this function:

◆ getCounterTypeProvider()

static GlyphTest::getCounterTypeProvider ( )
static

Definition at line 342 of file GlyphTest.php.

342 : array
343 {
344 return [
345 ["status"],
346 ["novelty"]
347 ];
348 }

◆ getGlyphFactory()

GlyphTest::getGlyphFactory ( )

Definition at line 40 of file GlyphTest.php.

40 : G\Factory
41 {
42 return new I\Symbol\Glyph\Factory($this->createRelayArgumentLanguageStub());
43 }
This is how a factory for glyphs looks like.
Definition: Factory.php:27

Referenced by testGlyphNoAction(), testGlyphTypes(), testImmutabilityWithCounter(), testImplementsFactoryInterface(), testNoCounter(), testOneCounter(), testOnlyTwoCounters(), testRenderSimple(), testRenderWithCounter(), testRenderWithOnLoadCode(), testRenderWithTwoCounters(), testTwoCounters(), and testWithHighlight().

+ Here is the caller graph for this function:

◆ getGlyphTypeProvider()

static GlyphTest::getGlyphTypeProvider ( )
static

Definition at line 333 of file GlyphTest.php.

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

◆ testDontRenderCounter()

GlyphTest::testDontRenderCounter ( )

Definition at line 410 of file GlyphTest.php.

410 : void
411 {
412 $this->expectException(\LogicException::class);
413 $r = new Renderer(
414 $this->getUIFactory(),
415 $this->getTemplateFactory(),
416 $this->getLanguage(),
417 $this->getJavaScriptBinding(),
419 $this->createMock(DataFactory::class),
420 $this->createMock(HelpTextRetriever::class),
421 $this->getUploadLimitResolver(),
422 $this->getRefinery(),
423 );
424 $f = $this->getCounterFactory();
425
426 $r->render($f->status(0), $this->getDefaultRenderer());
427 }
getCounterFactory()
Definition: GlyphTest.php:45
getLanguage()

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

+ Here is the call graph for this function:

◆ testGlyphNoAction()

GlyphTest::testGlyphNoAction ( string  $factory_method)

Definition at line 210 of file GlyphTest.php.

210 : void
211 {
212 $f = $this->getGlyphFactory();
213 $g = $f->$factory_method();
214
215 $this->assertNotNull($g);
216 }
getGlyphFactory()
Definition: GlyphTest.php:40

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

+ Here is the call graph for this function:

◆ testGlyphTypes()

GlyphTest::testGlyphTypes ( string  $factory_method)

Definition at line 200 of file GlyphTest.php.

200 : void
201 {
202 $f = $this->getGlyphFactory();
203 $g = $f->$factory_method();
204
205 $this->assertNotNull($g);
206 $this->assertEquals($factory_method, $g->getType());
207 }

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

+ Here is the call graph for this function:

◆ testImmutabilityWithCounter()

GlyphTest::testImmutabilityWithCounter ( )

Definition at line 312 of file GlyphTest.php.

312 : void
313 {
314 $gf = $this->getGlyphFactory();
315 $cf = $this->getCounterFactory();
316
317 $g = $gf->mail();
318 $g
319 ->withCounter(
320 $cf->novelty(0)
321 );
322
323 $counters = $g->getCounters();
324 $this->assertCount(0, $counters);
325 }

References getCounterFactory(), and getGlyphFactory().

+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

GlyphTest::testImplementsFactoryInterface ( string  $factory_method)

Definition at line 191 of file GlyphTest.php.

191 : void
192 {
193 $f = $this->getGlyphFactory();
194
195 $this->assertInstanceOf("ILIAS\\UI\\Component\\Symbol\\Glyph\\Factory", $f);
196 $this->assertInstanceOf("ILIAS\\UI\\Component\\Symbol\\Glyph\\Glyph", $f->$factory_method());
197 }

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

+ Here is the call graph for this function:

◆ testKnownGlyphsOnly()

GlyphTest::testKnownGlyphsOnly ( )

Definition at line 327 of file GlyphTest.php.

327 : void
328 {
329 $this->expectException(InvalidArgumentException::class);
330 new Glyph("FOO", "FAA");
331 }

◆ testNoCounter()

GlyphTest::testNoCounter ( string  $factory_method)

Definition at line 230 of file GlyphTest.php.

230 : void
231 {
232 $f = $this->getGlyphFactory();
233 $g = $f->$factory_method();
234
235 $this->assertCount(0, $g->getCounters());
236 }

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

+ Here is the call graph for this function:

◆ testOneCounter()

GlyphTest::testOneCounter ( string  $counter_type)

Definition at line 239 of file GlyphTest.php.

239 : void
240 {
241 $gf = $this->getGlyphFactory();
242 $cf = $this->getCounterFactory();
243 $number = 1;
244
245 $g = $gf
246 ->mail()
247 ->withCounter(
248 $cf->$counter_type($number)
249 );
250
251 $counters = $g->getCounters();
252 $this->assertCount(1, $counters);
253 $c = $counters[0];
254 $this->assertEquals($counter_type, $c->getType());
255 $this->assertEquals($number, $c->getNumber());
256 }

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

+ Here is the call graph for this function:

◆ testOnlyTwoCounters()

GlyphTest::testOnlyTwoCounters ( )

Definition at line 283 of file GlyphTest.php.

283 : void
284 {
285 $gf = $this->getGlyphFactory();
286 $cf = $this->getCounterFactory();
287 $number_s = 1;
288 $number_n1 = 2;
289 $number_n2 = 2;
290
291 $g = $gf
292 ->mail()
293 ->withCounter(
294 $cf->status($number_s)
295 )
296 ->withCounter(
297 $cf->novelty($number_n1)
298 )
299 ->withCounter(
300 $cf->novelty($number_n2)
301 );
302
303 $counters = $g->getCounters();
304 $this->assertCount(2, $counters);
305 $vals = array_map(function ($c) {
306 return array($c->getType(), $c->getNumber());
307 }, $counters);
308 $this->assertContains(array("status", $number_s), $vals);
309 $this->assertContains(array("novelty", $number_n2), $vals);
310 }

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

+ Here is the call graph for this function:

◆ testRenderSimple()

GlyphTest::testRenderSimple ( string  $type)

Definition at line 351 of file GlyphTest.php.

351 : void
352 {
353 $f = $this->getGlyphFactory();
354 $r = $this->getDefaultRenderer();
355 $c = $f->$type();
356
357 $html = $this->normalizeHTML($r->render($c));
358
359 $css_classes = self::$canonical_css_classes[$type];
360 $aria_label = self::$aria_labels[$type];
361
362 $expected = '<span class="glyph" aria-label="' . $aria_label . '" role="img"><span class="' . $css_classes . '" aria-hidden="true"></span></span>';
363 $this->assertEquals($expected, $html);
364 }

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

+ Here is the call graph for this function:

◆ testRenderWithCounter()

GlyphTest::testRenderWithCounter ( string  $type)

Definition at line 367 of file GlyphTest.php.

367 : void
368 {
369 $fg = $this->getGlyphFactory();
370 $fc = $this->getCounterFactory();
371 $r = $this->getDefaultRenderer();
372 $c = $fg->mail()->withCounter($fc->$type(42));
373
374 $html = $this->normalizeHTML($r->render($c));
375
376 $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
377 $aria_label = self::$aria_labels[G\Glyph::MAIL];
378
379 $expected = '
380 <span class="glyph" aria-label="' . $aria_label . '" role="img">
381 <span class="' . $css_classes . '" aria-hidden="true"></span>
382 <span class="il-counter"><span class="badge badge-notify il-counter-' . $type . '">42</span></span>
383 <span class="il-counter-spacer">42</span>
384 </span>';
385 $this->assertHTMLEquals($expected, $html);
386 }

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

+ Here is the call graph for this function:

◆ testRenderWithOnLoadCode()

GlyphTest::testRenderWithOnLoadCode ( string  $type)

Definition at line 430 of file GlyphTest.php.

430 : void
431 {
432 $f = $this->getGlyphFactory();
433 $r = $this->getDefaultRenderer();
434 $ids = array();
435 $c = $f->$type()
436 ->withOnLoadCode(function ($id) use (&$ids): string {
437 $ids[] = $id;
438 return "";
439 });
440
441 $html = $this->normalizeHTML($r->render($c));
442
443 $this->assertCount(1, $ids);
444
445 $css_classes = self::$canonical_css_classes[$type];
446 $aria_label = self::$aria_labels[$type];
447
448 $id = $ids[0];
449 $expected = '<span class="glyph" aria-label="' . $aria_label . '" role="img" id="' . $id . '"><span class="' . $css_classes . '" aria-hidden="true"></span></span>';
450 $this->assertEquals($expected, $html);
451 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

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

+ Here is the call graph for this function:

◆ testRenderWithTwoCounters()

GlyphTest::testRenderWithTwoCounters ( )

Definition at line 388 of file GlyphTest.php.

388 : void
389 {
390 $fg = $this->getGlyphFactory();
391 $fc = $this->getCounterFactory();
392 $r = $this->getDefaultRenderer();
393 $c = $fg->mail()
394 ->withCounter($fc->novelty(42))
395 ->withCounter($fc->status(7));
396
397 $html = $this->normalizeHTML($r->render($c));
398
399 $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
400 $aria_label = self::$aria_labels[G\Glyph::MAIL];
401 $expected = '<span class="glyph" aria-label="' . $aria_label . '" role="img">' .
402 '<span class="' . $css_classes . '" aria-hidden="true"></span>' .
403 '<span class="il-counter"><span class="badge badge-notify il-counter-status">7</span></span>' .
404 '<span class="il-counter"><span class="badge badge-notify il-counter-novelty">42</span></span>' .
405 '<span class="il-counter-spacer">42</span>' .
406 '</span>';
407 $this->assertHTMLEquals($expected, $html);
408 }

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

+ Here is the call graph for this function:

◆ testTwoCounters()

GlyphTest::testTwoCounters ( )

Definition at line 258 of file GlyphTest.php.

258 : void
259 {
260 $gf = $this->getGlyphFactory();
261 $cf = $this->getCounterFactory();
262 $number_s = 1;
263 $number_n = 2;
264
265 $g = $gf
266 ->mail()
267 ->withCounter(
268 $cf->status($number_s)
269 )
270 ->withCounter(
271 $cf->novelty($number_n)
272 );
273
274 $counters = $g->getCounters();
275 $this->assertCount(2, $counters);
276 $vals = array_map(function ($c) {
277 return array($c->getType(), $c->getNumber());
278 }, $counters);
279 $this->assertContains(array("status", $number_s), $vals);
280 $this->assertContains(array("novelty", $number_n), $vals);
281 }

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

+ Here is the call graph for this function:

◆ testWithHighlight()

GlyphTest::testWithHighlight ( )

Definition at line 218 of file GlyphTest.php.

218 : void
219 {
220 $gf = $this->getGlyphFactory();
221
222 $g = $gf->mail();
223 $g2 = $g->withHighlight();
224
225 $this->assertFalse($g->isHighlighted());
226 $this->assertTrue($g2->isHighlighted());
227 }

References getGlyphFactory().

+ Here is the call graph for this function:

Field Documentation

◆ $aria_labels

array GlyphTest::$aria_labels
static

Definition at line 120 of file GlyphTest.php.

◆ $canonical_css_classes

array GlyphTest::$canonical_css_classes
static

Definition at line 50 of file GlyphTest.php.


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