ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
GlyphTest Class Reference

Test on glyph implementation. More...

+ Inheritance diagram for GlyphTest:
+ Collaboration diagram for GlyphTest:

Public Member Functions

 getGlyphFactory ()
 
 getCounterFactory ()
 
 test_implements_factory_interface ($factory_method)
 @dataProvider glyph_type_provider More...
 
 test_glyph_types ($factory_method)
 @dataProvider glyph_type_provider More...
 
 test_glyph_action ($factory_method)
 @dataProvider glyph_type_provider More...
 
 test_glyph_no_action ($factory_method)
 @dataProvider glyph_type_provider More...
 
 test_with_highlight ($counter_type)
 @dataProvider counter_type_provider More...
 
 test_no_counter ($factory_method)
 @dataProvider glyph_type_provider More...
 
 test_one_counter ($counter_type)
 @dataProvider counter_type_provider More...
 
 test_two_counters ()
 
 test_only_two_counters ()
 
 test_immutability_withCounter ()
 
 test_known_glyphs_only ()
 
 glyph_type_provider ()
 
 counter_type_provider ()
 
 test_render_simple ($type)
 @dataProvider glyph_type_provider More...
 
 test_render_withCounter ($type)
 @dataProvider counter_type_provider More...
 
 test_render_withTwoCounters ()
 
 test_dont_render_counter ()
 
 test_render_with_on_load_code ($type)
 @dataProvider glyph_type_provider More...
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getDefaultRenderer ()
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Static Public Attributes

static $canonical_css_classes
 
static $aria_labels
 

Detailed Description

Test on glyph implementation.

Definition at line 13 of file GlyphTest.php.

Member Function Documentation

◆ counter_type_provider()

GlyphTest::counter_type_provider ( )

Definition at line 247 of file GlyphTest.php.

247 {
248 return array
249 ( array("status")
250 , array("novelty")
251 );
252 }

◆ getCounterFactory()

GlyphTest::getCounterFactory ( )

Definition at line 18 of file GlyphTest.php.

18 {
19 return new \ILIAS\UI\Implementation\Component\Counter\Factory();
20 }

Referenced by test_dont_render_counter(), test_immutability_withCounter(), test_one_counter(), test_only_two_counters(), test_render_withCounter(), test_render_withTwoCounters(), and test_two_counters().

+ Here is the caller graph for this function:

◆ getGlyphFactory()

◆ glyph_type_provider()

GlyphTest::glyph_type_provider ( )

Definition at line 225 of file GlyphTest.php.

225 {
226 return array
227 ( array(C\Glyph\Glyph::SETTINGS)
228 , array(C\Glyph\Glyph::EXPAND)
229 , array(C\Glyph\Glyph::COLLAPSE)
230 , array(C\Glyph\Glyph::ADD)
231 , array(C\Glyph\Glyph::REMOVE)
232 , array(C\Glyph\Glyph::UP)
233 , array(C\Glyph\Glyph::DOWN)
234 , array(C\Glyph\Glyph::BACK)
235 , array(C\Glyph\Glyph::NEXT)
236 , array(C\Glyph\Glyph::SORT_ASCENDING)
237 , array(C\Glyph\Glyph::SORT_DESCENDING)
238 , array(C\Glyph\Glyph::USER)
239 , array(C\Glyph\Glyph::MAIL)
240 , array(C\Glyph\Glyph::NOTIFICATION)
241 , array(C\Glyph\Glyph::TAG)
242 , array(C\Glyph\Glyph::NOTE)
243 , array(C\Glyph\Glyph::COMMENT)
244 );
245 }

◆ test_dont_render_counter()

GlyphTest::test_dont_render_counter ( )

Definition at line 314 of file GlyphTest.php.

314 {
315 $r = new \ILIAS\UI\Implementation\Component\Glyph\Renderer($this->getUIFactory(), $this->getTemplateFactory(),$this->getLanguage(), $this->getJavaScriptBinding());
316 $f = $this->getCounterFactory();
317
318 try {
319 $r->render($f->status(0), $this->getDefaultRenderer());
320 $this->assertFalse("This should not happen!");
321 }
322 catch (\LogicException $e) {}
323 }
getCounterFactory()
Definition: GlyphTest.php:18
getJavaScriptBinding()
Definition: Base.php:96
getTemplateFactory()
Definition: Base.php:84
$r
Definition: example_031.php:79

References $r, getCounterFactory(), ILIAS_UI_TestBase\getJavaScriptBinding(), ILIAS_UI_TestBase\getLanguage(), ILIAS_UI_TestBase\getTemplateFactory(), and ILIAS_UI_TestBase\getUIFactory().

+ Here is the call graph for this function:

◆ test_glyph_action()

GlyphTest::test_glyph_action (   $factory_method)

@dataProvider glyph_type_provider

Definition at line 86 of file GlyphTest.php.

86 {
87 $f = $this->getGlyphFactory();
88 $g = $f->$factory_method("http://www.ilias.de");
89
90 $this->assertNotNull($g);
91 $this->assertEquals("http://www.ilias.de", $g->getAction());
92 }
getGlyphFactory()
Definition: GlyphTest.php:14

References getGlyphFactory().

+ Here is the call graph for this function:

◆ test_glyph_no_action()

GlyphTest::test_glyph_no_action (   $factory_method)

@dataProvider glyph_type_provider

Definition at line 97 of file GlyphTest.php.

97 {
98 $f = $this->getGlyphFactory();
99 $g = $f->$factory_method();
100
101 $this->assertNotNull($g);
102 $this->assertEquals(null, $g->getAction());
103 }

References getGlyphFactory().

+ Here is the call graph for this function:

◆ test_glyph_types()

GlyphTest::test_glyph_types (   $factory_method)

@dataProvider glyph_type_provider

Definition at line 75 of file GlyphTest.php.

75 {
76 $f = $this->getGlyphFactory();
77 $g = $f->$factory_method();
78
79 $this->assertNotNull($g);
80 $this->assertEquals($factory_method, $g->getType());
81 }

References getGlyphFactory().

+ Here is the call graph for this function:

◆ test_immutability_withCounter()

GlyphTest::test_immutability_withCounter ( )

Definition at line 203 of file GlyphTest.php.

203 {
204 $gf = $this->getGlyphFactory();
205 $cf = $this->getCounterFactory();
206
207 $g = $gf->mail();
208 $g2 = $g
209 ->withCounter(
210 $cf->novelty(0)
211 );
212
213 $counters = $g->getCounters();
214 $this->assertCount(0, $counters);
215 }

References getCounterFactory(), and getGlyphFactory().

+ Here is the call graph for this function:

◆ test_implements_factory_interface()

GlyphTest::test_implements_factory_interface (   $factory_method)

@dataProvider glyph_type_provider

Definition at line 65 of file GlyphTest.php.

65 {
66 $f = $this->getGlyphFactory();
67
68 $this->assertInstanceOf("ILIAS\\UI\\Component\\Glyph\\Factory", $f);
69 $this->assertInstanceOf("ILIAS\\UI\\Component\\Glyph\\Glyph", $f->$factory_method("http://www.ilias.de"));
70 }

References getGlyphFactory().

+ Here is the call graph for this function:

◆ test_known_glyphs_only()

GlyphTest::test_known_glyphs_only ( )

Definition at line 217 of file GlyphTest.php.

217 {
218 try {
219 new \ILIAS\UI\Implementation\Component\Glyph\Glyph("FOO", "http://www.ilias.de");
220 $this->assertFalse("We should not get here");
221 }
222 catch (\InvalidArgumentException $e) {}
223 }

◆ test_no_counter()

GlyphTest::test_no_counter (   $factory_method)

@dataProvider glyph_type_provider

Definition at line 123 of file GlyphTest.php.

123 {
124 $f = $this->getGlyphFactory();
125 $g = $f->$factory_method();
126
127 $this->assertCount(0, $g->getCounters());
128 }

References getGlyphFactory().

+ Here is the call graph for this function:

◆ test_one_counter()

GlyphTest::test_one_counter (   $counter_type)

@dataProvider counter_type_provider

Definition at line 133 of file GlyphTest.php.

133 {
134 $gf = $this->getGlyphFactory();
135 $cf = $this->getCounterFactory();
136 $number = 1;
137
138 $g = $gf
139 ->mail()
140 ->withCounter(
141 $cf->$counter_type($number)
142 );
143
144 $counters = $g->getCounters();
145 $this->assertCount(1, $counters);
146 $c = $counters[0];
147 $this->assertEquals($counter_type, $c->getType());
148 $this->assertEquals($number, $c->getNumber());
149 }

References getCounterFactory(), and getGlyphFactory().

+ Here is the call graph for this function:

◆ test_only_two_counters()

GlyphTest::test_only_two_counters ( )

Definition at line 175 of file GlyphTest.php.

175 {
176 $gf = $this->getGlyphFactory();
177 $cf = $this->getCounterFactory();
178 $number_s = 1;
179 $number_n1 = 2;
180 $number_n2 = 2;
181
182 $g = $gf
183 ->mail()
184 ->withCounter(
185 $cf->status($number_s)
186 )
187 ->withCounter(
188 $cf->novelty($number_n1)
189 )
190 ->withCounter(
191 $cf->novelty($number_n2)
192 );
193
194 $counters = $g->getCounters();
195 $this->assertCount(2, $counters);
196 $vals = array_map(function($c) {
197 return array($c->getType(), $c->getNumber());
198 }, $counters);
199 $this->assertContains(array("status", $number_s), $vals);
200 $this->assertContains(array("novelty", $number_n2), $vals);
201 }

References getCounterFactory(), and getGlyphFactory().

+ Here is the call graph for this function:

◆ test_render_simple()

GlyphTest::test_render_simple (   $type)

@dataProvider glyph_type_provider

Definition at line 257 of file GlyphTest.php.

257 {
258 $f = $this->getGlyphFactory();
259 $r = $this->getDefaultRenderer();
260 $c = $f->$type("http://www.ilias.de");
261
262 $html = $this->normalizeHTML($r->render($c));
263
264 $css_classes = self::$canonical_css_classes[$type];
265 $aria_label = self::$aria_labels[$type];
266
267 $expected = "<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
268 $this->assertEquals($expected, $html);
269 }
normalizeHTML($html)
Definition: Base.php:110
getDefaultRenderer()
Definition: Base.php:100
$html
Definition: example_001.php:87

References $html, $r, ILIAS_UI_TestBase\getDefaultRenderer(), getGlyphFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_with_on_load_code()

GlyphTest::test_render_with_on_load_code (   $type)

@dataProvider glyph_type_provider

Definition at line 328 of file GlyphTest.php.

328 {
329 $f = $this->getGlyphFactory();
330 $r = $this->getDefaultRenderer();
331 $ids = array();
332 $c = $f->$type("http://www.ilias.de")
333 ->withOnLoadCode(function($id) use (&$ids) {
334 $ids[] = $id;
335 return "";
336 });
337
338 $html = $this->normalizeHTML($r->render($c));
339
340 $this->assertCount(1, $ids);
341
342 $css_classes = self::$canonical_css_classes[$type];
343 $aria_label = self::$aria_labels[$type];
344
345 $id = $ids[0];
346 $expected = "<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\" id=\"$id\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
347 $this->assertEquals($expected, $html);
348 }

References $html, $r, ILIAS_UI_TestBase\getDefaultRenderer(), getGlyphFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_withCounter()

GlyphTest::test_render_withCounter (   $type)

@dataProvider counter_type_provider

Definition at line 274 of file GlyphTest.php.

274 {
275 $fg = $this->getGlyphFactory();
276 $fc = $this->getCounterFactory();
277 $r = $this->getDefaultRenderer();
278 $c = $fg->mail("http://www.ilias.de")->withCounter($fc->$type(42));
279
280 $html = $this->normalizeHTML($r->render($c));
281
282 $css_classes = self::$canonical_css_classes[C\Glyph\Glyph::MAIL];
283 $aria_label = self::$aria_labels[C\Glyph\Glyph::MAIL];
284
285 $expected = "<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">".
286 "<span class=\"$css_classes\" aria-hidden=\"true\"></span>".
287 "<span class=\"badge badge-notify il-counter-$type\">42</span>".
288 "<span class=\"il-counter-spacer\">42</span>".
289 "</a>";
290 $this->assertEquals($expected, $html);
291 }

References $html, $r, getCounterFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), getGlyphFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_withTwoCounters()

GlyphTest::test_render_withTwoCounters ( )

Definition at line 293 of file GlyphTest.php.

293 {
294 $fg = $this->getGlyphFactory();
295 $fc = $this->getCounterFactory();
296 $r = $this->getDefaultRenderer();
297 $c = $fg->mail("http://www.ilias.de")
298 ->withCounter($fc->novelty(42))
299 ->withCounter($fc->status(7));
300
301 $html = $this->normalizeHTML($r->render($c));
302
303 $css_classes = self::$canonical_css_classes[C\Glyph\Glyph::MAIL];
304 $aria_label = self::$aria_labels[C\Glyph\Glyph::MAIL];
305 $expected = "<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">".
306 "<span class=\"$css_classes\" aria-hidden=\"true\"></span>".
307 "<span class=\"badge badge-notify il-counter-status\">7</span>".
308 "<span class=\"badge badge-notify il-counter-novelty\">42</span>".
309 "<span class=\"il-counter-spacer\">42</span>".
310 "</a>";
311 $this->assertEquals($expected, $html);
312 }

References $html, $r, getCounterFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), getGlyphFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_two_counters()

GlyphTest::test_two_counters ( )

Definition at line 151 of file GlyphTest.php.

151 {
152 $gf = $this->getGlyphFactory();
153 $cf = $this->getCounterFactory();
154 $number_s = 1;
155 $number_n = 2;
156
157 $g = $gf
158 ->mail()
159 ->withCounter(
160 $cf->status($number_s)
161 )
162 ->withCounter(
163 $cf->novelty($number_n)
164 );
165
166 $counters = $g->getCounters();
167 $this->assertCount(2, $counters);
168 $vals = array_map(function($c) {
169 return array($c->getType(), $c->getNumber());
170 }, $counters);
171 $this->assertContains(array("status", $number_s), $vals);
172 $this->assertContains(array("novelty", $number_n), $vals);
173 }

References getCounterFactory(), and getGlyphFactory().

+ Here is the call graph for this function:

◆ test_with_highlight()

GlyphTest::test_with_highlight (   $counter_type)

@dataProvider counter_type_provider

Definition at line 108 of file GlyphTest.php.

108 {
109 $gf = $this->getGlyphFactory();
110
111 $g = $gf
112 ->mail()
113 ;
114 $g2 = $g->withHighlight();
115
116 $this->assertFalse($g->isHighlighted());
117 $this->assertTrue($g2->isHighlighted());
118 }

References getGlyphFactory().

+ Here is the call graph for this function:

Field Documentation

◆ $aria_labels

GlyphTest::$aria_labels
static
Initial value:
= array(
C\Glyph\Glyph::SETTINGS => "settings"
, C\Glyph\Glyph::EXPAND => "expand_content"
, C\Glyph\Glyph::COLLAPSE => "collapse_content"
, C\Glyph\Glyph::ADD => "add"
, C\Glyph\Glyph::REMOVE => "remove"
, C\Glyph\Glyph::UP => "up"
, C\Glyph\Glyph::DOWN => "down"
, C\Glyph\Glyph::BACK => "back"
, C\Glyph\Glyph::NEXT => "next"
, C\Glyph\Glyph::SORT_ASCENDING => "sort_ascending"
, C\Glyph\Glyph::SORT_DESCENDING => "sort_descending"
, C\Glyph\Glyph::USER => "show_who_is_online"
, C\Glyph\Glyph::MAIL => "mail"
, C\Glyph\Glyph::NOTIFICATION => "notifications"
, C\Glyph\Glyph::TAG => "tags"
, C\Glyph\Glyph::NOTE => "notes"
, C\Glyph\Glyph::COMMENT => "comments"
)

Definition at line 42 of file GlyphTest.php.

◆ $canonical_css_classes

GlyphTest::$canonical_css_classes
static
Initial value:
= array
( C\Glyph\Glyph::SETTINGS => "glyphicon glyphicon-cog"
, C\Glyph\Glyph::EXPAND => "glyphicon glyphicon-triangle-right"
, C\Glyph\Glyph::COLLAPSE => "glyphicon glyphicon-triangle-bottom"
, C\Glyph\Glyph::ADD => "glyphicon glyphicon-plus-sign"
, C\Glyph\Glyph::REMOVE => "glyphicon glyphicon-minus-sign"
, C\Glyph\Glyph::UP => "glyphicon glyphicon-circle-arrow-up"
, C\Glyph\Glyph::DOWN => "glyphicon glyphicon-circle-arrow-down"
, C\Glyph\Glyph::BACK => "glyphicon glyphicon-chevron-left"
, C\Glyph\Glyph::NEXT => "glyphicon glyphicon-chevron-right"
, C\Glyph\Glyph::SORT_ASCENDING => "glyphicon glyphicon-arrow-up"
, C\Glyph\Glyph::SORT_DESCENDING => "glyphicon glyphicon-arrow-down"
, C\Glyph\Glyph::USER => "glyphicon glyphicon-user"
, C\Glyph\Glyph::MAIL => "glyphicon glyphicon-envelope"
, C\Glyph\Glyph::NOTIFICATION => "glyphicon glyphicon-bell"
, C\Glyph\Glyph::TAG => "glyphicon glyphicon-tag"
, C\Glyph\Glyph::NOTE => "glyphicon glyphicon-pushpin"
, C\Glyph\Glyph::COMMENT => "glyphicon glyphicon-comment"
)

Definition at line 22 of file GlyphTest.php.


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