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

261 {
262 return array( array("status")
263 , array("novelty")
264 );
265 }

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

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 }

◆ test_dont_render_counter()

GlyphTest::test_dont_render_counter ( )

Definition at line 330 of file GlyphTest.php.

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 }
getCounterFactory()
Definition: GlyphTest.php:20
getJavaScriptBinding()
Definition: Base.php:211
getTemplateFactory()
Definition: Base.php:196
$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 90 of file GlyphTest.php.

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

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

103 {
104 $f = $this->getGlyphFactory();
105 $g = $f->$factory_method();
106
107 $this->assertNotNull($g);
108 $this->assertEquals(null, $g->getAction());
109 }

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

79 {
80 $f = $this->getGlyphFactory();
81 $g = $f->$factory_method();
82
83 $this->assertNotNull($g);
84 $this->assertEquals($factory_method, $g->getType());
85 }

References getGlyphFactory().

+ Here is the call graph for this function:

◆ test_immutability_withCounter()

GlyphTest::test_immutability_withCounter ( )

Definition at line 214 of file GlyphTest.php.

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 }

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

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 }

References getGlyphFactory().

+ 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)

@dataProvider glyph_type_provider

Definition at line 130 of file GlyphTest.php.

131 {
132 $f = $this->getGlyphFactory();
133 $g = $f->$factory_method();
134
135 $this->assertCount(0, $g->getCounters());
136 }

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

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 }

References getCounterFactory(), and getGlyphFactory().

+ 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.

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 }

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

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 }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
normalizeHTML($html)
Definition: Base.php:243
$html
Definition: example_001.php:87
$type

References $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 345 of file GlyphTest.php.

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 }
if(!array_key_exists('StateId', $_REQUEST)) $id

References $html, $id, $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 288 of file GlyphTest.php.

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 }

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

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 }

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

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 }

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

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 }

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 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: