ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
IconTest Class Reference

Test on icon implementation. More...

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

Public Member Functions

 testConstruction ()
 
 testAttributes ()
 
 testSizeModification ()
 
 testSizeModificationWrongParam ()
 
 testDisabledModification ()
 
 testDisabledModificationWrongParam ()
 
 testOutlinedModification ()
 
 testCustomPath ()
 
 testRenderingStandard ()
 
 testRenderingStandardOutlined ()
 
 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 13 of file IconTest.php.

Member Function Documentation

◆ getIconFactory()

IconTest::getIconFactory ( )
private

◆ 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->assertEquals(false, $ico->isDisabled());
41 $this->assertEquals(false, $ico->isOutlined());
42
43 $this->assertNull($ico->getAbbreviation());
44
45 $ico = $ico->withAbbreviation('K');
46 $this->assertEquals('K', $ico->getAbbreviation());
47 }
getIconFactory()
Definition: IconTest.php:15

References $f, and 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 $f, $si, and getIconFactory().

+ Here is the call graph for this function:

◆ testCustomPath()

IconTest::testCustomPath ( )

Definition at line 112 of file IconTest.php.

113 {
114 $f = $this->getIconFactory();
115
116 $ico = $f->custom('/some/path/', 'Custom Icon');
117 $this->assertEquals('/some/path/', $ico->getIconPath());
118 }

References $f, and getIconFactory().

+ Here is the call graph for this function:

◆ testDisabledModification()

IconTest::testDisabledModification ( )

Definition at line 76 of file IconTest.php.

77 {
78 $f = $this->getIconFactory();
79 $ico = $f->standard('course', 'Kurs', 'small');
80
81 $ico = $ico->withDisabled(false);
82 $this->assertEquals(false, $ico->isDisabled());
83
84 $ico = $ico->withDisabled(true);
85 $this->assertEquals(true, $ico->isDisabled());
86 }

References $f, and getIconFactory().

+ Here is the call graph for this function:

◆ testDisabledModificationWrongParam()

IconTest::testDisabledModificationWrongParam ( )

Definition at line 88 of file IconTest.php.

89 {
90 try {
91 $f = $this->getIconFactory();
92 $ico = $f->standard('course', 'Kurs', 'small');
93 $ico = $ico->withDisabled('true');
94 $this->assertFalse("This should not happen");
95 } catch (\InvalidArgumentException $e) {
96 $this->assertTrue(true);
97 }
98 }

References $f, and getIconFactory().

+ Here is the call graph for this function:

◆ testOutlinedModification()

IconTest::testOutlinedModification ( )

Definition at line 100 of file IconTest.php.

101 {
102 $f = $this->getIconFactory();
103 $ico = $f->standard('course', 'Kurs', 'small');
104
105 $ico = $ico->withIsOutlined(true);
106 $this->assertEquals(true, $ico->isOutlined());
107
108 $ico = $ico->withIsOutlined(false);
109 $this->assertEquals(false, $ico->isOutlined());
110 }

References $f, and getIconFactory().

+ Here is the call graph for this function:

◆ testRenderingCustom()

IconTest::testRenderingCustom ( )

Definition at line 170 of file IconTest.php.

171 {
172 $f = $this->getIconFactory();
173 $r = $this->getDefaultRenderer();
174 $path = './templates/default/images/icon_fold.svg';
175
176 $ico = $ico = $f->custom($path, 'Custom', 'medium');
177 $html = $this->normalizeHTML($r->render($ico));
178 $expected = '<div class="icon custom medium" aria-label="Custom">'
179 . ' <img src="./templates/default/images/icon_fold.svg" />'
180 . '</div>';
181 $this->assertEquals($expected, $html);
182
183 //with disabled
184 $ico = $ico->withDisabled(true);
185 $html = $this->normalizeHTML($r->render($ico));
186 $expected = '<div class="icon custom medium disabled" aria-label="Custom">'
187 . ' <img src="./templates/default/images/icon_fold.svg" />'
188 . '</div>';
189 $this->assertEquals($expected, $html);
190
191 //with abbreviation
192 $ico = $ico->withAbbreviation('CS');
193 $html = $this->normalizeHTML($r->render($ico));
194 $expected = '<div class="icon custom medium disabled" aria-label="Custom">'
195 . ' <img src="./templates/default/images/icon_fold.svg" />'
196 . ' <div class="abbreviation">CS</div>'
197 . '</div>';
198
199 $this->assertEquals($expected, $html);
200 }
$path
Definition: aliased.php:25
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79

References $f, $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 120 of file IconTest.php.

121 {
122 $f = $this->getIconFactory();
123 $r = $this->getDefaultRenderer();
124
125 $ico = $ico = $f->standard('crs', 'Course', 'medium');
126 $html = $this->normalizeHTML($r->render($ico));
127 $expected = '<div class="icon crs medium" aria-label="Course"></div>';
128 $this->assertEquals($expected, $html);
129
130 //with disabled
131 $ico = $ico->withDisabled(true);
132 $html = $this->normalizeHTML($r->render($ico));
133 $expected = '<div class="icon crs medium disabled" aria-label="Course"></div>';
134 $this->assertEquals($expected, $html);
135
136 //with abbreviation
137 $ico = $ico->withAbbreviation('CRS');
138 $html = $this->normalizeHTML($r->render($ico));
139 $expected = '<div class="icon crs medium disabled" aria-label="Course">'
140 . ' <div class="abbreviation">CRS</div>'
141 . '</div>';
142 $this->assertEquals($expected, $html);
143 }

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

+ Here is the call graph for this function:

◆ testRenderingStandardOutlined()

IconTest::testRenderingStandardOutlined ( )

Definition at line 145 of file IconTest.php.

146 {
147 $f = $this->getIconFactory();
148 $r = $this->getDefaultRenderer();
149
150 $ico = $ico = $f->standard('crs', 'Course', 'medium')->withIsOutlined(true);
151 $html = $this->normalizeHTML($r->render($ico));
152 $expected = '<div class="icon crs medium outlined" aria-label="Course"></div>';
153 $this->assertEquals($expected, $html);
154
155 //with disabled
156 $ico = $ico->withDisabled(true);
157 $html = $this->normalizeHTML($r->render($ico));
158 $expected = '<div class="icon crs medium disabled outlined" aria-label="Course"></div>';
159 $this->assertEquals($expected, $html);
160
161 //with abbreviation
162 $ico = $ico->withAbbreviation('CRS');
163 $html = $this->normalizeHTML($r->render($ico));
164 $expected = '<div class="icon crs medium disabled outlined" aria-label="Course">'
165 . ' <div class="abbreviation">CRS</div>'
166 . '</div>';
167 $this->assertEquals($expected, $html);
168 }

References $f, $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 49 of file IconTest.php.

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

References $f, and getIconFactory().

+ Here is the call graph for this function:

◆ testSizeModificationWrongParam()

IconTest::testSizeModificationWrongParam ( )

Definition at line 64 of file IconTest.php.

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

References $f, and getIconFactory().

+ Here is the call graph for this function:

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