ILIAS  release_8 Revision v8.24
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 (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_button_string_action_only (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_button_label (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_button_with_label (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_button_action (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_button_activated_on_default (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_button_deactivation (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_button_with_loading_animation ()
 test loading animation More...
 
 test_render_button_label (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_render_button_disabled (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_render_close_button ()
 
 test_render_minimize_button ()
 
 test_render_button_with_on_load_code (string $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 (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_button_with_engageable (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_button_with_engaged (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_render_button_with_aria_label (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_render_button_with_aria_pressed (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_withOnClick_removes_action (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_appendOnClick_appends_to_action (string $factory_method)
 @dataProvider button_type_provider More...
 
 test_render_button_with_signal (string $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 (string $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 ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Data Fields

const NOT_APPLICABLE = true
 

Static Public Attributes

static array $canonical_css_classes
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Detailed Description

Test on button implementation.

Definition at line 31 of file ButtonTest.php.

Member Function Documentation

◆ button_type_provider()

ButtonTest::button_type_provider ( )

Definition at line 540 of file ButtonTest.php.

540 : array
541 {
542 return [
543 ['standard'],
544 ['primary'],
545 ['shy'],
546 ['tag']
547 ];
548 }

◆ getButtonFactory()

◆ test_____render_close_button_with_on_load_code()

ButtonTest::test_____render_close_button_with_on_load_code ( )

Definition at line 261 of file ButtonTest.php.

261 : void
262 {
263 $f = $this->getButtonFactory();
264 $r = $this->getDefaultRenderer();
265 $ids = array();
266 $b = $f->close()
267 ->withOnLoadCode(function ($id) use (&$ids): string {
268 $ids[] = $id;
269 return "";
270 });
271
272 $html = $this->normalizeHTML($r->render($b));
273
274 $this->assertCount(1, $ids);
275
276 $id = $ids[0];
277 $expected = "<button type=\"button\" class=\"close\" aria-label=\"close\" id=\"$id\">" .
278 " <span aria-hidden=\"true\">&times;</span>" .
279 "</button>";
280 $this->assertEquals($expected, $html);
281 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getButtonFactory()
Definition: ButtonTest.php:35
normalizeHTML(string $html)
Definition: Base.php:422
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355

References Vendor\Package\$b, Vendor\Package\$f, $id, 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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 465 of file ButtonTest.php.

465 : void
466 {
467 $f = $this->getButtonFactory();
468 $signal1 = $this->createMock(C\Signal::class);
469 $signal2 = $this->createMock(C\Signal::class);
470 $button = $f->$factory_method("label", "http://www.example.com");
471
472 $button = $button->withOnClick($signal1)->appendOnClick($signal2);
473
474 $this->assertEquals([$signal1, $signal2], $button->getAction());
475 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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 283 of file ButtonTest.php.

283 : void
284 {
285 $f = $this->getButtonFactory();
286 $b = $f->tag('tag', '#');
287
288 $this->expectException(TypeError::class);
289 $b->withRelevance(0);
290
291 $this->expectException(TypeError::class);
292 $b->withRelevance('notsoimportant');
293 }

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

+ Here is the call graph for this function:

◆ test_button_action()

ButtonTest::test_button_action ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 118 of file ButtonTest.php.

118 : void
119 {
120 $f = $this->getButtonFactory();
121 $b = $f->$factory_method("label", "http://www.ilias.de");
122
123 $this->assertEquals("http://www.ilias.de", $b->getAction());
124 }

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 129 of file ButtonTest.php.

129 : void
130 {
131 $f = $this->getButtonFactory();
132 $b = $f->$factory_method("label", "http://www.ilias.de");
133
134 $this->assertTrue($b->isActive());
135 }

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

+ Here is the call graph for this function:

◆ test_button_deactivation()

ButtonTest::test_button_deactivation ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 140 of file ButtonTest.php.

140 : void
141 {
142 $f = $this->getButtonFactory();
143 $b = $f->$factory_method("label", "http://www.ilias.de")
144 ->withUnavailableAction();
145
146 $this->assertFalse($b->isActive());
147 $this->assertEquals("http://www.ilias.de", $b->getAction());
148 }

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

+ Here is the call graph for this function:

◆ test_button_label()

ButtonTest::test_button_label ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 93 of file ButtonTest.php.

93 : void
94 {
95 $f = $this->getButtonFactory();
96 $b = $f->$factory_method("label", "http://www.ilias.de");
97
98 $this->assertEquals("label", $b->getLabel());
99 }

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 73 of file ButtonTest.php.

73 : void
74 {
75 $this->expectException(TypeError::class);
76 $f = $this->getButtonFactory();
77 $f->$factory_method($this, "http://www.ilias.de");
78 }

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 83 of file ButtonTest.php.

83 : void
84 {
85 $this->expectException(InvalidArgumentException::class);
86 $f = $this->getButtonFactory();
87 $f->$factory_method("label", $this);
88 }

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 364 of file ButtonTest.php.

364 : void
365 {
366 $f = $this->getButtonFactory();
367 $b = $f->$factory_method("label", "http://www.ilias.de")->withAriaLabel("ariatext");
368 $this->assertEquals("ariatext", $b->getAriaLabel());
369 }

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 374 of file ButtonTest.php.

374 : void
375 {
376 $f = $this->getButtonFactory();
377 $b = $f->$factory_method("label", "http://www.ilias.de");
378 if ($b instanceof C\Button\Engageable) {
379 $this->assertEquals(false, $b->isEngageable());
380 $b2 = $f->$factory_method("label", "http://www.ilias.de")->withEngagedState(false);
381 $this->assertEquals(true, $b2->isEngageable());
382 } else {
383 $this->assertTrue(self::NOT_APPLICABLE);
384 }
385 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 390 of file ButtonTest.php.

390 : void
391 {
392 $f = $this->getButtonFactory();
393 $b = $f->$factory_method("label", "http://www.ilias.de");
394 if ($b instanceof C\Button\Engageable) {
395 $b = $b->withEngagedState(false);
396 $this->assertEquals(false, $b->isEngaged());
397 $b2 = $f->$factory_method("label", "http://www.ilias.de")->withEngagedState(true);
398 $this->assertEquals(true, $b2->isEngaged());
399 } else {
400 $this->assertTrue(self::NOT_APPLICABLE);
401 }
402 }

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 104 of file ButtonTest.php.

104 : void
105 {
106 $f = $this->getButtonFactory();
107 $b = $f->$factory_method("label", "http://www.ilias.de");
108
109 $b2 = $b->withLabel("label2");
110
111 $this->assertEquals("label", $b->getLabel());
112 $this->assertEquals("label2", $b2->getLabel());
113 }

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 153 of file ButtonTest.php.

153 : void
154 {
155 $f = $this->getButtonFactory();
156 foreach (["standard", "primary"] as $method) {
157 $b = $f->$method("label", "http://www.ilias.de");
158
159 $this->assertFalse($b->hasLoadingAnimationOnClick());
160
161 $b = $b->withLoadingAnimationOnClick(true);
162
163 $this->assertTrue($b->hasLoadingAnimationOnClick());
164 }
165 }

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 530 of file ButtonTest.php.

530 : void
531 {
532 $f = $this->getButtonFactory();
533 $signal = $this->createMock(C\Signal::class);
534
535 $button = $f->$factory_method("label", $signal);
536
537 $this->assertEquals([$signal], $button->getAction());
538 }

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 47 of file ButtonTest.php.

47 : void
48 {
49 $f = $this->getButtonFactory();
50
51 $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Factory", $f);
52 $this->assertInstanceOf(
53 "ILIAS\\UI\\Component\\Button\\Standard",
54 $f->standard("label", "http://www.ilias.de")
55 );
56 $this->assertInstanceOf(
57 "ILIAS\\UI\\Component\\Button\\Primary",
58 $f->primary("label", "http://www.ilias.de")
59 );
60 $this->assertInstanceOf(
61 "ILIAS\\UI\\Component\\Button\\Close",
62 $f->close()
63 );
64 $this->assertInstanceOf(
65 "ILIAS\\UI\\Component\\Button\\Shy",
66 $f->shy("label", "http://www.ilias.de")
67 );
68 }

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 345 of file ButtonTest.php.

345 : void
346 {
347 $f = $this->getButtonFactory();
348 $r = $this->getDefaultRenderer();
349 $df = new \ILIAS\Data\Factory();
350
351 $classes = array('cl1', 'cl2');
352 $b = $f->tag('tag', '#')
353 ->withClasses($classes);
354 $this->assertEquals($classes, $b->getClasses());
355
356 $html = $this->normalizeHTML($r->render($b));
357 $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh cl1 cl2" data-action="#" id="id_1">tag</button>';
358 $this->assertEquals($expected, $html);
359 }

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 324 of file ButtonTest.php.

324 : void
325 {
326 $f = $this->getButtonFactory();
327 $r = $this->getDefaultRenderer();
328 $df = new \ILIAS\Data\Factory();
329
330 $bgcol = $df->color('#00ff00');
331
332 $b = $f->tag('tag', '#')
333 ->withBackgroundColor($bgcol);
334 $html = $this->normalizeHTML($r->render($b));
335 $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #000000;" data-action="#" id="id_1">tag</button>';
336 $this->assertEquals($expected, $html);
337
338 $fcol = $df->color('#ddd');
339 $b = $b->withForegroundColor($fcol);
340 $html = $this->normalizeHTML($r->render($b));
341 $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #dddddd;" data-action="#" id="id_2">tag</button>';
342 $this->assertEquals($expected, $html);
343 }

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 295 of file ButtonTest.php.

295 : void
296 {
297 $expectations = array(
298 '<button class="btn btn-tag btn-tag-relevance-verylow" data-action="#" id="id_1">tag</button>',
299 '<button class="btn btn-tag btn-tag-relevance-low" data-action="#" id="id_2">tag</button>',
300 '<button class="btn btn-tag btn-tag-relevance-middle" data-action="#" id="id_3">tag</button>',
301 '<button class="btn btn-tag btn-tag-relevance-high" data-action="#" id="id_4">tag</button>',
302 '<button class="btn btn-tag btn-tag-relevance-veryhigh" data-action="#" id="id_5">tag</button>'
303 );
304
305 $f = $this->getButtonFactory();
306 $r = $this->getDefaultRenderer();
307 $t = $f->tag('tag', '#');
308 $possible_relevances = array(
309 $t::REL_VERYLOW,
310 $t::REL_LOW,
311 $t::REL_MID,
312 $t::REL_HIGH,
313 $t::REL_VERYHIGH
314 );
315 foreach ($possible_relevances as $w) {
316 $html = $this->normalizeHTML(
317 $r->render($t->withRelevance($w))
318 );
319 $expected = $expectations[array_search($w, $possible_relevances)];
320 $this->assertEquals($expected, $html);
321 }
322 }

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 189 of file ButtonTest.php.

189 : void
190 {
191 $ln = "http://www.ilias.de";
192 $f = $this->getButtonFactory();
193 $b = $f->$factory_method("label", $ln)
194 ->withUnavailableAction();
195 $r = $this->getDefaultRenderer();
196
197 $html = $this->normalizeHTML($r->render($b));
198
199 $css_classes = self::$canonical_css_classes[$factory_method];
200 $expected = "<button class=\"$css_classes\" data-action=\"$ln\" disabled=\"disabled\">" .
201 "label" .
202 "</button>";
203 $this->assertHTMLEquals($expected, $html);
204 }
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 170 of file ButtonTest.php.

170 : void
171 {
172 $ln = "http://www.ilias.de";
173 $f = $this->getButtonFactory();
174 $b = $f->$factory_method("label", $ln);
175 $r = $this->getDefaultRenderer();
176
177 $html = $this->normalizeHTML($r->render($b));
178
179 $css_classes = self::$canonical_css_classes[$factory_method];
180 $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
181 "label" .
182 "</button>";
183 $this->assertHTMLEquals($expected, $html);
184 }

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 407 of file ButtonTest.php.

407 : void
408 {
409 $ln = "http://www.ilias.de";
410 $f = $this->getButtonFactory();
411 $r = $this->getDefaultRenderer();
412 $b = $f->$factory_method("label", $ln)->withAriaLabel("aria label text");
413 $aria_label = $b->getAriaLabel();
414
415 $html = $this->normalizeHTML($r->render($b));
416 $css_classes = self::$canonical_css_classes[$factory_method];
417 $expected = "<button class=\"$css_classes\" aria-label=\"$aria_label\" data-action=\"$ln\" id=\"id_1\">" .
418 "label" .
419 "</button>";
420 $this->assertHTMLEquals($expected, $html);
421 }

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 426 of file ButtonTest.php.

426 : void
427 {
428 $ln = "http://www.ilias.de";
429 $f = $this->getButtonFactory();
430 $r = $this->getDefaultRenderer();
431 $b = $f->$factory_method("label", $ln);
432 if ($b instanceof C\Button\Engageable) {
433 $b = $b->withEngagedState(true);
434
435 $html = $this->normalizeHTML($r->render($b));
436 $css_classes = self::$canonical_css_classes[$factory_method];
437 $css_classes .= ' engaged';
438 $expected = "<button class=\"$css_classes\" aria-pressed=\"true\" data-action=\"$ln\" id=\"id_1\">" .
439 "label" .
440 "</button>";
441 $this->assertHTMLEquals($expected, $html);
442 } else {
443 $this->assertTrue(self::NOT_APPLICABLE);
444 }
445 }

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 504 of file ButtonTest.php.

504 : void
505 {
506 foreach (["primary", "standard"] as $method) {
507 $ln = "http://www.ilias.de";
508 $f = $this->getButtonFactory();
509 $r = $this->getDefaultRenderer();
510 $b = $f->$method("label", $ln)
511 ->withLoadingAnimationOnClick(true);
512
513 $html = $this->normalizeHTML($r->render($b));
514
515 $css_classes = self::$canonical_css_classes[$method];
516 $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
517 "label" .
518 "</button>";
519 $this->assertHTMLEquals($expected, $html);
520 }
521 }

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 237 of file ButtonTest.php.

237 : void
238 {
239 $ln = "http://www.ilias.de";
240 $f = $this->getButtonFactory();
241 $r = $this->getDefaultRenderer();
242 $ids = array();
243 $b = $f->$factory_method("label", $ln)
244 ->withOnLoadCode(function ($id) use (&$ids): string {
245 $ids[] = $id;
246 return "";
247 });
248
249 $html = $this->normalizeHTML($r->render($b));
250
251 $this->assertCount(1, $ids);
252
253 $id = $ids[0];
254 $css_classes = self::$canonical_css_classes[$factory_method];
255 $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"$id\">" .
256 "label" .
257 "</button>";
258 $this->assertHTMLEquals($expected, $html);
259 }

References Vendor\Package\$b, Vendor\Package\$f, $id, 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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 480 of file ButtonTest.php.

480 : void
481 {
482 $ln = "http://www.ilias.de";
483 $f = $this->getButtonFactory();
484 $signal = $this->createMock(Signal::class);
485 $signal->method("__toString")
486 ->willReturn("MOCK_SIGNAL");
487
488 $b = $f->$factory_method("label", $ln)
489 ->withOnClick($signal);
490 $r = $this->getDefaultRenderer();
491
492 $html = $this->normalizeHTML($r->render($b));
493
494 $css_classes = self::$canonical_css_classes[$factory_method];
495 $expected = "<button class=\"$css_classes\" id=\"id_1\">" .
496 "label" .
497 "</button>";
498 $this->assertHTMLEquals($expected, $html);
499 }

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 206 of file ButtonTest.php.

206 : void
207 {
208 $f = $this->getButtonFactory();
209 $r = $this->getDefaultRenderer();
210 $b = $f->close();
211
212 $html = $this->normalizeHTML($r->render($b));
213
214 $expected = "<button type=\"button\" class=\"close\" aria-label=\"close\">" .
215 " <span aria-hidden=\"true\">&times;</span>" .
216 "</button>";
217 $this->assertEquals($expected, $html);
218 }

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

ButtonTest::test_render_minimize_button ( )

Definition at line 220 of file ButtonTest.php.

220 : void
221 {
222 $f = $this->getButtonFactory();
223 $r = $this->getDefaultRenderer();
224 $b = $f->minimize();
225
226 $html = $this->normalizeHTML($r->render($b));
227
228 $expected = "<button type=\"button\" class=\"minimize\" aria-label=\"minimize\">" .
229 " <span aria-hidden=\"true\">−</span>" .
230 "</button>";
231 $this->assertEquals($expected, $html);
232 }

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 ( string  $factory_method)

@dataProvider button_type_provider

Definition at line 450 of file ButtonTest.php.

450 : void
451 {
452 $f = $this->getButtonFactory();
453 $signal = $this->createMock(C\Signal::class);
454 $button = $f->$factory_method("label", "http://www.example.com");
455 $this->assertEquals("http://www.example.com", $button->getAction());
456
457 $button = $button->withOnClick($signal);
458
459 $this->assertEquals([$signal], $button->getAction());
460 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $canonical_css_classes

array ButtonTest::$canonical_css_classes
static
Initial value:
= [
"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 40 of file ButtonTest.php.

◆ NOT_APPLICABLE

const ButtonTest::NOT_APPLICABLE = true

Definition at line 33 of file ButtonTest.php.


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