ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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_unavailable_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_with_unavailable_action ($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 (JavaScriptBinding $js_binding=null)
 
 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 303 of file GlyphTest.php.

304 {
305 return array( array("status")
306 , array("novelty")
307 );
308 }

◆ getCounterFactory()

GlyphTest::getCounterFactory ( )

Definition at line 20 of file GlyphTest.php.

21 {
22 return new \ILIAS\UI\Implementation\Component\Counter\Factory();
23 }

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 271 of file GlyphTest.php.

272 {
273 return array( array(C\Glyph\Glyph::SETTINGS)
274 , array(C\Glyph\Glyph::EXPAND)
275 , array(C\Glyph\Glyph::COLLAPSE)
276 , array(C\Glyph\Glyph::ADD)
277 , array(C\Glyph\Glyph::REMOVE)
278 , array(C\Glyph\Glyph::UP)
279 , array(C\Glyph\Glyph::DOWN)
280 , array(C\Glyph\Glyph::BACK)
281 , array(C\Glyph\Glyph::NEXT)
282 , array(C\Glyph\Glyph::SORT_ASCENDING)
283 , array(C\Glyph\Glyph::SORT_DESCENDING)
284 , array(C\Glyph\Glyph::USER)
285 , array(C\Glyph\Glyph::MAIL)
286 , array(C\Glyph\Glyph::NOTIFICATION)
287 , array(C\Glyph\Glyph::TAG)
288 , array(C\Glyph\Glyph::NOTE)
289 , array(C\Glyph\Glyph::COMMENT)
290 , array(C\Glyph\Glyph::LIKE)
291 , array(C\Glyph\Glyph::LOVE)
292 , array(C\Glyph\Glyph::DISLIKE)
293 , array(C\Glyph\Glyph::LAUGH)
294 , array(C\Glyph\Glyph::ASTOUNDED)
295 , array(C\Glyph\Glyph::SAD)
296 , array(C\Glyph\Glyph::ANGRY)
297 , array(C\Glyph\Glyph::ATTACHMENT)
298 , array(C\Glyph\Glyph::RESET)
299 , array(C\Glyph\Glyph::APPLY)
300 );
301 }

◆ test_dont_render_counter()

GlyphTest::test_dont_render_counter ( )

Definition at line 392 of file GlyphTest.php.

393 {
394 $r = new \ILIAS\UI\Implementation\Component\Glyph\Renderer($this->getUIFactory(), $this->getTemplateFactory(), $this->getLanguage(), $this->getJavaScriptBinding());
395 $f = $this->getCounterFactory();
396
397 try {
398 $r->render($f->status(0), $this->getDefaultRenderer());
399 $this->assertFalse("This should not happen!");
400 } catch (\LogicException $e) {
401 }
402 }
getCounterFactory()
Definition: GlyphTest.php:20
getJavaScriptBinding()
Definition: Base.php:223
getTemplateFactory()
Definition: Base.php:208
$r
Definition: example_031.php:79

References $f, $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 110 of file GlyphTest.php.

111 {
112 $f = $this->getGlyphFactory();
113 $g = $f->$factory_method("http://www.ilias.de");
114
115 $this->assertNotNull($g);
116 $this->assertEquals("http://www.ilias.de", $g->getAction());
117 }
getGlyphFactory()
Definition: GlyphTest.php:15

References $f, and 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 122 of file GlyphTest.php.

123 {
124 $f = $this->getGlyphFactory();
125 $g = $f->$factory_method();
126
127 $this->assertNotNull($g);
128 $this->assertEquals(null, $g->getAction());
129 }

References $f, and 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 98 of file GlyphTest.php.

99 {
100 $f = $this->getGlyphFactory();
101 $g = $f->$factory_method();
102
103 $this->assertNotNull($g);
104 $this->assertEquals($factory_method, $g->getType());
105 }

References $f, and getGlyphFactory().

+ Here is the call graph for this function:

◆ test_immutability_withCounter()

GlyphTest::test_immutability_withCounter ( )

Definition at line 247 of file GlyphTest.php.

248 {
249 $gf = $this->getGlyphFactory();
250 $cf = $this->getCounterFactory();
251
252 $g = $gf->mail();
253 $g2 = $g
254 ->withCounter(
255 $cf->novelty(0)
256 );
257
258 $counters = $g->getCounters();
259 $this->assertCount(0, $counters);
260 }

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 87 of file GlyphTest.php.

88 {
89 $f = $this->getGlyphFactory();
90
91 $this->assertInstanceOf("ILIAS\\UI\\Component\\Glyph\\Factory", $f);
92 $this->assertInstanceOf("ILIAS\\UI\\Component\\Glyph\\Glyph", $f->$factory_method("http://www.ilias.de"));
93 }

References $f, and getGlyphFactory().

+ Here is the call graph for this function:

◆ test_known_glyphs_only()

GlyphTest::test_known_glyphs_only ( )

Definition at line 262 of file GlyphTest.php.

263 {
264 try {
265 new \ILIAS\UI\Implementation\Component\Glyph\Glyph("FOO", "http://www.ilias.de");
266 $this->assertFalse("We should not get here");
267 } catch (\InvalidArgumentException $e) {
268 }
269 }

◆ test_no_counter()

GlyphTest::test_no_counter (   $factory_method)

@dataProvider glyph_type_provider

Definition at line 163 of file GlyphTest.php.

164 {
165 $f = $this->getGlyphFactory();
166 $g = $f->$factory_method();
167
168 $this->assertCount(0, $g->getCounters());
169 }

References $f, and 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 174 of file GlyphTest.php.

175 {
176 $gf = $this->getGlyphFactory();
177 $cf = $this->getCounterFactory();
178 $number = 1;
179
180 $g = $gf
181 ->mail()
182 ->withCounter(
183 $cf->$counter_type($number)
184 );
185
186 $counters = $g->getCounters();
187 $this->assertCount(1, $counters);
188 $c = $counters[0];
189 $this->assertEquals($counter_type, $c->getType());
190 $this->assertEquals($number, $c->getNumber());
191 }

References $c, getCounterFactory(), and getGlyphFactory().

+ Here is the call graph for this function:

◆ test_only_two_counters()

GlyphTest::test_only_two_counters ( )

Definition at line 218 of file GlyphTest.php.

219 {
220 $gf = $this->getGlyphFactory();
221 $cf = $this->getCounterFactory();
222 $number_s = 1;
223 $number_n1 = 2;
224 $number_n2 = 2;
225
226 $g = $gf
227 ->mail()
228 ->withCounter(
229 $cf->status($number_s)
230 )
231 ->withCounter(
232 $cf->novelty($number_n1)
233 )
234 ->withCounter(
235 $cf->novelty($number_n2)
236 );
237
238 $counters = $g->getCounters();
239 $this->assertCount(2, $counters);
240 $vals = array_map(function ($c) {
241 return array($c->getType(), $c->getNumber());
242 }, $counters);
243 $this->assertContains(array("status", $number_s), $vals);
244 $this->assertContains(array("novelty", $number_n2), $vals);
245 }

References $c, 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 313 of file GlyphTest.php.

314 {
315 $f = $this->getGlyphFactory();
316 $r = $this->getDefaultRenderer();
317 $c = $f->$type("http://www.ilias.de");
318
319 $html = $this->normalizeHTML($r->render($c));
320
321 $css_classes = self::$canonical_css_classes[$type];
322 $aria_label = self::$aria_labels[$type];
323
324 $expected = "<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
325 $this->assertEquals($expected, $html);
326 }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$html
Definition: example_001.php:87
$type

References $c, $f, $html, $r, $type, 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 407 of file GlyphTest.php.

408 {
409 $f = $this->getGlyphFactory();
410 $r = $this->getDefaultRenderer();
411 $ids = array();
412 $c = $f->$type("http://www.ilias.de")
413 ->withOnLoadCode(function ($id) use (&$ids) {
414 $ids[] = $id;
415 return "";
416 });
417
418 $html = $this->normalizeHTML($r->render($c));
419
420 $this->assertCount(1, $ids);
421
422 $css_classes = self::$canonical_css_classes[$type];
423 $aria_label = self::$aria_labels[$type];
424
425 $id = $ids[0];
426 $expected = "<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\" id=\"$id\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
427 $this->assertEquals($expected, $html);
428 }
if(!array_key_exists('StateId', $_REQUEST)) $id

References $c, $f, $html, $id, $r, $type, ILIAS_UI_TestBase\getDefaultRenderer(), getGlyphFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_with_unavailable_action()

GlyphTest::test_render_with_unavailable_action (   $type)

@dataProvider glyph_type_provider

Definition at line 331 of file GlyphTest.php.

332 {
333 $f = $this->getGlyphFactory();
334 $r = $this->getDefaultRenderer();
335 $c = $f->$type("http://www.ilias.de")->withUnavailableAction();
336
337 $html = $this->normalizeHTML($r->render($c));
338
339 $css_classes = self::$canonical_css_classes[$type];
340 $aria_label = self::$aria_labels[$type];
341
342 $expected = "<a class=\"glyph disabled\" aria-label=\"$aria_label\" " .
343 "aria-disabled=\"true\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
344 $this->assertEquals($expected, $html);
345 }

References $c, $f, $html, $r, $type, 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 350 of file GlyphTest.php.

351 {
352 $fg = $this->getGlyphFactory();
353 $fc = $this->getCounterFactory();
354 $r = $this->getDefaultRenderer();
355 $c = $fg->mail("http://www.ilias.de")->withCounter($fc->$type(42));
356
357 $html = $this->normalizeHTML($r->render($c));
358
359 $css_classes = self::$canonical_css_classes[C\Glyph\Glyph::MAIL];
360 $aria_label = self::$aria_labels[C\Glyph\Glyph::MAIL];
361
362 $expected = "<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">" .
363 "<span class=\"$css_classes\" aria-hidden=\"true\"></span>" .
364 "<span class=\"badge badge-notify il-counter-$type\">42</span>" .
365 "<span class=\"il-counter-spacer\">42</span>" .
366 "</a>";
367 $this->assertEquals($expected, $html);
368 }

References $c, $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 370 of file GlyphTest.php.

371 {
372 $fg = $this->getGlyphFactory();
373 $fc = $this->getCounterFactory();
374 $r = $this->getDefaultRenderer();
375 $c = $fg->mail("http://www.ilias.de")
376 ->withCounter($fc->novelty(42))
377 ->withCounter($fc->status(7));
378
379 $html = $this->normalizeHTML($r->render($c));
380
381 $css_classes = self::$canonical_css_classes[C\Glyph\Glyph::MAIL];
382 $aria_label = self::$aria_labels[C\Glyph\Glyph::MAIL];
383 $expected = "<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">" .
384 "<span class=\"$css_classes\" aria-hidden=\"true\"></span>" .
385 "<span class=\"badge badge-notify il-counter-status\">7</span>" .
386 "<span class=\"badge badge-notify il-counter-novelty\">42</span>" .
387 "<span class=\"il-counter-spacer\">42</span>" .
388 "</a>";
389 $this->assertEquals($expected, $html);
390 }

References $c, $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 193 of file GlyphTest.php.

194 {
195 $gf = $this->getGlyphFactory();
196 $cf = $this->getCounterFactory();
197 $number_s = 1;
198 $number_n = 2;
199
200 $g = $gf
201 ->mail()
202 ->withCounter(
203 $cf->status($number_s)
204 )
205 ->withCounter(
206 $cf->novelty($number_n)
207 );
208
209 $counters = $g->getCounters();
210 $this->assertCount(2, $counters);
211 $vals = array_map(function ($c) {
212 return array($c->getType(), $c->getNumber());
213 }, $counters);
214 $this->assertContains(array("status", $number_s), $vals);
215 $this->assertContains(array("novelty", $number_n), $vals);
216 }

References $c, 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 147 of file GlyphTest.php.

148 {
149 $gf = $this->getGlyphFactory();
150
151 $g = $gf
152 ->mail()
153 ;
154 $g2 = $g->withHighlight();
155
156 $this->assertFalse($g->isHighlighted());
157 $this->assertTrue($g2->isHighlighted());
158 }

References getGlyphFactory().

+ Here is the call graph for this function:

◆ test_with_unavailable_action()

GlyphTest::test_with_unavailable_action (   $factory_method)

@dataProvider glyph_type_provider

Definition at line 134 of file GlyphTest.php.

135 {
136 $f = $this->getGlyphFactory();
137 $g = $f->$factory_method();
138 $g2 = $f->$factory_method()->withUnavailableAction();
139
140 $this->assertTrue($g->isActive());
141 $this->assertFalse($g2->isActive());
142 }

References $f, and 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"
, C\Glyph\Glyph::LIKE => "like"
, C\Glyph\Glyph::LOVE => "love"
, C\Glyph\Glyph::DISLIKE => "dislike"
, C\Glyph\Glyph::LAUGH => "laugh"
, C\Glyph\Glyph::ASTOUNDED => "astounded"
, C\Glyph\Glyph::SAD => "sad"
, C\Glyph\Glyph::ANGRY => "angry"
, C\Glyph\Glyph::ATTACHMENT => "attachment"
, C\Glyph\Glyph::RESET => "reset"
, C\Glyph\Glyph::APPLY => "apply"
)

Definition at line 54 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"
, C\Glyph\Glyph::LIKE => "glyphicon il-glyphicon-like"
, C\Glyph\Glyph::LOVE => "glyphicon il-glyphicon-love"
, C\Glyph\Glyph::DISLIKE => "glyphicon il-glyphicon-dislike"
, C\Glyph\Glyph::LAUGH => "glyphicon il-glyphicon-laugh"
, C\Glyph\Glyph::ASTOUNDED => "glyphicon il-glyphicon-astounded"
, C\Glyph\Glyph::SAD => "glyphicon il-glyphicon-sad"
, C\Glyph\Glyph::ANGRY => "glyphicon il-glyphicon-angry"
, C\Glyph\Glyph::ATTACHMENT => "glyphicon glyphicon-paperclip"
, C\Glyph\Glyph::RESET => "glyphicon glyphicon-repeat"
, C\Glyph\Glyph::APPLY => "glyphicon glyphicon-ok"
)

Definition at line 25 of file GlyphTest.php.


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