ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 glyph_type_provider More...
 
 test_glyph_types ($factory_method)
 glyph_type_provider More...
 
 test_glyph_action ($factory_method)
 glyph_type_provider More...
 
 test_glyph_no_action ($factory_method)
 glyph_type_provider More...
 
 test_with_highlight ($counter_type)
 counter_type_provider More...
 
 test_no_counter ($factory_method)
 glyph_type_provider More...
 
 test_one_counter ($counter_type)
 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)
 glyph_type_provider More...
 
 test_render_withCounter ($type)
 counter_type_provider More...
 
 test_render_withTwoCounters ()
 
 test_dont_render_counter ()
 
 test_render_with_on_load_code ($type)
 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 260 of file GlyphTest.php.

References array.

261  {
262  return array( array("status")
263  , array("novelty")
264  );
265  }
Create styles array
The data for the language used.

◆ getCounterFactory()

GlyphTest::getCounterFactory ( )

Definition at line 20 of file GlyphTest.php.

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().

21  {
22  return new \ILIAS\UI\Implementation\Component\Counter\Factory();
23  }
+ Here is the caller graph for this function:

◆ getGlyphFactory()

GlyphTest::getGlyphFactory ( )

◆ glyph_type_provider()

GlyphTest::glyph_type_provider ( )

Definition at line 238 of file GlyphTest.php.

References array.

239  {
240  return array( array(C\Glyph\Glyph::SETTINGS)
241  , array(C\Glyph\Glyph::EXPAND)
242  , array(C\Glyph\Glyph::COLLAPSE)
243  , array(C\Glyph\Glyph::ADD)
244  , array(C\Glyph\Glyph::REMOVE)
245  , array(C\Glyph\Glyph::UP)
246  , array(C\Glyph\Glyph::DOWN)
247  , array(C\Glyph\Glyph::BACK)
248  , array(C\Glyph\Glyph::NEXT)
249  , array(C\Glyph\Glyph::SORT_ASCENDING)
250  , array(C\Glyph\Glyph::SORT_DESCENDING)
251  , array(C\Glyph\Glyph::USER)
252  , array(C\Glyph\Glyph::MAIL)
253  , array(C\Glyph\Glyph::NOTIFICATION)
254  , array(C\Glyph\Glyph::TAG)
255  , array(C\Glyph\Glyph::NOTE)
256  , array(C\Glyph\Glyph::COMMENT)
257  );
258  }
Create styles array
The data for the language used.

◆ test_dont_render_counter()

GlyphTest::test_dont_render_counter ( )

Definition at line 330 of file GlyphTest.php.

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

331  {
332  $r = new \ILIAS\UI\Implementation\Component\Glyph\Renderer($this->getUIFactory(), $this->getTemplateFactory(), $this->getLanguage(), $this->getJavaScriptBinding());
333  $f = $this->getCounterFactory();
334 
335  try {
336  $r->render($f->status(0), $this->getDefaultRenderer());
337  $this->assertFalse("This should not happen!");
338  } catch (\LogicException $e) {
339  }
340  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
getJavaScriptBinding()
Definition: Base.php:211
$r
Definition: example_031.php:79
getCounterFactory()
Definition: GlyphTest.php:20
getTemplateFactory()
Definition: Base.php:196
+ Here is the call graph for this function:

◆ test_glyph_action()

GlyphTest::test_glyph_action (   $factory_method)

glyph_type_provider

Definition at line 90 of file GlyphTest.php.

References getGlyphFactory().

91  {
92  $f = $this->getGlyphFactory();
93  $g = $f->$factory_method("http://www.ilias.de");
94 
95  $this->assertNotNull($g);
96  $this->assertEquals("http://www.ilias.de", $g->getAction());
97  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_glyph_no_action()

GlyphTest::test_glyph_no_action (   $factory_method)

glyph_type_provider

Definition at line 102 of file GlyphTest.php.

References getGlyphFactory().

103  {
104  $f = $this->getGlyphFactory();
105  $g = $f->$factory_method();
106 
107  $this->assertNotNull($g);
108  $this->assertEquals(null, $g->getAction());
109  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_glyph_types()

GlyphTest::test_glyph_types (   $factory_method)

glyph_type_provider

Definition at line 78 of file GlyphTest.php.

References getGlyphFactory().

79  {
80  $f = $this->getGlyphFactory();
81  $g = $f->$factory_method();
82 
83  $this->assertNotNull($g);
84  $this->assertEquals($factory_method, $g->getType());
85  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_immutability_withCounter()

GlyphTest::test_immutability_withCounter ( )

Definition at line 214 of file GlyphTest.php.

References getCounterFactory(), and getGlyphFactory().

215  {
216  $gf = $this->getGlyphFactory();
217  $cf = $this->getCounterFactory();
218 
219  $g = $gf->mail();
220  $g2 = $g
221  ->withCounter(
222  $cf->novelty(0)
223  );
224 
225  $counters = $g->getCounters();
226  $this->assertCount(0, $counters);
227  }
getCounterFactory()
Definition: GlyphTest.php:20
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_implements_factory_interface()

GlyphTest::test_implements_factory_interface (   $factory_method)

glyph_type_provider

Definition at line 67 of file GlyphTest.php.

References getGlyphFactory().

68  {
69  $f = $this->getGlyphFactory();
70 
71  $this->assertInstanceOf("ILIAS\\UI\\Component\\Glyph\\Factory", $f);
72  $this->assertInstanceOf("ILIAS\\UI\\Component\\Glyph\\Glyph", $f->$factory_method("http://www.ilias.de"));
73  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_known_glyphs_only()

GlyphTest::test_known_glyphs_only ( )

Definition at line 229 of file GlyphTest.php.

230  {
231  try {
232  new \ILIAS\UI\Implementation\Component\Glyph\Glyph("FOO", "http://www.ilias.de");
233  $this->assertFalse("We should not get here");
234  } catch (\InvalidArgumentException $e) {
235  }
236  }

◆ test_no_counter()

GlyphTest::test_no_counter (   $factory_method)

glyph_type_provider

Definition at line 130 of file GlyphTest.php.

References getGlyphFactory().

131  {
132  $f = $this->getGlyphFactory();
133  $g = $f->$factory_method();
134 
135  $this->assertCount(0, $g->getCounters());
136  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_one_counter()

GlyphTest::test_one_counter (   $counter_type)

counter_type_provider

Definition at line 141 of file GlyphTest.php.

References getCounterFactory(), and getGlyphFactory().

142  {
143  $gf = $this->getGlyphFactory();
144  $cf = $this->getCounterFactory();
145  $number = 1;
146 
147  $g = $gf
148  ->mail()
149  ->withCounter(
150  $cf->$counter_type($number)
151  );
152 
153  $counters = $g->getCounters();
154  $this->assertCount(1, $counters);
155  $c = $counters[0];
156  $this->assertEquals($counter_type, $c->getType());
157  $this->assertEquals($number, $c->getNumber());
158  }
getCounterFactory()
Definition: GlyphTest.php:20
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_only_two_counters()

GlyphTest::test_only_two_counters ( )

Definition at line 185 of file GlyphTest.php.

References array, getCounterFactory(), and getGlyphFactory().

186  {
187  $gf = $this->getGlyphFactory();
188  $cf = $this->getCounterFactory();
189  $number_s = 1;
190  $number_n1 = 2;
191  $number_n2 = 2;
192 
193  $g = $gf
194  ->mail()
195  ->withCounter(
196  $cf->status($number_s)
197  )
198  ->withCounter(
199  $cf->novelty($number_n1)
200  )
201  ->withCounter(
202  $cf->novelty($number_n2)
203  );
204 
205  $counters = $g->getCounters();
206  $this->assertCount(2, $counters);
207  $vals = array_map(function ($c) {
208  return array($c->getType(), $c->getNumber());
209  }, $counters);
210  $this->assertContains(array("status", $number_s), $vals);
211  $this->assertContains(array("novelty", $number_n2), $vals);
212  }
getCounterFactory()
Definition: GlyphTest.php:20
Create styles array
The data for the language used.
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_render_simple()

GlyphTest::test_render_simple (   $type)

glyph_type_provider

Definition at line 270 of file GlyphTest.php.

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

271  {
272  $f = $this->getGlyphFactory();
273  $r = $this->getDefaultRenderer();
274  $c = $f->$type("http://www.ilias.de");
275 
276  $html = $this->normalizeHTML($r->render($c));
277 
278  $css_classes = self::$canonical_css_classes[$type];
279  $aria_label = self::$aria_labels[$type];
280 
281  $expected = "<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
282  $this->assertEquals($expected, $html);
283  }
$type
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
normalizeHTML($html)
Definition: Base.php:243
$r
Definition: example_031.php:79
$html
Definition: example_001.php:87
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_render_with_on_load_code()

GlyphTest::test_render_with_on_load_code (   $type)

glyph_type_provider

Definition at line 345 of file GlyphTest.php.

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

346  {
347  $f = $this->getGlyphFactory();
348  $r = $this->getDefaultRenderer();
349  $ids = array();
350  $c = $f->$type("http://www.ilias.de")
351  ->withOnLoadCode(function ($id) use (&$ids) {
352  $ids[] = $id;
353  return "";
354  });
355 
356  $html = $this->normalizeHTML($r->render($c));
357 
358  $this->assertCount(1, $ids);
359 
360  $css_classes = self::$canonical_css_classes[$type];
361  $aria_label = self::$aria_labels[$type];
362 
363  $id = $ids[0];
364  $expected = "<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\" id=\"$id\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
365  $this->assertEquals($expected, $html);
366  }
$type
if(!array_key_exists('StateId', $_REQUEST)) $id
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
normalizeHTML($html)
Definition: Base.php:243
$r
Definition: example_031.php:79
Create styles array
The data for the language used.
$html
Definition: example_001.php:87
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_render_withCounter()

GlyphTest::test_render_withCounter (   $type)

counter_type_provider

Definition at line 288 of file GlyphTest.php.

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

289  {
290  $fg = $this->getGlyphFactory();
291  $fc = $this->getCounterFactory();
292  $r = $this->getDefaultRenderer();
293  $c = $fg->mail("http://www.ilias.de")->withCounter($fc->$type(42));
294 
295  $html = $this->normalizeHTML($r->render($c));
296 
297  $css_classes = self::$canonical_css_classes[C\Glyph\Glyph::MAIL];
298  $aria_label = self::$aria_labels[C\Glyph\Glyph::MAIL];
299 
300  $expected = "<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">" .
301  "<span class=\"$css_classes\" aria-hidden=\"true\"></span>" .
302  "<span class=\"badge badge-notify il-counter-$type\">42</span>" .
303  "<span class=\"il-counter-spacer\">42</span>" .
304  "</a>";
305  $this->assertEquals($expected, $html);
306  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
normalizeHTML($html)
Definition: Base.php:243
$r
Definition: example_031.php:79
getCounterFactory()
Definition: GlyphTest.php:20
$html
Definition: example_001.php:87
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_render_withTwoCounters()

GlyphTest::test_render_withTwoCounters ( )

Definition at line 308 of file GlyphTest.php.

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

309  {
310  $fg = $this->getGlyphFactory();
311  $fc = $this->getCounterFactory();
312  $r = $this->getDefaultRenderer();
313  $c = $fg->mail("http://www.ilias.de")
314  ->withCounter($fc->novelty(42))
315  ->withCounter($fc->status(7));
316 
317  $html = $this->normalizeHTML($r->render($c));
318 
319  $css_classes = self::$canonical_css_classes[C\Glyph\Glyph::MAIL];
320  $aria_label = self::$aria_labels[C\Glyph\Glyph::MAIL];
321  $expected = "<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">" .
322  "<span class=\"$css_classes\" aria-hidden=\"true\"></span>" .
323  "<span class=\"badge badge-notify il-counter-status\">7</span>" .
324  "<span class=\"badge badge-notify il-counter-novelty\">42</span>" .
325  "<span class=\"il-counter-spacer\">42</span>" .
326  "</a>";
327  $this->assertEquals($expected, $html);
328  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
normalizeHTML($html)
Definition: Base.php:243
$r
Definition: example_031.php:79
getCounterFactory()
Definition: GlyphTest.php:20
$html
Definition: example_001.php:87
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_two_counters()

GlyphTest::test_two_counters ( )

Definition at line 160 of file GlyphTest.php.

References array, getCounterFactory(), and getGlyphFactory().

161  {
162  $gf = $this->getGlyphFactory();
163  $cf = $this->getCounterFactory();
164  $number_s = 1;
165  $number_n = 2;
166 
167  $g = $gf
168  ->mail()
169  ->withCounter(
170  $cf->status($number_s)
171  )
172  ->withCounter(
173  $cf->novelty($number_n)
174  );
175 
176  $counters = $g->getCounters();
177  $this->assertCount(2, $counters);
178  $vals = array_map(function ($c) {
179  return array($c->getType(), $c->getNumber());
180  }, $counters);
181  $this->assertContains(array("status", $number_s), $vals);
182  $this->assertContains(array("novelty", $number_n), $vals);
183  }
getCounterFactory()
Definition: GlyphTest.php:20
Create styles array
The data for the language used.
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

◆ test_with_highlight()

GlyphTest::test_with_highlight (   $counter_type)

counter_type_provider

Definition at line 114 of file GlyphTest.php.

References getGlyphFactory().

115  {
116  $gf = $this->getGlyphFactory();
117 
118  $g = $gf
119  ->mail()
120  ;
121  $g2 = $g->withHighlight();
122 
123  $this->assertFalse($g->isHighlighted());
124  $this->assertTrue($g2->isHighlighted());
125  }
getGlyphFactory()
Definition: GlyphTest.php:15
+ Here is the call graph for this function:

Field Documentation

◆ $aria_labels

GlyphTest::$aria_labels
static
Initial value:
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 44 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 25 of file GlyphTest.php.


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