ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 
 testAllStandardIconsExist ()
 
 testAllOutlinedIconsExist ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Data Fields

const ICON_PATH = __DIR__ . "/../../../../../templates/default/images/"
 
const ICON_OUTLINED_PATH = self::ICON_PATH . "outlined/"
 

Private Member Functions

 getIconFactory ()
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Test on icon implementation.

Definition at line 12 of file IconTest.php.

Member Function Documentation

◆ getIconFactory()

◆ testAllOutlinedIconsExist()

IconTest::testAllOutlinedIconsExist ( )

Definition at line 215 of file IconTest.php.

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

216  {
217  $f = $this->getIconFactory();
218  $default_icons_abr = $f->standard("nothing", "nothing")->getAllStandardHandles();
219 
220  foreach ($default_icons_abr as $icon_abr) {
221  $path = self::ICON_OUTLINED_PATH . "icon_" . $icon_abr . ".svg";
222 
223  $this->assertTrue(file_exists($path), "Missing Outlined Icon: " . $path);
224  }
225  }
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

◆ testAllStandardIconsExist()

IconTest::testAllStandardIconsExist ( )

Definition at line 204 of file IconTest.php.

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

205  {
206  $f = $this->getIconFactory();
207  $default_icons_abr = $f->standard("nothing", "nothing")->getAllStandardHandles();
208 
209  foreach ($default_icons_abr as $icon_abr) {
210  $path = self::ICON_PATH . "icon_" . $icon_abr . ".svg";
211  $this->assertTrue(file_exists($path), "Missing Standard Icon: " . $path);
212  }
213  }
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

◆ testAttributes()

IconTest::testAttributes ( )

Definition at line 34 of file IconTest.php.

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

35  {
36  $f = $this->getIconFactory();
37 
38  $ico = $f->standard('course', 'Kurs');
39  $this->assertEquals('Kurs', $ico->getAriaLabel());
40  $this->assertEquals('course', $ico->getName());
41  $this->assertEquals('small', $ico->getSize());
42  $this->assertEquals(false, $ico->isDisabled());
43  $this->assertEquals(false, $ico->isOutlined());
44 
45  $this->assertNull($ico->getAbbreviation());
46 
47  $ico = $ico->withAbbreviation('K');
48  $this->assertEquals('K', $ico->getAbbreviation());
49  }
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

◆ testConstruction()

IconTest::testConstruction ( )

Definition at line 22 of file IconTest.php.

References Vendor\Package\$f, $si, and getIconFactory().

23  {
24  $f = $this->getIconFactory();
25  $this->assertInstanceOf("ILIAS\\UI\\Component\\Symbol\\Icon\\Factory", $f);
26 
27  $si = $f->standard('course', 'Kurs');
28  $this->assertInstanceOf("ILIAS\\UI\\Component\\Symbol\\Icon\\Standard", $si);
29 
30  $ci = $f->custom('course', 'Kurs');
31  $this->assertInstanceOf("ILIAS\\UI\\Component\\Symbol\\Icon\\Custom", $ci);
32  }
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

◆ testCustomPath()

IconTest::testCustomPath ( )

Definition at line 114 of file IconTest.php.

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

115  {
116  $f = $this->getIconFactory();
117 
118  $ico = $f->custom('/some/path/', 'Custom Icon');
119  $this->assertEquals('/some/path/', $ico->getIconPath());
120  }
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

◆ testDisabledModification()

IconTest::testDisabledModification ( )

Definition at line 78 of file IconTest.php.

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

79  {
80  $f = $this->getIconFactory();
81  $ico = $f->standard('course', 'Kurs', 'small');
82 
83  $ico = $ico->withDisabled(false);
84  $this->assertEquals(false, $ico->isDisabled());
85 
86  $ico = $ico->withDisabled(true);
87  $this->assertEquals(true, $ico->isDisabled());
88  }
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

◆ testDisabledModificationWrongParam()

IconTest::testDisabledModificationWrongParam ( )

Definition at line 90 of file IconTest.php.

References Vendor\Package\$e, Vendor\Package\$f, and getIconFactory().

91  {
92  try {
93  $f = $this->getIconFactory();
94  $ico = $f->standard('course', 'Kurs', 'small');
95  $ico = $ico->withDisabled('true');
96  $this->assertFalse("This should not happen");
97  } catch (\InvalidArgumentException $e) {
98  $this->assertTrue(true);
99  }
100  }
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

◆ testOutlinedModification()

IconTest::testOutlinedModification ( )

Definition at line 102 of file IconTest.php.

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

103  {
104  $f = $this->getIconFactory();
105  $ico = $f->standard('course', 'Kurs', 'small');
106 
107  $ico = $ico->withIsOutlined(true);
108  $this->assertEquals(true, $ico->isOutlined());
109 
110  $ico = $ico->withIsOutlined(false);
111  $this->assertEquals(false, $ico->isOutlined());
112  }
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

◆ testRenderingCustom()

IconTest::testRenderingCustom ( )

Definition at line 172 of file IconTest.php.

References Vendor\Package\$f, ILIAS_UI_TestBase\getDefaultRenderer(), getIconFactory(), and ILIAS_UI_TestBase\normalizeHTML().

173  {
174  $f = $this->getIconFactory();
175  $r = $this->getDefaultRenderer();
176  $path = './templates/default/images/icon_fold.svg';
177 
178  $ico = $ico = $f->custom($path, 'Custom', 'medium');
179  $html = $this->normalizeHTML($r->render($ico));
180  $expected = '<div class="icon custom medium" aria-label="Custom">'
181  . ' <img src="./templates/default/images/icon_fold.svg" />'
182  . '</div>';
183  $this->assertEquals($expected, $html);
184 
185  //with disabled
186  $ico = $ico->withDisabled(true);
187  $html = $this->normalizeHTML($r->render($ico));
188  $expected = '<div class="icon custom medium disabled" aria-label="Custom">'
189  . ' <img src="./templates/default/images/icon_fold.svg" />'
190  . '</div>';
191  $this->assertEquals($expected, $html);
192 
193  //with abbreviation
194  $ico = $ico->withAbbreviation('CS');
195  $html = $this->normalizeHTML($r->render($ico));
196  $expected = '<div class="icon custom medium disabled" aria-label="Custom">'
197  . ' <img src="./templates/default/images/icon_fold.svg" />'
198  . ' <div class="abbreviation">CS</div>'
199  . '</div>';
200 
201  $this->assertEquals($expected, $html);
202  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

◆ testRenderingStandard()

IconTest::testRenderingStandard ( )

Definition at line 122 of file IconTest.php.

References Vendor\Package\$f, ILIAS_UI_TestBase\getDefaultRenderer(), getIconFactory(), and ILIAS_UI_TestBase\normalizeHTML().

123  {
124  $f = $this->getIconFactory();
125  $r = $this->getDefaultRenderer();
126 
127  $ico = $ico = $f->standard('crs', 'Course', 'medium');
128  $html = $this->normalizeHTML($r->render($ico));
129  $expected = '<div class="icon crs medium" aria-label="Course"></div>';
130  $this->assertEquals($expected, $html);
131 
132  //with disabled
133  $ico = $ico->withDisabled(true);
134  $html = $this->normalizeHTML($r->render($ico));
135  $expected = '<div class="icon crs medium disabled" aria-label="Course"></div>';
136  $this->assertEquals($expected, $html);
137 
138  //with abbreviation
139  $ico = $ico->withAbbreviation('CRS');
140  $html = $this->normalizeHTML($r->render($ico));
141  $expected = '<div class="icon crs medium disabled" aria-label="Course">'
142  . ' <div class="abbreviation">CRS</div>'
143  . '</div>';
144  $this->assertEquals($expected, $html);
145  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

◆ testRenderingStandardOutlined()

IconTest::testRenderingStandardOutlined ( )

Definition at line 147 of file IconTest.php.

References Vendor\Package\$f, ILIAS_UI_TestBase\getDefaultRenderer(), getIconFactory(), and ILIAS_UI_TestBase\normalizeHTML().

148  {
149  $f = $this->getIconFactory();
150  $r = $this->getDefaultRenderer();
151 
152  $ico = $ico = $f->standard('crs', 'Course', 'medium')->withIsOutlined(true);
153  $html = $this->normalizeHTML($r->render($ico));
154  $expected = '<div class="icon crs medium outlined" aria-label="Course"></div>';
155  $this->assertEquals($expected, $html);
156 
157  //with disabled
158  $ico = $ico->withDisabled(true);
159  $html = $this->normalizeHTML($r->render($ico));
160  $expected = '<div class="icon crs medium disabled outlined" aria-label="Course"></div>';
161  $this->assertEquals($expected, $html);
162 
163  //with abbreviation
164  $ico = $ico->withAbbreviation('CRS');
165  $html = $this->normalizeHTML($r->render($ico));
166  $expected = '<div class="icon crs medium disabled outlined" aria-label="Course">'
167  . ' <div class="abbreviation">CRS</div>'
168  . '</div>';
169  $this->assertEquals($expected, $html);
170  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

◆ testSizeModification()

IconTest::testSizeModification ( )

Definition at line 51 of file IconTest.php.

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

52  {
53  $f = $this->getIconFactory();
54  $ico = $f->standard('course', 'Kurs');
55 
56  $ico = $ico->withSize('medium');
57  $this->assertEquals('medium', $ico->getSize());
58 
59  $ico = $ico->withSize('large');
60  $this->assertEquals('large', $ico->getSize());
61 
62  $ico = $ico->withSize('small');
63  $this->assertEquals('small', $ico->getSize());
64  }
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

◆ testSizeModificationWrongParam()

IconTest::testSizeModificationWrongParam ( )

Definition at line 66 of file IconTest.php.

References Vendor\Package\$e, Vendor\Package\$f, and getIconFactory().

67  {
68  try {
69  $f = $this->getIconFactory();
70  $ico = $f->standard('course', 'Kurs');
71  $ico = $ico->withSize('tiny');
72  $this->assertFalse("This should not happen");
73  } catch (\InvalidArgumentException $e) {
74  $this->assertTrue(true);
75  }
76  }
getIconFactory()
Definition: IconTest.php:17
+ Here is the call graph for this function:

Field Documentation

◆ ICON_OUTLINED_PATH

const IconTest::ICON_OUTLINED_PATH = self::ICON_PATH . "outlined/"

Definition at line 15 of file IconTest.php.

◆ ICON_PATH

const IconTest::ICON_PATH = __DIR__ . "/../../../../../templates/default/images/"

Definition at line 14 of file IconTest.php.


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