ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 
 testCustomPath ()
 
 testRenderingStandard ()
 
 testRenderingStandardDisabled (Standard $ico)
 
 testRenderingStandardAbbreviation (Standard $ico)
 
 testRenderingCustom ()
 
 testAllStandardIconsExist ()
 
 testRenderingStandardJSBindable ($ico)
 
 testSetCustomLabel ()
 
 testHTMLInName ()
 
 testHTMLInLabel ()
 
 testHTMLInAbbreviation ()
 
 testHTMLInCustomImage ()
 

Data Fields

const ICON_PATH = __DIR__ . '/../../../../../../../public/assets/images/standard/'
 
const ICON_PATH_REL = './assets/images/'
 

Private Member Functions

 getIconFactory ()
 

Detailed Description

Test on icon implementation.

Definition at line 31 of file IconTest.php.

Member Function Documentation

◆ getIconFactory()

IconTest::getIconFactory ( )
private

◆ testAllStandardIconsExist()

IconTest::testAllStandardIconsExist ( )

Definition at line 165 of file IconTest.php.

165 : void
166 {
167 $f = $this->getIconFactory();
168 $default_icons_abr = $f->standard("nothing", "nothing")->getAllStandardHandles();
169
170 foreach ($default_icons_abr as $icon_abr) {
171 $path = self::ICON_PATH . "icon_" . $icon_abr . ".svg";
172 $this->assertTrue(file_exists($path), "Missing Standard Icon: " . $path);
173 }
174 }
getIconFactory()
Definition: IconTest.php:36
$path
Definition: ltiservices.php:30

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

+ Here is the call graph for this function:

◆ testAttributes()

IconTest::testAttributes ( )

Definition at line 53 of file IconTest.php.

53 : void
54 {
55 $f = $this->getIconFactory();
56
57 $ico = $f->standard('course', 'Kurs');
58 $this->assertEquals('Kurs', $ico->getLabel());
59 $this->assertEquals('course', $ico->getName());
60 $this->assertEquals('small', $ico->getSize());
61 $this->assertEquals(false, $ico->isDisabled());
62
63 $this->assertNull($ico->getAbbreviation());
64
65 $ico = $ico->withAbbreviation('K');
66 $this->assertEquals('K', $ico->getAbbreviation());
67 }

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

+ Here is the call graph for this function:

◆ testConstruction()

IconTest::testConstruction ( )

Definition at line 41 of file IconTest.php.

41 : void
42 {
43 $f = $this->getIconFactory();
44 $this->assertInstanceOf("ILIAS\\UI\\Component\\Symbol\\Icon\\Factory", $f);
45
46 $si = $f->standard('course', 'Kurs');
47 $this->assertInstanceOf("ILIAS\\UI\\Component\\Symbol\\Icon\\Standard", $si);
48
49 $ci = $f->custom('course', 'Kurs');
50 $this->assertInstanceOf("ILIAS\\UI\\Component\\Symbol\\Icon\\Custom", $ci);
51 }

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

+ Here is the call graph for this function:

◆ testCustomPath()

IconTest::testCustomPath ( )

Definition at line 116 of file IconTest.php.

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

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

+ Here is the call graph for this function:

◆ testDisabledModification()

IconTest::testDisabledModification ( )

Definition at line 96 of file IconTest.php.

96 : void
97 {
98 $f = $this->getIconFactory();
99 $ico = $f->standard('course', 'Kurs');
100
101 $ico = $ico->withDisabled(false);
102 $this->assertEquals(false, $ico->isDisabled());
103
104 $ico = $ico->withDisabled(true);
105 $this->assertEquals(true, $ico->isDisabled());
106 }

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

+ Here is the call graph for this function:

◆ testDisabledModificationWrongParam()

IconTest::testDisabledModificationWrongParam ( )

Definition at line 108 of file IconTest.php.

108 : void
109 {
110 $f = $this->getIconFactory();
111 $ico = $f->standard('course', 'Kurs');
112 $this->expectException(TypeError::class);
113 $ico->withDisabled('true');
114 }

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

+ Here is the call graph for this function:

◆ testHTMLInAbbreviation()

IconTest::testHTMLInAbbreviation ( )

Definition at line 218 of file IconTest.php.

218 : void
219 {
220 $ico = $this->getIconFactory()->standard('name', 'label')->withAbbreviation('<h1>abbreviation</h1>');
221 $html = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($ico));
222 $expected = '<img class="icon name small" src="data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgdmlld0JveD0iMCAwIDMyMCAzMjAiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyMCAzMjA7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+DQoJLnN0MHtjbGlwLXBhdGg6dXJsKCNTVkdJRF8wMDAwMDA0Nzc1MTgzNzAxNzcyMjkwMzQ5MDAwMDAwOTM5MjQyNjM5Mzc4Mzc4Mzg1N18pO2ZpbGw6IzRDNjU4Njt9DQo8L3N0eWxlPg0KPGc+DQoJPGc+DQoJCTxkZWZzPg0KCQkJPHJlY3QgaWQ9IlNWR0lEXzFfIiB3aWR0aD0iMzIwIiBoZWlnaHQ9IjMyMCIvPg0KCQk8L2RlZnM+DQoJCTxjbGlwUGF0aCBpZD0iU1ZHSURfMDAwMDAxNjU5Mjc3Njk0MzI5ODM0MDA2OTAwMDAwMTQyOTU5NjQxMjMxNjc4OTQ5MjBfIj4NCgkJCTx1c2UgeGxpbms6aHJlZj0iI1NWR0lEXzFfIiAgc3R5bGU9Im92ZXJmbG93OnZpc2libGU7Ii8+DQoJCTwvY2xpcFBhdGg+DQoJCTxwYXRoIHN0eWxlPSJjbGlwLXBhdGg6dXJsKCNTVkdJRF8wMDAwMDE2NTkyNzc2OTQzMjk4MzQwMDY5MDAwMDAxNDI5NTk2NDEyMzE2Nzg5NDkyMF8pO2ZpbGw6IzRDNjU4NjsiIGQ9Ik05MCw1MEg2MA0KCQkJYy01LjUsMC0xMCw0LjUtMTAsMTB2MjAwYzAsNS41LDQuNSwxMCwxMCwxMGgzMHYtMTVINjVWNjVoMjVWNTB6IE0yNzAsMjYwVjYwYzAtNS41LTQuNS0xMC0xMC0xMGgtMzB2MTVoMjV2MTkwaC0yNXYxNWgzMA0KCQkJQzI2NS41LDI3MCwyNzAsMjY1LjUsMjcwLDI2MCIvPg0KCTwvZz4NCjwvZz4NCjx0ZXh0CiAgIHN0eWxlPSIKICAgICAgZm9udC1zdHlsZTpub3JtYWw7CiAgICAgIGZvbnQtd2VpZ2h0Om5vcm1hbDsKICAgICAgZm9udC1zaXplOjhyZW07CiAgICAgIGZvbnQtZmFtaWx5OnNhbnMtc2VyaWY7CiAgICAgIGxldHRlci1zcGFjaW5nOjBweDsKICAgICAgZmlsbDojMDAwOwogICAgICBmaWxsLW9wYWNpdHk6MTsKICAgICIKICAgIHg9IjUwJSIKICAgIHk9IjU1JSIKICAgIGRvbWluYW50LWJhc2VsaW5lPSJtaWRkbGUiCiAgICB0ZXh0LWFuY2hvcj0ibWlkZGxlIgogID4mbHQ7aDEmZ3Q7YWJicmV2aWF0aW9uJmx0Oy9oMSZndDs8L3RleHQ+PC9zdmc+" alt="label" data-abbreviation="&lt;h1&gt;abbreviation&lt;/h1&gt;"/>';
223 $this->assertEquals($expected, $html);
224 }

References getIconFactory().

+ Here is the call graph for this function:

◆ testHTMLInCustomImage()

IconTest::testHTMLInCustomImage ( )

Definition at line 226 of file IconTest.php.

226 : void
227 {
228 $ico = $this->getIconFactory()->custom('<h1>path</h1>', 'label');
229 $html = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($ico));
230 $expected = '<img class="icon custom small" src="&lt;h1&gt;path&lt;/h1&gt;" alt="label"/>';
231 $this->assertEquals($expected, $html);
232 }

References getIconFactory().

+ Here is the call graph for this function:

◆ testHTMLInLabel()

IconTest::testHTMLInLabel ( )

Definition at line 209 of file IconTest.php.

209 : void
210 {
211 $ico = $this->getIconFactory()->standard('name', '<h1>label</h1>');
212 $html = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($ico));
213 $expected = '<img class="icon name small" src="./assets/images/standard/icon_default.svg" alt="&lt;h1&gt;label&lt;/h1&gt;"/>';
214 $this->assertEquals($expected, $html);
215 }

References getIconFactory().

+ Here is the call graph for this function:

◆ testHTMLInName()

IconTest::testHTMLInName ( )

Definition at line 201 of file IconTest.php.

201 : void
202 {
203 $ico = $this->getIconFactory()->standard('<h1>name</h1>', 'label');
204 $html = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($ico));
205 $expected = '<img class="icon &lt;h1&gt;name&lt;/h1&gt; small" src="./assets/images/standard/icon_default.svg" alt="label"/>';
206 $this->assertEquals($expected, $html);
207 }

References getIconFactory().

+ Here is the call graph for this function:

◆ testRenderingCustom()

IconTest::testRenderingCustom ( )

Definition at line 155 of file IconTest.php.

155 : Custom
156 {
157 $path = './assets/images/standard/icon_fold.svg';
158 $ico = $this->getIconFactory()->custom($path, 'Custom', 'medium');
159 $html = $this->normalizeHTML($this->getDefaultRenderer()->render($ico));
160 $expected = '<img class="icon custom medium" src="./assets/images/standard/icon_fold.svg" alt="Custom"/>';
161 $this->assertEquals($expected, $html);
162 return $ico;
163 }
This describes the behavior of an custom icon.
Definition: Custom.php:27

References $path, and getIconFactory().

+ Here is the call graph for this function:

◆ testRenderingStandard()

IconTest::testRenderingStandard ( )

Definition at line 124 of file IconTest.php.

124 : Standard
125 {
126 $ico = $this->getIconFactory()->standard('crs', 'Course', 'medium');
127 $html = $this->normalizeHTML($this->getDefaultRenderer()->render($ico));
128 $path = self::ICON_PATH_REL . 'standard/icon_crs.svg';
129 $expected = "<img class=\"icon crs medium\" src=\"$path\" alt=\"Course\"/>";
130 $this->assertEquals($expected, $html);
131 return $ico;
132 }
This describes the specific behavior of an ILIAS standard icon.
Definition: Standard.php:27

References $path, and getIconFactory().

+ Here is the call graph for this function:

◆ testRenderingStandardAbbreviation()

IconTest::testRenderingStandardAbbreviation ( Standard  $ico)

Definition at line 145 of file IconTest.php.

145 : void
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,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgdmlld0JveD0iMCAwIDMyMCAzMjAiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyMCAzMjA7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+DQoJLnN0MHtjbGlwLXBhdGg6dXJsKCNTVkdJRF8wMDAwMDA4MDE3OTA3MDMwNjQ3MTMxMjU3MDAwMDAwNzg1OTYxOTkxMTQ1NzE1MjM5MV8pO2ZpbGw6IzRDNjU4Njt9DQoJLnN0MXtmaWxsOm5vbmU7fQ0KPC9zdHlsZT4NCjxnPg0KCTxnPg0KCQk8ZGVmcz4NCgkJCTxyZWN0IGlkPSJTVkdJRF8xXyIgeD0iNTUiIHk9IjQwIiB3aWR0aD0iMjEwIiBoZWlnaHQ9IjIzNy41Ii8+DQoJCTwvZGVmcz4NCgkJPGNsaXBQYXRoIGlkPSJTVkdJRF8wMDAwMDE2NzM2MjYwODc4ODY3MDYzMDMwMDAwMDAwODg4OTk5NTQwMjk4MTcwOTk1M18iPg0KCQkJPHVzZSB4bGluazpocmVmPSIjU1ZHSURfMV8iICBzdHlsZT0ib3ZlcmZsb3c6dmlzaWJsZTsiLz4NCgkJPC9jbGlwUGF0aD4NCgkJPHBhdGggc3R5bGU9ImNsaXAtcGF0aD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0ibWlkZGxlIgogICAgdGV4dC1hbmNob3I9Im1pZGRsZSIKICA+Q1JTPC90ZXh0Pjwvc3ZnPg==" alt="Course" data-abbreviation="CRS"/>
151imgtag;
152 $this->assertEquals(trim($expected), trim($html));
153 }
withAbbreviation(string $abbreviation)
Set the abbreviation for this icon.

References ILIAS\UI\Component\Symbol\Icon\Icon\withAbbreviation().

+ Here is the call graph for this function:

◆ testRenderingStandardDisabled()

IconTest::testRenderingStandardDisabled ( Standard  $ico)

Definition at line 135 of file IconTest.php.

135 : void
136 {
137 $ico = $ico->withDisabled(true);
138 $html = $this->normalizeHTML($this->getDefaultRenderer()->render($ico));
139 $path = self::ICON_PATH_REL . 'standard/icon_crs.svg';
140 $expected = "<img class=\"icon crs medium disabled\" src=\"$path\" alt=\"Course\" aria-disabled=\"true\"/>";
141 $this->assertEquals($expected, $html);
142 }
withDisabled(bool $is_disabled)
Get an icon like this, but marked as disabled.

References $path, and ILIAS\UI\Component\Symbol\Icon\Icon\withDisabled().

+ Here is the call graph for this function:

◆ testRenderingStandardJSBindable()

IconTest::testRenderingStandardJSBindable (   $ico)

Definition at line 177 of file IconTest.php.

177 : void
178 {
179 $ico = $ico->withAdditionalOnLoadCode(function ($id) {
180 return 'alert();';
181 });
182 $html = $this->normalizeHTML($this->getDefaultRenderer()->render($ico));
183 $path = self::ICON_PATH_REL . 'standard/icon_crs.svg';
184 $expected = "<img aria-disabled=\"true\"/>";
185 $expected = $this->normalizeHTML("<img id=\"id_1\" class=\"icon crs medium\" src=\"$path\" alt=\"Course\"/>");
186 $this->assertEquals($expected, $html);
187 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, and $path.

◆ testSetCustomLabel()

IconTest::testSetCustomLabel ( )

Definition at line 189 of file IconTest.php.

189 : Custom
190 {
191 $path = './assets/images/icon_fold.svg';
192 $ico = $this->getIconFactory()->custom($path, 'Custom', 'medium');
193 $ico->setLabel("New Custom Icon Label");
194 $html = $this->normalizeHTML($this->getDefaultRenderer()->render($ico));
195 $expected = '<img class="icon custom medium" src="./assets/images/icon_fold.svg" alt="New Custom Icon Label"/>';
196 $this->assertEquals($expected, $html);
197
198 return $ico;
199 }

References $path, and getIconFactory().

+ Here is the call graph for this function:

◆ testSizeModification()

IconTest::testSizeModification ( )

Definition at line 69 of file IconTest.php.

69 : void
70 {
71 $f = $this->getIconFactory();
72 $ico = $f->standard('course', 'Kurs');
73
74 $ico = $ico->withSize('medium');
75 $this->assertEquals('medium', $ico->getSize());
76
77 $ico = $ico->withSize('large');
78 $this->assertEquals('large', $ico->getSize());
79
80 $ico = $ico->withSize('small');
81 $this->assertEquals('small', $ico->getSize());
82 }

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

+ Here is the call graph for this function:

◆ testSizeModificationWrongParam()

IconTest::testSizeModificationWrongParam ( )

Definition at line 84 of file IconTest.php.

84 : void
85 {
86 try {
87 $f = $this->getIconFactory();
88 $ico = $f->standard('course', 'Kurs');
89 $ico->withSize('tiny');
90 $this->assertFalse("This should not happen");
91 } catch (InvalidArgumentException $e) {
92 $this->assertTrue(true);
93 }
94 }

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

+ Here is the call graph for this function:

Field Documentation

◆ ICON_PATH

const IconTest::ICON_PATH = __DIR__ . '/../../../../../../../public/assets/images/standard/'

Definition at line 33 of file IconTest.php.

◆ ICON_PATH_REL

const IconTest::ICON_PATH_REL = './assets/images/'

Definition at line 34 of file IconTest.php.


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