ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ()
 
 testRenderingStandardDisabled ($ico)
 @depends testRenderingStandard More...
 
 testRenderingStandardAbbreviation ($ico)
 @depends testRenderingStandard More...
 
 testRenderingStandardOutlined ($ico)
 @depends testRenderingStandard More...
 
 testRenderingCustom ()
 
 testAllStandardIconsExist ()
 
 testAllOutlinedIconsExist ()
 
 testRenderingStandardJSBindable ($ico)
 @depends testRenderingStandard More...
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 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()

IconTest::getIconFactory ( )
private

◆ testAllOutlinedIconsExist()

IconTest::testAllOutlinedIconsExist ( )

Definition at line 187 of file IconTest.php.

188 {
189 $f = $this->getIconFactory();
190 $default_icons_abr = $f->standard("nothing", "nothing")->getAllStandardHandles();
191
192 foreach ($default_icons_abr as $icon_abr) {
193 $path = self::ICON_OUTLINED_PATH . "icon_" . $icon_abr . ".svg";
194
195 $this->assertTrue(file_exists($path), "Missing Outlined Icon: " . $path);
196 }
197 }
getIconFactory()
Definition: IconTest.php:17

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

+ Here is the call graph for this function:

◆ testAllStandardIconsExist()

IconTest::testAllStandardIconsExist ( )

Definition at line 176 of file IconTest.php.

177 {
178 $f = $this->getIconFactory();
179 $default_icons_abr = $f->standard("nothing", "nothing")->getAllStandardHandles();
180
181 foreach ($default_icons_abr as $icon_abr) {
182 $path = self::ICON_PATH . "icon_" . $icon_abr . ".svg";
183 $this->assertTrue(file_exists($path), "Missing Standard Icon: " . $path);
184 }
185 }

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

+ Here is the call graph for this function:

◆ testAttributes()

IconTest::testAttributes ( )

Definition at line 34 of file IconTest.php.

35 {
36 $f = $this->getIconFactory();
37
38 $ico = $f->standard('course', 'Kurs');
39 $this->assertEquals('Kurs', $ico->getLabel());
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 }

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

+ Here is the call graph for this function:

◆ testConstruction()

IconTest::testConstruction ( )

Definition at line 22 of file IconTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testCustomPath()

IconTest::testCustomPath ( )

Definition at line 114 of file IconTest.php.

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

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

+ Here is the call graph for this function:

◆ testDisabledModification()

IconTest::testDisabledModification ( )

Definition at line 78 of file IconTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testDisabledModificationWrongParam()

IconTest::testDisabledModificationWrongParam ( )

Definition at line 90 of file IconTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testOutlinedModification()

IconTest::testOutlinedModification ( )

Definition at line 102 of file IconTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testRenderingCustom()

IconTest::testRenderingCustom ( )

Definition at line 166 of file IconTest.php.

167 {
168 $path = './templates/default/images/icon_fold.svg';
169 $ico = $this->getIconFactory()->custom($path, 'Custom', 'medium');
170 $html = $this->normalizeHTML($this->getDefaultRenderer()->render($ico));
171 $expected = '<img class="icon custom medium" src="./templates/default/images/icon_fold.svg" alt="Custom"/>';
172 $this->assertEquals($expected, $html);
173 return $ico;
174 }
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
normalizeHTML($html)
Definition: Base.php:363

References ILIAS_UI_TestBase\getDefaultRenderer(), getIconFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ testRenderingStandard()

IconTest::testRenderingStandard ( )

Definition at line 122 of file IconTest.php.

123 {
124 $ico = $this->getIconFactory()->standard('crs', 'Course', 'medium');
125 $html = $this->normalizeHTML($this->getDefaultRenderer()->render($ico));
126 $expected = '<img class="icon crs medium" src="./templates/default/images/icon_crs.svg" alt="Course"/>';
127 $this->assertEquals($expected, $html);
128 return $ico;
129 }

References ILIAS_UI_TestBase\getDefaultRenderer(), getIconFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ testRenderingStandardAbbreviation()

IconTest::testRenderingStandardAbbreviation (   $ico)

@depends testRenderingStandard

Definition at line 145 of file IconTest.php.

146 {
147 $ico = $ico->withAbbreviation('CRS');
148 $html = $this->normalizeHTML($this->getDefaultRenderer()->render($ico));
149 $expected = <<<imgtag
150<img class="icon crs medium" src="data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxuczp4PSImbnNfZXh0ZW5kOyIgeG1sbnM6aT0iJm5zX2FpOyIgeG1sbnM6Z3JhcGg9IiZuc19ncmFwaHM7Ig0KCSB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjMycHgiIGhlaWdodD0iMzJweCINCgkgdmlld0JveD0iMCAwIDMyIDMyIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAzMiAzMiIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8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Pg0KCQk8cGF0aCBmaWxsPSIjNEMzMzI3IiBkPSJNMjYsMTZINnYyaDUuMjg0bC0zLjk0Myw4LjU4MmMtMC4yMywwLjUwMi0wLjAxMSwxLjA5NiwwLjQ5MSwxLjMyNkM3Ljk2OCwyNy45NzEsOC4xMSwyOCw4LjI1LDI4DQoJCQljMC4zNzgsMCwwLjc0MS0wLjIxNiwwLjkwOS0wLjU4MmwxLjQ5Ni0zLjI1NmgxMC42OTFsMS40OTYsMy4yNTZDMjMuMDEsMjcuNzg0LDIzLjM3MiwyOCwyMy43NTEsMjgNCgkJCWMwLjE0LDAsMC4yODItMC4wMjksMC40MTctMC4wOTJjMC41MDItMC4yMywwLjcyMi0wLjgyNCwwLjQ5MS0xLjMyNkwyMC43MTYsMThIMjZWMTZ6IE0xOC41OTEsMTguMTY4bDEuODM1LDMuOTk0aC04Ljg1Mw0KCQkJbDEuODM1LTMuOTk0YzAuMDI1LTAuMDU0LDAuMDI1LTAuMTEyLDAuMDQtMC4xNjhoNS4xMDRDMTguNTY2LDE4LjA1NiwxOC41NjYsMTguMTEzLDE4LjU5MSwxOC4xNjh6Ii8+DQoJPC9nPg0KPC9zd2l0Y2g+DQo8dGV4dAogICBzdHlsZT0iCiAgICAgIGZvbnQtc3R5bGU6bm9ybWFsOwogICAgICBmb250LXdlaWdodDpub3JtYWw7CiAgICAgIGZvbnQtc2l6ZToxNHB4OwogICAgICBmb250LWZhbWlseTpzYW5zLXNlcmlmOwogICAgICBsZXR0ZXItc3BhY2luZzowcHg7CiAgICAgIGZpbGw6IzAwMDsKICAgICAgZmlsbC1vcGFjaXR5OjE7CiAgICAiCiAgICB4PSI1MCUiCiAgICB5PSI1NSUiCiAgICBkb21pbmFudC1iYXNlbGluZT0ibWlkZGxlIgogICAgdGV4dC1hbmNob3I9Im1pZGRsZSIKICA+Q1JTPC90ZXh0Pjwvc3ZnPg==" alt="Course" data-abbreviation="CRS"/>
151imgtag;
152 $this->assertEquals(trim($expected), trim($html));
153 }

References ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ testRenderingStandardDisabled()

IconTest::testRenderingStandardDisabled (   $ico)

@depends testRenderingStandard

Definition at line 134 of file IconTest.php.

135 {
136 $ico = $ico->withDisabled(true);
137 $html = $this->normalizeHTML($this->getDefaultRenderer()->render($ico));
138 $expected = '<img class="icon crs medium disabled" src="./templates/default/images/icon_crs.svg" alt="Course" aria-disabled="true"/>';
139 $this->assertEquals($expected, $html);
140 }

References ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ testRenderingStandardJSBindable()

IconTest::testRenderingStandardJSBindable (   $ico)

@depends testRenderingStandard

Definition at line 202 of file IconTest.php.

203 {
204 $ico = $ico->withAdditionalOnLoadCode(function ($id) {
205 return 'alert();';
206 });
207 $html = $this->normalizeHTML($this->getDefaultRenderer()->render($ico));
208 $expected = $this->normalizeHTML('<img id="id_1" class="icon crs medium" src="./templates/default/images/icon_crs.svg" alt="Course"/>');
209 $this->assertEquals($expected, $html);
210 }

References ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ testRenderingStandardOutlined()

IconTest::testRenderingStandardOutlined (   $ico)

@depends testRenderingStandard

Definition at line 158 of file IconTest.php.

159 {
160 $ico = $ico->withIsOutlined(true);
161 $html = $this->normalizeHTML($this->getDefaultRenderer()->render($ico));
162 $expected = '<img class="icon crs medium outlined" src="./templates/default/images/outlined/icon_crs.svg" alt="Course"/>';
163 $this->assertEquals($expected, $html);
164 }

References ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ testSizeModification()

IconTest::testSizeModification ( )

Definition at line 51 of file IconTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testSizeModificationWrongParam()

IconTest::testSizeModificationWrongParam ( )

Definition at line 66 of file IconTest.php.

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 }

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

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