ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
IconTest Class Reference

Test on icon implementation. More...

+ Inheritance diagram for IconTest:
+ Collaboration diagram for IconTest:

Public Member Functions

 testConstruction ()
 
 testAttributes ()
 
 testSizeModification ()
 
 testSizeModificationWrongParam ()
 
 testCustomPath ()
 
 testRenderingStandard ()
 
 testRenderingCustom ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Private Member Functions

 getIconFactory ()
 

Detailed Description

Test on icon implementation.

Definition at line 12 of file IconTest.php.

Member Function Documentation

◆ getIconFactory()

IconTest::getIconFactory ( )
private

Definition at line 14 of file IconTest.php.

15 {
16 $f = new \ILIAS\UI\Implementation\Factory();
17 return $f->icon();
18 }

Referenced by testAttributes(), testConstruction(), testCustomPath(), testRenderingCustom(), testRenderingStandard(), testSizeModification(), and testSizeModificationWrongParam().

+ Here is the caller graph for this function:

◆ testAttributes()

IconTest::testAttributes ( )

Definition at line 32 of file IconTest.php.

33 {
34 $f = $this->getIconFactory();
35
36 $ico = $f->standard('course', 'Kurs');
37 $this->assertEquals('Kurs', $ico->getAriaLabel());
38 $this->assertEquals('course', $ico->getName());
39 $this->assertEquals('small', $ico->getSize());
40 $this->assertNull($ico->getAbbreviation());
41
42 $ico = $ico->withAbbreviation('K');
43 $this->assertEquals('K', $ico->getAbbreviation());
44 }
getIconFactory()
Definition: IconTest.php:14

References getIconFactory().

+ Here is the call graph for this function:

◆ testConstruction()

IconTest::testConstruction ( )

Definition at line 20 of file IconTest.php.

21 {
22 $f = $this->getIconFactory();
23 $this->assertInstanceOf("ILIAS\\UI\\Component\\Icon\\Factory", $f);
24
25 $si = $f->standard('course', 'Kurs');
26 $this->assertInstanceOf("ILIAS\\UI\\Component\\Icon\\Standard", $si);
27
28 $ci = $f->custom('course', 'Kurs');
29 $this->assertInstanceOf("ILIAS\\UI\\Component\\Icon\\Custom", $ci);
30 }

References $si, and getIconFactory().

+ Here is the call graph for this function:

◆ testCustomPath()

IconTest::testCustomPath ( )

Definition at line 73 of file IconTest.php.

74 {
75 $f = $f = $this->getIconFactory();
76
77 $ico = $f->custom('/some/path/', 'Custom Icon');
78 $this->assertEquals('/some/path/', $ico->getIconPath());
79 }

References getIconFactory().

+ Here is the call graph for this function:

◆ testRenderingCustom()

IconTest::testRenderingCustom ( )

Definition at line 100 of file IconTest.php.

101 {
102 $f = $f = $this->getIconFactory();
103 $r = $this->getDefaultRenderer();
104 $path = './templates/default/images/icon_fold.svg';
105
106 $ico = $ico = $f->custom($path, 'Custom', 'medium');
107 $html = $this->normalizeHTML($r->render($ico));
108 $expected = '<div class="icon custom medium" aria-label="Custom">'
109 . ' <img src="./templates/default/images/icon_fold.svg" />'
110 . '</div>';
111 $this->assertEquals($expected, $html);
112
113 //with abbreviation
114 $ico = $ico->withAbbreviation('CS');
115 $html = $this->normalizeHTML($r->render($ico));
116 $expected = '<div class="icon custom medium" aria-label="Custom">'
117 . ' <img src="./templates/default/images/icon_fold.svg" />'
118 . ' <div class="abbreviation">CS</div>'
119 . '</div>';
120
121 $this->assertEquals($expected, $html);
122 }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
normalizeHTML($html)
Definition: Base.php:243
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79

References $html, $path, $r, ILIAS_UI_TestBase\getDefaultRenderer(), getIconFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ testRenderingStandard()

IconTest::testRenderingStandard ( )

Definition at line 81 of file IconTest.php.

82 {
83 $f = $f = $this->getIconFactory();
84 $r = $this->getDefaultRenderer();
85
86 $ico = $ico = $f->standard('crs', 'Course', 'medium');
87 $html = $this->normalizeHTML($r->render($ico));
88 $expected = '<div class="icon crs medium" aria-label="Course"></div>';
89 $this->assertEquals($expected, $html);
90
91 //with abbreviation
92 $ico = $ico->withAbbreviation('CRS');
93 $html = $this->normalizeHTML($r->render($ico));
94 $expected = '<div class="icon crs medium" aria-label="Course">'
95 . ' <div class="abbreviation">CRS</div>'
96 . '</div>';
97 $this->assertEquals($expected, $html);
98 }

References $html, $r, ILIAS_UI_TestBase\getDefaultRenderer(), getIconFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ testSizeModification()

IconTest::testSizeModification ( )

Definition at line 46 of file IconTest.php.

47 {
48 $f = $f = $this->getIconFactory();
49 $ico = $f->standard('course', 'Kurs');
50
51 $ico = $ico->withSize('medium');
52 $this->assertEquals('medium', $ico->getSize());
53
54 $ico = $ico->withSize('large');
55 $this->assertEquals('large', $ico->getSize());
56
57 $ico = $ico->withSize('small');
58 $this->assertEquals('small', $ico->getSize());
59 }

References getIconFactory().

+ Here is the call graph for this function:

◆ testSizeModificationWrongParam()

IconTest::testSizeModificationWrongParam ( )

Definition at line 61 of file IconTest.php.

62 {
63 try {
64 $f = $f = $this->getIconFactory();
65 $ico = $f->standard('course', 'Kurs');
66 $ico = $ico->withSize('tiny');
67 $this->assertFalse("This should not happen");
68 } catch (\InvalidArgumentException $e) {
69 $this->assertTrue(true);
70 }
71 }

References getIconFactory().

+ Here is the call graph for this function:

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