ILIAS  release_7 Revision v7.30-3-g800a261c036
ButtonTest Class Reference

Test on button implementation. More...

+ Inheritance diagram for ButtonTest:
+ Collaboration diagram for ButtonTest:

Public Member Functions

 getButtonFactory ()
 
 test_implements_factory_interface ()
 
 test_button_label_or_glyph_only ($factory_method)
 @dataProvider button_type_provider More...
 
 test_button_string_action_only ($factory_method)
 @dataProvider button_type_provider More...
 
 test_button_label ($factory_method)
 @dataProvider button_type_provider More...
 
 test_button_with_label ($factory_method)
 @dataProvider button_type_provider More...
 
 test_button_action ($factory_method)
 @dataProvider button_type_provider More...
 
 test_button_activated_on_default ($factory_method)
 @dataProvider button_type_provider More...
 
 test_button_deactivation ($factory_method)
 @dataProvider button_type_provider More...
 
 test_button_with_loading_animation ()
 test loading animation More...
 
 test_render_button_label ($factory_method)
 @dataProvider button_type_provider More...
 
 test_render_button_disabled ($factory_method)
 @dataProvider button_type_provider More...
 
 test_render_close_button ()
 
 test_render_button_with_on_load_code ($factory_method)
 @dataProvider button_type_provider More...
 
 test_____render_close_button_with_on_load_code ()
 
 test_btn_tag_relevance ()
 
 test_render_btn_tag_relevance ()
 
 test_render_btn_tag_colors ()
 
 test_render_btn_tag_classes ()
 
 test_button_with_aria_label ($factory_method)
 @dataProvider button_type_provider More...
 
 test_button_with_engageable ($factory_method)
 @dataProvider button_type_provider More...
 
 test_button_with_engaged ($factory_method)
 @dataProvider button_type_provider More...
 
 test_render_button_with_aria_label ($factory_method)
 @dataProvider button_type_provider More...
 
 test_render_button_with_aria_pressed ($factory_method)
 @dataProvider button_type_provider More...
 
 test_withOnClick_removes_action ($factory_method)
 @dataProvider button_type_provider More...
 
 test_appendOnClick_appends_to_action ($factory_method)
 @dataProvider button_type_provider More...
 
 test_render_button_with_signal ($factory_method)
 @dataProvider button_type_provider More...
 
 test_render_button_with_on_click_animation ()
 test rendering with on click animation More...
 
 test_factory_accepts_signal_as_action ($factory_method)
 @dataProvider button_type_provider More...
 
 button_type_provider ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Data Fields

const NOT_APPLICABLE = true
 

Static Public Attributes

static $canonical_css_classes
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Test on button implementation.

Definition at line 14 of file ButtonTest.php.

Member Function Documentation

◆ button_type_provider()

ButtonTest::button_type_provider ( )

Definition at line 513 of file ButtonTest.php.

514 {
515 return array( array("standard")
516 , array("primary")
517 , array("shy")
518 , array("tag")
519 );
520 }

◆ getButtonFactory()

◆ test_____render_close_button_with_on_load_code()

ButtonTest::test_____render_close_button_with_on_load_code ( )

Definition at line 229 of file ButtonTest.php.

230 {
231 $f = $this->getButtonFactory();
232 $r = $this->getDefaultRenderer();
233 $ids = array();
234 $b = $f->close()
235 ->withOnLoadCode(function ($id) use (&$ids) {
236 $ids[] = $id;
237 return "";
238 });
239
240 $html = $this->normalizeHTML($r->render($b));
241
242 $this->assertCount(1, $ids);
243
244 $id = $ids[0];
245 $expected = "<button type=\"button\" class=\"close\" aria-label=\"close\" id=\"$id\">" .
246 " <span aria-hidden=\"true\">&times;</span>" .
247 "</button>";
248 $this->assertEquals($expected, $html);
249 }
getButtonFactory()
Definition: ButtonTest.php:18
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
normalizeHTML($html)
Definition: Base.php:363

References Vendor\Package\$b, Vendor\Package\$f, getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_appendOnClick_appends_to_action()

ButtonTest::test_appendOnClick_appends_to_action (   $factory_method)

@dataProvider button_type_provider

Definition at line 438 of file ButtonTest.php.

439 {
440 $f = $this->getButtonFactory();
441 $signal1 = $this->createMock(C\Signal::class);
442 $signal2 = $this->createMock(C\Signal::class);
443 $button = $f->$factory_method("label", "http://www.example.com");
444
445 $button = $button->withOnClick($signal1)->appendOnClick($signal2);
446
447 $this->assertEquals([$signal1, $signal2], $button->getAction());
448 }

References Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_btn_tag_relevance()

ButtonTest::test_btn_tag_relevance ( )

Definition at line 251 of file ButtonTest.php.

252 {
253 $f = $this->getButtonFactory();
254 $b = $f->tag('tag', '#');
255 try {
256 $b->withRelevance(0);
257 $this->assertFalse("This should not happen");
258 } catch (\InvalidArgumentException $e) {
259 $this->assertTrue(true);
260 }
261 try {
262 $b->withRelevance('notsoimportant');
263 $this->assertFalse("This should not happen");
264 } catch (\InvalidArgumentException $e) {
265 $this->assertTrue(true);
266 }
267 }

References Vendor\Package\$b, Vendor\Package\$e, Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_button_action()

ButtonTest::test_button_action (   $factory_method)

@dataProvider button_type_provider

Definition at line 100 of file ButtonTest.php.

101 {
102 $f = $this->getButtonFactory();
103 $b = $f->$factory_method("label", "http://www.ilias.de");
104
105 $this->assertEquals("http://www.ilias.de", $b->getAction());
106 }

References Vendor\Package\$b, Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_button_activated_on_default()

ButtonTest::test_button_activated_on_default (   $factory_method)

@dataProvider button_type_provider

Definition at line 111 of file ButtonTest.php.

112 {
113 $f = $this->getButtonFactory();
114 $b = $f->$factory_method("label", "http://www.ilias.de");
115
116 $this->assertTrue($b->isActive());
117 }

References Vendor\Package\$b, Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_button_deactivation()

ButtonTest::test_button_deactivation (   $factory_method)

@dataProvider button_type_provider

Definition at line 122 of file ButtonTest.php.

123 {
124 $f = $this->getButtonFactory();
125 $b = $f->$factory_method("label", "http://www.ilias.de")
126 ->withUnavailableAction();
127
128 $this->assertFalse($b->isActive());
129 $this->assertEquals("http://www.ilias.de", $b->getAction());
130 }

References Vendor\Package\$b, Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_button_label()

ButtonTest::test_button_label (   $factory_method)

@dataProvider button_type_provider

Definition at line 75 of file ButtonTest.php.

76 {
77 $f = $this->getButtonFactory();
78 $b = $f->$factory_method("label", "http://www.ilias.de");
79
80 $this->assertEquals("label", $b->getLabel());
81 }

References Vendor\Package\$b, Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_button_label_or_glyph_only()

ButtonTest::test_button_label_or_glyph_only (   $factory_method)

@dataProvider button_type_provider

Definition at line 55 of file ButtonTest.php.

56 {
57 $this->expectException(\InvalidArgumentException::class);
58 $f = $this->getButtonFactory();
59 $f->$factory_method($this, "http://www.ilias.de");
60 }

References Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_button_string_action_only()

ButtonTest::test_button_string_action_only (   $factory_method)

@dataProvider button_type_provider

Definition at line 65 of file ButtonTest.php.

66 {
67 $this->expectException(\InvalidArgumentException::class);
68 $f = $this->getButtonFactory();
69 $f->$factory_method("label", $this);
70 }

References Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_button_with_aria_label()

ButtonTest::test_button_with_aria_label (   $factory_method)

@dataProvider button_type_provider

Definition at line 337 of file ButtonTest.php.

338 {
339 $f = $this->getButtonFactory();
340 $b = $f->$factory_method("label", "http://www.ilias.de")->withAriaLabel("ariatext");
341 $this->assertEquals("ariatext", $b->getAriaLabel());
342 }

References Vendor\Package\$b, Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_button_with_engageable()

ButtonTest::test_button_with_engageable (   $factory_method)

@dataProvider button_type_provider

Definition at line 347 of file ButtonTest.php.

348 {
349 $f = $this->getButtonFactory();
350 $b = $f->$factory_method("label", "http://www.ilias.de");
351 if ($b instanceof C\Button\Engageable) {
352 $this->assertEquals(false, $b->isEngageable());
353 $b2 = $f->$factory_method("label", "http://www.ilias.de")->withEngagedState(false);
354 $this->assertEquals(true, $b2->isEngageable());
355 } else {
356 $this->assertTrue(self::NOT_APPLICABLE);
357 }
358 }

References Vendor\Package\$b, Vendor\Package\$f, ILIAS\UI\Implementation\Component\Button\Engageable, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_button_with_engaged()

ButtonTest::test_button_with_engaged (   $factory_method)

@dataProvider button_type_provider

Definition at line 363 of file ButtonTest.php.

364 {
365 $f = $this->getButtonFactory();
366 $b = $f->$factory_method("label", "http://www.ilias.de");
367 if ($b instanceof C\Button\Engageable) {
368 $b = $b->withEngagedState(false);
369 $this->assertEquals(false, $b->isEngaged());
370 $b2 = $f->$factory_method("label", "http://www.ilias.de")->withEngagedState(true);
371 $this->assertEquals(true, $b2->isEngaged());
372 } else {
373 $this->assertTrue(self::NOT_APPLICABLE);
374 }
375 }

References Vendor\Package\$b, Vendor\Package\$f, ILIAS\UI\Implementation\Component\Button\Engageable, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_button_with_label()

ButtonTest::test_button_with_label (   $factory_method)

@dataProvider button_type_provider

Definition at line 86 of file ButtonTest.php.

87 {
88 $f = $this->getButtonFactory();
89 $b = $f->$factory_method("label", "http://www.ilias.de");
90
91 $b2 = $b->withLabel("label2");
92
93 $this->assertEquals("label", $b->getLabel());
94 $this->assertEquals("label2", $b2->getLabel());
95 }

References Vendor\Package\$b, Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_button_with_loading_animation()

ButtonTest::test_button_with_loading_animation ( )

test loading animation

Definition at line 135 of file ButtonTest.php.

136 {
137 $f = $this->getButtonFactory();
138 foreach (["standard", "primary"] as $method) {
139 $b = $f->$method("label", "http://www.ilias.de");
140
141 $this->assertFalse($b->hasLoadingAnimationOnClick());
142
143 $b = $b->withLoadingAnimationOnClick(true);
144
145 $this->assertTrue($b->hasLoadingAnimationOnClick());
146 }
147 }

References Vendor\Package\$b, Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_factory_accepts_signal_as_action()

ButtonTest::test_factory_accepts_signal_as_action (   $factory_method)

@dataProvider button_type_provider

Definition at line 503 of file ButtonTest.php.

504 {
505 $f = $this->getButtonFactory();
506 $signal = $this->createMock(C\Signal::class);
507
508 $button = $f->$factory_method("label", $signal);
509
510 $this->assertEquals([$signal], $button->getAction());
511 }

References Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_implements_factory_interface()

ButtonTest::test_implements_factory_interface ( )

Definition at line 29 of file ButtonTest.php.

30 {
31 $f = $this->getButtonFactory();
32
33 $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Factory", $f);
34 $this->assertInstanceOf(
35 "ILIAS\\UI\\Component\\Button\\Standard",
36 $f->standard("label", "http://www.ilias.de")
37 );
38 $this->assertInstanceOf(
39 "ILIAS\\UI\\Component\\Button\\Primary",
40 $f->primary("label", "http://www.ilias.de")
41 );
42 $this->assertInstanceOf(
43 "ILIAS\\UI\\Component\\Button\\Close",
44 $f->close()
45 );
46 $this->assertInstanceOf(
47 "ILIAS\\UI\\Component\\Button\\Shy",
48 $f->shy("label", "http://www.ilias.de")
49 );
50 }

References Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

◆ test_render_btn_tag_classes()

ButtonTest::test_render_btn_tag_classes ( )

Definition at line 319 of file ButtonTest.php.

320 {
321 $f = $this->getButtonFactory();
322 $r = $this->getDefaultRenderer();
323 $df = new \ILIAS\Data\Factory;
324
325 $classes = array('cl1', 'cl2');
326 $b = $f->tag('tag', '#')
327 ->withClasses($classes);
328 $this->assertEquals($classes, $b->getClasses());
329
330 $html = $this->normalizeHTML($r->render($b));
331 $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh cl1 cl2" data-action="#" id="id_1">tag</button>';
332 $this->assertEquals($expected, $html);
333 }

References Vendor\Package\$b, Vendor\Package\$f, getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_btn_tag_colors()

ButtonTest::test_render_btn_tag_colors ( )

Definition at line 298 of file ButtonTest.php.

299 {
300 $f = $this->getButtonFactory();
301 $r = $this->getDefaultRenderer();
302 $df = new \ILIAS\Data\Factory;
303
304 $bgcol = $df->color('#00ff00');
305
306 $b = $f->tag('tag', '#')
307 ->withBackgroundColor($bgcol);
308 $html = $this->normalizeHTML($r->render($b));
309 $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #000000;" data-action="#" id="id_1">tag</button>';
310 $this->assertEquals($expected, $html);
311
312 $fcol = $df->color('#ddd');
313 $b = $b->withForegroundColor($fcol);
314 $html = $this->normalizeHTML($r->render($b));
315 $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #dddddd;" data-action="#" id="id_2">tag</button>';
316 $this->assertEquals($expected, $html);
317 }

References Vendor\Package\$b, Vendor\Package\$f, getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_btn_tag_relevance()

ButtonTest::test_render_btn_tag_relevance ( )

Definition at line 269 of file ButtonTest.php.

270 {
271 $expectations = array(
272 '<button class="btn btn-tag btn-tag-relevance-verylow" data-action="#" id="id_1">tag</button>',
273 '<button class="btn btn-tag btn-tag-relevance-low" data-action="#" id="id_2">tag</button>',
274 '<button class="btn btn-tag btn-tag-relevance-middle" data-action="#" id="id_3">tag</button>',
275 '<button class="btn btn-tag btn-tag-relevance-high" data-action="#" id="id_4">tag</button>',
276 '<button class="btn btn-tag btn-tag-relevance-veryhigh" data-action="#" id="id_5">tag</button>'
277 );
278
279 $f = $this->getButtonFactory();
280 $r = $this->getDefaultRenderer();
281 $t = $f->tag('tag', '#');
282 $possible_relevances = array(
283 $t::REL_VERYLOW,
284 $t::REL_LOW,
285 $t::REL_MID,
286 $t::REL_HIGH,
287 $t::REL_VERYHIGH
288 );
289 foreach ($possible_relevances as $w) {
290 $html = $this->normalizeHTML(
291 $r->render($t->withRelevance($w))
292 );
293 $expected = $expectations[array_search($w, $possible_relevances)];
294 $this->assertEquals($expected, $html);
295 }
296 }

References Vendor\Package\$f, getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_button_disabled()

ButtonTest::test_render_button_disabled (   $factory_method)

@dataProvider button_type_provider

Definition at line 171 of file ButtonTest.php.

172 {
173 $ln = "http://www.ilias.de";
174 $f = $this->getButtonFactory();
175 $b = $f->$factory_method("label", $ln)
176 ->withUnavailableAction();
177 $r = $this->getDefaultRenderer();
178
179 $html = $this->normalizeHTML($r->render($b));
180
181 $css_classes = self::$canonical_css_classes[$factory_method];
182 $expected = "<button class=\"$css_classes\" data-action=\"$ln\" disabled=\"disabled\">" .
183 "label" .
184 "</button>";
185 $this->assertHTMLEquals($expected, $html);
186 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372

References Vendor\Package\$b, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_button_label()

ButtonTest::test_render_button_label (   $factory_method)

@dataProvider button_type_provider

Definition at line 152 of file ButtonTest.php.

153 {
154 $ln = "http://www.ilias.de";
155 $f = $this->getButtonFactory();
156 $b = $f->$factory_method("label", $ln);
157 $r = $this->getDefaultRenderer();
158
159 $html = $this->normalizeHTML($r->render($b));
160
161 $css_classes = self::$canonical_css_classes[$factory_method];
162 $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
163 "label" .
164 "</button>";
165 $this->assertHTMLEquals($expected, $html);
166 }

References Vendor\Package\$b, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_button_with_aria_label()

ButtonTest::test_render_button_with_aria_label (   $factory_method)

@dataProvider button_type_provider

Definition at line 380 of file ButtonTest.php.

381 {
382 $ln = "http://www.ilias.de";
383 $f = $this->getButtonFactory();
384 $r = $this->getDefaultRenderer();
385 $b = $f->$factory_method("label", $ln)->withAriaLabel("aria label text");
386 $aria_label = $b->getAriaLabel();
387
388 $html = $this->normalizeHTML($r->render($b));
389 $css_classes = self::$canonical_css_classes[$factory_method];
390 $expected = "<button class=\"$css_classes\" aria-label=\"$aria_label\" data-action=\"$ln\" id=\"id_1\">" .
391 "label" .
392 "</button>";
393 $this->assertHTMLEquals($expected, $html);
394 }

References Vendor\Package\$b, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_button_with_aria_pressed()

ButtonTest::test_render_button_with_aria_pressed (   $factory_method)

@dataProvider button_type_provider

Definition at line 399 of file ButtonTest.php.

400 {
401 $ln = "http://www.ilias.de";
402 $f = $this->getButtonFactory();
403 $r = $this->getDefaultRenderer();
404 $b = $f->$factory_method("label", $ln);
405 if ($b instanceof C\Button\Engageable) {
406 $b = $b->withEngagedState(true);
407
408 $html = $this->normalizeHTML($r->render($b));
409 $css_classes = self::$canonical_css_classes[$factory_method];
410 $css_classes .= ' engaged';
411 $expected = "<button class=\"$css_classes\" aria-pressed=\"true\" data-action=\"$ln\" id=\"id_1\">" .
412 "label" .
413 "</button>";
414 $this->assertHTMLEquals($expected, $html);
415 } else {
416 $this->assertTrue(self::NOT_APPLICABLE);
417 }
418 }

References Vendor\Package\$b, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS\UI\Implementation\Component\Button\Engageable, getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_button_with_on_click_animation()

ButtonTest::test_render_button_with_on_click_animation ( )

test rendering with on click animation

Definition at line 477 of file ButtonTest.php.

478 {
479 foreach (["primary", "standard"] as $method) {
480 $ln = "http://www.ilias.de";
481 $f = $this->getButtonFactory();
482 $r = $this->getDefaultRenderer();
483 $b = $f->$method("label", $ln)
484 ->withLoadingAnimationOnClick(true);
485
486 $html = $this->normalizeHTML($r->render($b));
487
488 $css_classes = self::$canonical_css_classes[$method];
489 $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
490 "label" .
491 "</button>";
492 $this->assertHTMLEquals($expected, $html);
493 }
494 }

References Vendor\Package\$b, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_button_with_on_load_code()

ButtonTest::test_render_button_with_on_load_code (   $factory_method)

@dataProvider button_type_provider

Definition at line 205 of file ButtonTest.php.

206 {
207 $ln = "http://www.ilias.de";
208 $f = $this->getButtonFactory();
209 $r = $this->getDefaultRenderer();
210 $ids = array();
211 $b = $f->$factory_method("label", $ln)
212 ->withOnLoadCode(function ($id) use (&$ids) {
213 $ids[] = $id;
214 return "";
215 });
216
217 $html = $this->normalizeHTML($r->render($b));
218
219 $this->assertCount(1, $ids);
220
221 $id = $ids[0];
222 $css_classes = self::$canonical_css_classes[$factory_method];
223 $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"$id\">" .
224 "label" .
225 "</button>";
226 $this->assertHTMLEquals($expected, $html);
227 }

References Vendor\Package\$b, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_button_with_signal()

ButtonTest::test_render_button_with_signal (   $factory_method)

@dataProvider button_type_provider

Definition at line 453 of file ButtonTest.php.

454 {
455 $ln = "http://www.ilias.de";
456 $f = $this->getButtonFactory();
457 $signal = $this->createMock(Signal::class);
458 $signal->method("__toString")
459 ->willReturn("MOCK_SIGNAL");
460
461 $b = $f->$factory_method("label", $ln)
462 ->withOnClick($signal);
463 $r = $this->getDefaultRenderer();
464
465 $html = $this->normalizeHTML($r->render($b));
466
467 $css_classes = self::$canonical_css_classes[$factory_method];
468 $expected = "<button class=\"$css_classes\" id=\"id_1\">" .
469 "label" .
470 "</button>";
471 $this->assertHTMLEquals($expected, $html);
472 }

References Vendor\Package\$b, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_close_button()

ButtonTest::test_render_close_button ( )

Definition at line 188 of file ButtonTest.php.

189 {
190 $f = $this->getButtonFactory();
191 $r = $this->getDefaultRenderer();
192 $b = $f->close();
193
194 $html = $this->normalizeHTML($r->render($b));
195
196 $expected = "<button type=\"button\" class=\"close\" aria-label=\"close\">" .
197 " <span aria-hidden=\"true\">&times;</span>" .
198 "</button>";
199 $this->assertEquals($expected, $html);
200 }

References Vendor\Package\$b, Vendor\Package\$f, getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_withOnClick_removes_action()

ButtonTest::test_withOnClick_removes_action (   $factory_method)

@dataProvider button_type_provider

Definition at line 423 of file ButtonTest.php.

424 {
425 $f = $this->getButtonFactory();
426 $signal = $this->createMock(C\Signal::class);
427 $button = $f->$factory_method("label", "http://www.example.com");
428 $this->assertEquals("http://www.example.com", $button->getAction());
429
430 $button = $button->withOnClick($signal);
431
432 $this->assertEquals([$signal], $button->getAction());
433 }

References Vendor\Package\$f, and getButtonFactory().

+ Here is the call graph for this function:

Field Documentation

◆ $canonical_css_classes

ButtonTest::$canonical_css_classes
static
Initial value:
= array( "standard" => "btn btn-default"
, "primary" => "btn btn-default btn-primary"
, "shy" => "btn btn-link"
, "tag" => "btn btn-tag btn-tag-relevance-veryhigh"
)

Definition at line 23 of file ButtonTest.php.

◆ NOT_APPLICABLE

const ButtonTest::NOT_APPLICABLE = true

Definition at line 16 of file ButtonTest.php.


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