Test on icon implementation.
More...
Test on icon implementation.
Definition at line 13 of file IconTest.php.
◆ getIconFactory()
IconTest::getIconFactory |
( |
| ) |
|
|
private |
Definition at line 15 of file IconTest.php.
16 {
17 return new I\Component\Icon\Factory();
18 }
Referenced by testAttributes(), testConstruction(), testCustomPath(), testDisabledModification(), testDisabledModificationWrongParam(), testOutlinedModification(), testRenderingCustom(), testRenderingStandard(), testRenderingStandardOutlined(), testSizeModification(), and testSizeModificationWrongParam().
◆ testAttributes()
IconTest::testAttributes |
( |
| ) |
|
Definition at line 32 of file IconTest.php.
33 {
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 }
References $f, and getIconFactory().
◆ testConstruction()
IconTest::testConstruction |
( |
| ) |
|
Definition at line 20 of file IconTest.php.
21 {
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().
◆ testCustomPath()
IconTest::testCustomPath |
( |
| ) |
|
Definition at line 112 of file IconTest.php.
113 {
115
116 $ico =
$f->custom(
'/some/path/',
'Custom Icon');
117 $this->assertEquals('/some/path/', $ico->getIconPath());
118 }
References $f, and getIconFactory().
◆ testDisabledModification()
IconTest::testDisabledModification |
( |
| ) |
|
Definition at line 76 of file IconTest.php.
77 {
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().
◆ testDisabledModificationWrongParam()
IconTest::testDisabledModificationWrongParam |
( |
| ) |
|
Definition at line 88 of file IconTest.php.
89 {
90 try {
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().
◆ testOutlinedModification()
IconTest::testOutlinedModification |
( |
| ) |
|
Definition at line 100 of file IconTest.php.
101 {
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().
◆ testRenderingCustom()
IconTest::testRenderingCustom |
( |
| ) |
|
Definition at line 170 of file IconTest.php.
171 {
174 $path =
'./templates/default/images/icon_fold.svg';
175
176 $ico = $ico =
$f->custom(
$path,
'Custom',
'medium');
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
184 $ico = $ico->withDisabled(true);
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
192 $ico = $ico->withAbbreviation('CS');
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 }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
References $f, $html, $path, $r, ILIAS_UI_TestBase\getDefaultRenderer(), getIconFactory(), and ILIAS_UI_TestBase\normalizeHTML().
◆ testRenderingStandard()
IconTest::testRenderingStandard |
( |
| ) |
|
Definition at line 120 of file IconTest.php.
121 {
124
125 $ico = $ico =
$f->standard(
'crs',
'Course',
'medium');
127 $expected = '<div class="icon crs medium" aria-label="Course"></div>';
128 $this->assertEquals($expected,
$html);
129
130
131 $ico = $ico->withDisabled(true);
133 $expected = '<div class="icon crs medium disabled" aria-label="Course"></div>';
134 $this->assertEquals($expected,
$html);
135
136
137 $ico = $ico->withAbbreviation('CRS');
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().
◆ testRenderingStandardOutlined()
IconTest::testRenderingStandardOutlined |
( |
| ) |
|
Definition at line 145 of file IconTest.php.
146 {
149
150 $ico = $ico =
$f->standard(
'crs',
'Course',
'medium')->withIsOutlined(
true);
152 $expected = '<div class="icon crs medium outlined" aria-label="Course"></div>';
153 $this->assertEquals($expected,
$html);
154
155
156 $ico = $ico->withDisabled(true);
158 $expected = '<div class="icon crs medium disabled outlined" aria-label="Course"></div>';
159 $this->assertEquals($expected,
$html);
160
161
162 $ico = $ico->withAbbreviation('CRS');
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().
◆ testSizeModification()
IconTest::testSizeModification |
( |
| ) |
|
Definition at line 49 of file IconTest.php.
50 {
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().
◆ testSizeModificationWrongParam()
IconTest::testSizeModificationWrongParam |
( |
| ) |
|
Definition at line 64 of file IconTest.php.
65 {
66 try {
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().
The documentation for this class was generated from the following file: