ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
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 43 of file GlyphTest.php.

43 : C\Factory
44 {
45 return new I\Counter\Factory();
46 }

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

326 : array
327 {
328 return [
329 ["status"],
330 ["novelty"]
331 ];
332 }

◆ getGlyphFactory()

GlyphTest::getGlyphFactory ( )

◆ getGlyphTypeProvider()

static GlyphTest::getGlyphTypeProvider ( )
static

Definition at line 317 of file GlyphTest.php.

317 : array
318 {
319 $glyph_reflection = new ReflectionClass(G\Glyph::class);
320 $constant_values = array_values($glyph_reflection->getConstants());
321 return array_map(function ($val) {
322 return [$val];
323 }, $constant_values);
324 }

◆ testDontRenderCounter()

GlyphTest::testDontRenderCounter ( )

Definition at line 394 of file GlyphTest.php.

394 : void
395 {
396 $this->expectException(\LogicException::class);
397 $r = new Renderer(
398 $this->getUIFactory(),
399 $this->getTemplateFactory(),
400 $this->getLanguage(),
401 $this->getJavaScriptBinding(),
403 $this->createMock(DataFactory::class),
404 $this->createMock(HelpTextRetriever::class),
405 $this->getUploadLimitResolver()
406 );
407 $f = $this->getCounterFactory();
408
409 $r->render($f->status(0), $this->getDefaultRenderer());
410 }
getCounterFactory()
Definition: GlyphTest.php:43
getLanguage()

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

+ Here is the call graph for this function:

◆ testGlyphNoAction()

GlyphTest::testGlyphNoAction ( string  $factory_method)

Definition at line 194 of file GlyphTest.php.

194 : void
195 {
196 $f = $this->getGlyphFactory();
197 $g = $f->$factory_method();
198
199 $this->assertNotNull($g);
200 }
getGlyphFactory()
Definition: GlyphTest.php:38

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

+ Here is the call graph for this function:

◆ testGlyphTypes()

GlyphTest::testGlyphTypes ( string  $factory_method)

Definition at line 184 of file GlyphTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testImmutabilityWithCounter()

GlyphTest::testImmutabilityWithCounter ( )

Definition at line 296 of file GlyphTest.php.

296 : void
297 {
298 $gf = $this->getGlyphFactory();
299 $cf = $this->getCounterFactory();
300
301 $g = $gf->mail();
302 $g
303 ->withCounter(
304 $cf->novelty(0)
305 );
306
307 $counters = $g->getCounters();
308 $this->assertCount(0, $counters);
309 }

References getCounterFactory(), and getGlyphFactory().

+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

GlyphTest::testImplementsFactoryInterface ( string  $factory_method)

Definition at line 175 of file GlyphTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testKnownGlyphsOnly()

GlyphTest::testKnownGlyphsOnly ( )

Definition at line 311 of file GlyphTest.php.

311 : void
312 {
313 $this->expectException(InvalidArgumentException::class);
314 new Glyph("FOO", "FAA");
315 }

◆ testNoCounter()

GlyphTest::testNoCounter ( string  $factory_method)

Definition at line 214 of file GlyphTest.php.

214 : void
215 {
216 $f = $this->getGlyphFactory();
217 $g = $f->$factory_method();
218
219 $this->assertCount(0, $g->getCounters());
220 }

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

+ Here is the call graph for this function:

◆ testOneCounter()

GlyphTest::testOneCounter ( string  $counter_type)

Definition at line 223 of file GlyphTest.php.

223 : void
224 {
225 $gf = $this->getGlyphFactory();
226 $cf = $this->getCounterFactory();
227 $number = 1;
228
229 $g = $gf
230 ->mail()
231 ->withCounter(
232 $cf->$counter_type($number)
233 );
234
235 $counters = $g->getCounters();
236 $this->assertCount(1, $counters);
237 $c = $counters[0];
238 $this->assertEquals($counter_type, $c->getType());
239 $this->assertEquals($number, $c->getNumber());
240 }
$c
Definition: deliver.php:25

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

+ Here is the call graph for this function:

◆ testOnlyTwoCounters()

GlyphTest::testOnlyTwoCounters ( )

Definition at line 267 of file GlyphTest.php.

267 : void
268 {
269 $gf = $this->getGlyphFactory();
270 $cf = $this->getCounterFactory();
271 $number_s = 1;
272 $number_n1 = 2;
273 $number_n2 = 2;
274
275 $g = $gf
276 ->mail()
277 ->withCounter(
278 $cf->status($number_s)
279 )
280 ->withCounter(
281 $cf->novelty($number_n1)
282 )
283 ->withCounter(
284 $cf->novelty($number_n2)
285 );
286
287 $counters = $g->getCounters();
288 $this->assertCount(2, $counters);
289 $vals = array_map(function ($c) {
290 return array($c->getType(), $c->getNumber());
291 }, $counters);
292 $this->assertContains(array("status", $number_s), $vals);
293 $this->assertContains(array("novelty", $number_n2), $vals);
294 }

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

+ Here is the call graph for this function:

◆ testRenderSimple()

GlyphTest::testRenderSimple ( string  $type)

Definition at line 335 of file GlyphTest.php.

335 : void
336 {
337 $f = $this->getGlyphFactory();
338 $r = $this->getDefaultRenderer();
339 $c = $f->$type();
340
341 $html = $this->normalizeHTML($r->render($c));
342
343 $css_classes = self::$canonical_css_classes[$type];
344 $aria_label = self::$aria_labels[$type];
345
346 $expected = '<span class="glyph" aria-label="' . $aria_label . '" role="img"><span class="' . $css_classes . '" aria-hidden="true"></span></span>';
347 $this->assertEquals($expected, $html);
348 }

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

+ Here is the call graph for this function:

◆ testRenderWithCounter()

GlyphTest::testRenderWithCounter ( string  $type)

Definition at line 351 of file GlyphTest.php.

351 : void
352 {
353 $fg = $this->getGlyphFactory();
354 $fc = $this->getCounterFactory();
355 $r = $this->getDefaultRenderer();
356 $c = $fg->mail()->withCounter($fc->$type(42));
357
358 $html = $this->normalizeHTML($r->render($c));
359
360 $css_classes = self::$canonical_css_classes[G\Glyph::MAIL];
361 $aria_label = self::$aria_labels[G\Glyph::MAIL];
362
363 $expected = '
364 <span class="glyph" aria-label="' . $aria_label . '" role="img">
365 <span class="' . $css_classes . '" aria-hidden="true"></span>
366 <span class="il-counter"><span class="badge badge-notify il-counter-' . $type . '">42</span></span>
367 <span class="il-counter-spacer">42</span>
368 </span>';
369 $this->assertHTMLEquals($expected, $html);
370 }

References $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 413 of file GlyphTest.php.

413 : void
414 {
415 $f = $this->getGlyphFactory();
416 $r = $this->getDefaultRenderer();
417 $ids = array();
418 $c = $f->$type()
419 ->withOnLoadCode(function ($id) use (&$ids): string {
420 $ids[] = $id;
421 return "";
422 });
423
424 $html = $this->normalizeHTML($r->render($c));
425
426 $this->assertCount(1, $ids);
427
428 $css_classes = self::$canonical_css_classes[$type];
429 $aria_label = self::$aria_labels[$type];
430
431 $id = $ids[0];
432 $expected = '<span class="glyph" aria-label="' . $aria_label . '" role="img" id="' . $id . '"><span class="' . $css_classes . '" aria-hidden="true"></span></span>';
433 $this->assertEquals($expected, $html);
434 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

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

+ Here is the call graph for this function:

◆ testRenderWithTwoCounters()

GlyphTest::testRenderWithTwoCounters ( )

Definition at line 372 of file GlyphTest.php.

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

References $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 242 of file GlyphTest.php.

242 : void
243 {
244 $gf = $this->getGlyphFactory();
245 $cf = $this->getCounterFactory();
246 $number_s = 1;
247 $number_n = 2;
248
249 $g = $gf
250 ->mail()
251 ->withCounter(
252 $cf->status($number_s)
253 )
254 ->withCounter(
255 $cf->novelty($number_n)
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_n), $vals);
265 }

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

+ Here is the call graph for this function:

◆ testWithHighlight()

GlyphTest::testWithHighlight ( )

Definition at line 202 of file GlyphTest.php.

202 : void
203 {
204 $gf = $this->getGlyphFactory();
205
206 $g = $gf->mail();
207 $g2 = $g->withHighlight();
208
209 $this->assertFalse($g->isHighlighted());
210 $this->assertTrue($g2->isHighlighted());
211 }

References getGlyphFactory().

+ 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: