Test on icon implementation.
More...
|
const | ICON_PATH = __DIR__ . '/../../../../../../../public/assets/images/standard/' |
|
const | ICON_PATH_REL = './assets/images/' |
|
Test on icon implementation.
Definition at line 31 of file IconTest.php.
◆ getIconFactory()
IconTest::getIconFactory |
( |
| ) |
|
|
private |
Definition at line 36 of file IconTest.php.
36 : I\Component\Symbol\Icon\Factory
37 {
38 return new I\Component\Symbol\Icon\Factory();
39 }
Referenced by testAllStandardIconsExist(), testAttributes(), testConstruction(), testCustomPath(), testDisabledModification(), testDisabledModificationWrongParam(), testHTMLInAbbreviation(), testHTMLInCustomImage(), testHTMLInLabel(), testHTMLInName(), testRenderingCustom(), testRenderingStandard(), testSetCustomLabel(), testSizeModification(), and testSizeModificationWrongParam().
◆ testAllStandardIconsExist()
IconTest::testAllStandardIconsExist |
( |
| ) |
|
Definition at line 165 of file IconTest.php.
165 : void
166 {
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 }
References Vendor\Package\$f, $path, and getIconFactory().
◆ testAttributes()
IconTest::testAttributes |
( |
| ) |
|
Definition at line 53 of file IconTest.php.
53 : void
54 {
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().
◆ testConstruction()
IconTest::testConstruction |
( |
| ) |
|
Definition at line 41 of file IconTest.php.
41 : void
42 {
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().
◆ testCustomPath()
IconTest::testCustomPath |
( |
| ) |
|
◆ testDisabledModification()
IconTest::testDisabledModification |
( |
| ) |
|
Definition at line 96 of file IconTest.php.
96 : void
97 {
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().
◆ testDisabledModificationWrongParam()
IconTest::testDisabledModificationWrongParam |
( |
| ) |
|
◆ 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+DQoJLnN0MHtjbGlwLXBhdGg6dXJsKCNTVkdJRF8wMDAwMDA0Nzc1MTgzNzAxNzcyMjkw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wJSIKICAgIHk9IjU1JSIKICAgIGRvbWluYW50LWJhc2VsaW5lPSJtaWRkbGUiCiAgICB0ZXh0LWFuY2hvcj0ibWlkZGxlIgogID4mbHQ7aDEmZ3Q7YWJicmV2aWF0aW9uJmx0Oy9oMSZndDs8L3RleHQ+PC9zdmc+" alt="label" data-abbreviation="<h1>abbreviation</h1>"/>';
223 $this->assertEquals($expected, $html);
224 }
References getIconFactory().
◆ testHTMLInCustomImage()
IconTest::testHTMLInCustomImage |
( |
| ) |
|
Definition at line 226 of file IconTest.php.
226 : void
227 {
229 $html = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($ico));
230 $expected = '<img class="icon custom small" src="<h1>path</h1>" alt="label"/>';
231 $this->assertEquals($expected, $html);
232 }
References getIconFactory().
◆ 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="<h1>label</h1>"/>';
214 $this->assertEquals($expected, $html);
215 }
References getIconFactory().
◆ 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 <h1>name</h1> small" src="./assets/images/standard/icon_default.svg" alt="label"/>';
206 $this->assertEquals($expected, $html);
207 }
References getIconFactory().
◆ testRenderingCustom()
IconTest::testRenderingCustom |
( |
| ) |
|
Definition at line 155 of file IconTest.php.
156 {
157 $path =
'./assets/images/standard/icon_fold.svg';
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.
References $path, and getIconFactory().
◆ testRenderingStandard()
IconTest::testRenderingStandard |
( |
| ) |
|
Definition at line 124 of file IconTest.php.
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.
References $path, and getIconFactory().
◆ testRenderingStandardAbbreviation()
IconTest::testRenderingStandardAbbreviation |
( |
Standard |
$ico | ) |
|
Definition at line 145 of file IconTest.php.
145 : void
146 {
148 $html = $this->normalizeHTML($this->getDefaultRenderer()->render($ico));
149 $expected = <<<imgtag
150<img class="icon crs medium" src="data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgdmlld0JveD0iMCAwIDMyMCAzMjAiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyMCAzMjA7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+DQoJLnN0MHtjbGlwLXBhdGg6dXJsKCNTVkdJRF8wMDAwMDA4MDE3OTA3MDMwNjQ3MTMxMjU3MDAwMDAwNzg1OTYxOTkxMTQ1NzE1MjM5MV8pO2ZpbGw6IzRDNjU4Njt9DQoJLnN0MXtmaWxsOm5vbmU7fQ0KPC9zdHlsZT4NCjxnPg0KCTxnPg0KCQk8ZGVmcz4NCgkJCTxyZWN0IGlkPSJTVkdJRF8xXyIg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hlaWdodD0iMzIwIi8+DQo8dGV4dAogICBzdHlsZT0iCiAgICAgIGZvbnQtc3R5bGU6bm9ybWFsOwogICAgICBmb250LXdlaWdodDpub3JtYWw7CiAgICAgIGZvbnQtc2l6ZTo4cmVtOwogICAgICBmb250LWZhbWlseTpzYW5zLXNlcmlmOwogICAgICBsZXR0ZXItc3BhY2luZzowcHg7CiAgICAgIGZpbGw6IzAwMDsKICAgICAgZmlsbC1vcGFjaXR5OjE7CiAgICAiCiAgICB4PSI1MCUiCiAgICB5PSI1NSUiCiAgICBkb21pbmFudC1iYXNlbGluZT0ibWlkZGxlIgogICAgdGV4dC1hbmNob3I9Im1pZGRsZSIKICA+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().
◆ testRenderingStandardDisabled()
IconTest::testRenderingStandardDisabled |
( |
Standard |
$ico | ) |
|
Definition at line 135 of file IconTest.php.
135 : void
136 {
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().
◆ 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
References $id, and $path.
◆ testSetCustomLabel()
IconTest::testSetCustomLabel |
( |
| ) |
|
Definition at line 189 of file IconTest.php.
190 {
191 $path =
'./assets/images/icon_fold.svg';
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().
◆ testSizeModification()
IconTest::testSizeModification |
( |
| ) |
|
Definition at line 69 of file IconTest.php.
69 : void
70 {
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().
◆ testSizeModificationWrongParam()
IconTest::testSizeModificationWrongParam |
( |
| ) |
|
◆ ICON_PATH
const IconTest::ICON_PATH = __DIR__ . '/../../../../../../../public/assets/images/standard/' |
◆ ICON_PATH_REL
const IconTest::ICON_PATH_REL = './assets/images/' |
The documentation for this class was generated from the following file:
- components/ILIAS/UI/tests/Component/Symbol/Icon/IconTest.php