ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ButtonTest Class Reference

Test on button implementation. More...

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

Public Member Functions

 getButtonFactory ()
 
 testImplementsFactoryInterface ()
 
 testButtonLabelOrGlyphOnly (string $factory_method)
 getButtonTypeProvider More...
 
 testButtonStringActionOnly (string $factory_method)
 getButtonTypeProvider More...
 
 testButtonLabel (string $factory_method)
 getButtonTypeProvider More...
 
 testButtonWithLabel (string $factory_method)
 getButtonTypeProvider More...
 
 testButtonAction (string $factory_method)
 getButtonTypeProvider More...
 
 testButtonActivatedOnDefault (string $factory_method)
 getButtonTypeProvider More...
 
 testButtonDeactivation (string $factory_method)
 getButtonTypeProvider More...
 
 testButtonWithLoadingAnimation ()
 test loading animation More...
 
 testRenderButtonLabel (string $factory_method)
 getButtonTypeProvider More...
 
 testRenderButtonDisabled (string $factory_method)
 getButtonTypeProvider More...
 
 testRenderCloseButton ()
 
 testRenderMinimizeButton ()
 
 testRenderButtonWithOnLoadCode (string $factory_method)
 getButtonTypeProvider More...
 
 testRenderCloseButtonWithOnLoadCode ()
 
 testBtnTagRelevance ()
 
 testRenderBtnTagRelevance ()
 
 testRenderBtnTagColors ()
 
 testRenderBtnTagClasses ()
 
 testButtonWithAriaLabel (string $factory_method)
 getButtonTypeProvider More...
 
 testButtonWithEngageable (string $factory_method)
 getButtonTypeProvider More...
 
 testButtonWithEngaged (string $factory_method)
 getButtonTypeProvider More...
 
 testRenderButtonWithAriaLabel (string $factory_method)
 getButtonTypeProvider More...
 
 testRenderButtonWithAriaPressed (string $factory_method)
 getButtonTypeProvider More...
 
 testWithOnClickRemovesAction (string $factory_method)
 getButtonTypeProvider More...
 
 testAppendOnClickAppendsToAction (string $factory_method)
 getButtonTypeProvider More...
 
 testRenderButtonWithSignal (string $factory_method)
 getButtonTypeProvider More...
 
 testRenderButtonWithOnClickAnimation ()
 test rendering with on click animation More...
 
 testButtonRendersTooltip (string $factory_method)
 getButtonTypeProvider More...
 
 testFactoryAcceptsSignalAsAction (string $factory_method)
 getButtonTypeProvider More...
 
 getButtonTypeProvider ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getHelpTextRetriever ()
 
 getUploadLimitResolver ()
 
 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
 
static array primary
 

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

Member Function Documentation

◆ getButtonFactory()

◆ getButtonTypeProvider()

ButtonTest::getButtonTypeProvider ( )

Definition at line 573 of file ButtonTest.php.

573  : array
574  {
575  return [
576  ['standard'],
577  ['primary'],
578  ['shy'],
579  ['tag']
580  ];
581  }

◆ testAppendOnClickAppendsToAction()

ButtonTest::testAppendOnClickAppendsToAction ( string  $factory_method)

getButtonTypeProvider

Definition at line 469 of file ButtonTest.php.

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

469  : void
470  {
471  $f = $this->getButtonFactory();
472  $signal1 = $this->createMock(C\Signal::class);
473  $signal2 = $this->createMock(C\Signal::class);
474  $button = $f->$factory_method("label", "http://www.example.com");
475 
476  $button = $button->withOnClick($signal1)->appendOnClick($signal2);
477 
478  $this->assertEquals([$signal1, $signal2], $button->getAction());
479  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testBtnTagRelevance()

ButtonTest::testBtnTagRelevance ( )

Definition at line 287 of file ButtonTest.php.

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

287  : void
288  {
289  $f = $this->getButtonFactory();
290  $b = $f->tag('tag', '#');
291 
292  $this->expectException(TypeError::class);
293  $b->withRelevance(0);
294 
295  $this->expectException(TypeError::class);
296  $b->withRelevance('notsoimportant');
297  }
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testButtonAction()

ButtonTest::testButtonAction ( string  $factory_method)

getButtonTypeProvider

Definition at line 119 of file ButtonTest.php.

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

119  : void
120  {
121  $f = $this->getButtonFactory();
122  $b = $f->$factory_method("label", "http://www.ilias.de");
123 
124  $this->assertEquals("http://www.ilias.de", $b->getAction());
125  }
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testButtonActivatedOnDefault()

ButtonTest::testButtonActivatedOnDefault ( string  $factory_method)

getButtonTypeProvider

Definition at line 130 of file ButtonTest.php.

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

130  : void
131  {
132  $f = $this->getButtonFactory();
133  $b = $f->$factory_method("label", "http://www.ilias.de");
134 
135  $this->assertTrue($b->isActive());
136  }
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testButtonDeactivation()

ButtonTest::testButtonDeactivation ( string  $factory_method)

getButtonTypeProvider

Definition at line 141 of file ButtonTest.php.

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

141  : void
142  {
143  $f = $this->getButtonFactory();
144  $b = $f->$factory_method("label", "http://www.ilias.de")
145  ->withUnavailableAction();
146 
147  $this->assertFalse($b->isActive());
148  $this->assertEquals("http://www.ilias.de", $b->getAction());
149 
150  $b = $b->withUnavailableAction(false);
151  $this->assertTrue($b->isActive());
152  }
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testButtonLabel()

ButtonTest::testButtonLabel ( string  $factory_method)

getButtonTypeProvider

Definition at line 94 of file ButtonTest.php.

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

94  : void
95  {
96  $f = $this->getButtonFactory();
97  $b = $f->$factory_method("label", "http://www.ilias.de");
98 
99  $this->assertEquals("label", $b->getLabel());
100  }
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testButtonLabelOrGlyphOnly()

ButtonTest::testButtonLabelOrGlyphOnly ( string  $factory_method)

getButtonTypeProvider

Definition at line 74 of file ButtonTest.php.

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

74  : void
75  {
76  $this->expectException(TypeError::class);
77  $f = $this->getButtonFactory();
78  $f->$factory_method($this, "http://www.ilias.de");
79  }
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testButtonRendersTooltip()

ButtonTest::testButtonRendersTooltip ( string  $factory_method)

getButtonTypeProvider

Definition at line 530 of file ButtonTest.php.

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

530  : void
531  {
532  $f = $this->getButtonFactory();
533  $r = $this->getDefaultRenderer();
534  $ln = "http://www.ilias.de";
535 
536  $button =
537  $f->$factory_method("label", $ln)
538  ->withHelpTopics(new Help\Topic("a"), new Help\Topic("b"));
539 
540  $css_classes = self::$canonical_css_classes[$factory_method];
541  $expected =
542  "<div class=\"c-tooltip__container\">" .
543  "<button class=\"$css_classes\" aria-describedby=\"id_2\" data-action=\"$ln\" id=\"id_1\" >" .
544  "label" .
545  "</button>" .
546  "<div id=\"id_2\" role=\"tooltip\" class=\"c-tooltip c-tooltip--hidden\">" .
547  "<p>tooltip: a</p>" .
548  "<p>tooltip: b</p>" .
549  "</div>" .
550  "</div>";
551 
552  $html = $this->normalizeHTML($r->render($button));
553  $this->assertHTMLEquals($expected, $html);
554  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
This is just a class that marks a string as a help topic.
Definition: Topic.php:26
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
getButtonFactory()
Definition: ButtonTest.php:36
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testButtonStringActionOnly()

ButtonTest::testButtonStringActionOnly ( string  $factory_method)

getButtonTypeProvider

Definition at line 84 of file ButtonTest.php.

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

84  : void
85  {
86  $this->expectException(InvalidArgumentException::class);
87  $f = $this->getButtonFactory();
88  $f->$factory_method("label", $this);
89  }
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testButtonWithAriaLabel()

ButtonTest::testButtonWithAriaLabel ( string  $factory_method)

getButtonTypeProvider

Definition at line 368 of file ButtonTest.php.

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

368  : void
369  {
370  $f = $this->getButtonFactory();
371  $b = $f->$factory_method("label", "http://www.ilias.de")->withAriaLabel("ariatext");
372  $this->assertEquals("ariatext", $b->getAriaLabel());
373  }
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testButtonWithEngageable()

ButtonTest::testButtonWithEngageable ( string  $factory_method)

getButtonTypeProvider

Definition at line 378 of file ButtonTest.php.

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

378  : void
379  {
380  $f = $this->getButtonFactory();
381  $b = $f->$factory_method("label", "http://www.ilias.de");
382  if ($b instanceof C\Button\Engageable) {
383  $this->assertEquals(false, $b->isEngageable());
384  $b2 = $f->$factory_method("label", "http://www.ilias.de")->withEngagedState(false);
385  $this->assertEquals(true, $b2->isEngageable());
386  } else {
387  $this->assertTrue(self::NOT_APPLICABLE);
388  }
389  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testButtonWithEngaged()

ButtonTest::testButtonWithEngaged ( string  $factory_method)

getButtonTypeProvider

Definition at line 394 of file ButtonTest.php.

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

394  : void
395  {
396  $f = $this->getButtonFactory();
397  $b = $f->$factory_method("label", "http://www.ilias.de");
398  if ($b instanceof C\Button\Engageable) {
399  $b = $b->withEngagedState(false);
400  $this->assertEquals(false, $b->isEngaged());
401  $b2 = $f->$factory_method("label", "http://www.ilias.de")->withEngagedState(true);
402  $this->assertEquals(true, $b2->isEngaged());
403  } else {
404  $this->assertTrue(self::NOT_APPLICABLE);
405  }
406  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testButtonWithLabel()

ButtonTest::testButtonWithLabel ( string  $factory_method)

getButtonTypeProvider

Definition at line 105 of file ButtonTest.php.

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

105  : void
106  {
107  $f = $this->getButtonFactory();
108  $b = $f->$factory_method("label", "http://www.ilias.de");
109 
110  $b2 = $b->withLabel("label2");
111 
112  $this->assertEquals("label", $b->getLabel());
113  $this->assertEquals("label2", $b2->getLabel());
114  }
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testButtonWithLoadingAnimation()

ButtonTest::testButtonWithLoadingAnimation ( )

test loading animation

Definition at line 157 of file ButtonTest.php.

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

157  : void
158  {
159  $f = $this->getButtonFactory();
160  foreach (["standard", "primary"] as $method) {
161  $b = $f->$method("label", "http://www.ilias.de");
162 
163  $this->assertFalse($b->hasLoadingAnimationOnClick());
164 
165  $b = $b->withLoadingAnimationOnClick(true);
166 
167  $this->assertTrue($b->hasLoadingAnimationOnClick());
168  }
169  }
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testFactoryAcceptsSignalAsAction()

ButtonTest::testFactoryAcceptsSignalAsAction ( string  $factory_method)

getButtonTypeProvider

Definition at line 563 of file ButtonTest.php.

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

563  : void
564  {
565  $f = $this->getButtonFactory();
566  $signal = $this->createMock(C\Signal::class);
567 
568  $button = $f->$factory_method("label", $signal);
569 
570  $this->assertEquals([$signal], $button->getAction());
571  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getButtonFactory()
Definition: ButtonTest.php:36
+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

ButtonTest::testImplementsFactoryInterface ( )

Definition at line 48 of file ButtonTest.php.

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

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

◆ testRenderBtnTagClasses()

ButtonTest::testRenderBtnTagClasses ( )

Definition at line 349 of file ButtonTest.php.

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

349  : void
350  {
351  $f = $this->getButtonFactory();
352  $r = $this->getDefaultRenderer();
353  $df = new \ILIAS\Data\Factory();
354 
355  $classes = array('cl1', 'cl2');
356  $b = $f->tag('tag', '#')
357  ->withClasses($classes);
358  $this->assertEquals($classes, $b->getClasses());
359 
360  $html = $this->normalizeHTML($r->render($b));
361  $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh cl1 cl2" data-action="#" id="id_1">tag</button>';
362  $this->assertEquals($expected, $html);
363  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
getButtonFactory()
Definition: ButtonTest.php:36
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRenderBtnTagColors()

ButtonTest::testRenderBtnTagColors ( )

Definition at line 328 of file ButtonTest.php.

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

328  : void
329  {
330  $f = $this->getButtonFactory();
331  $r = $this->getDefaultRenderer();
332  $df = new \ILIAS\Data\Factory();
333 
334  $bgcol = $df->color('#00ff00');
335 
336  $b = $f->tag('tag', '#')
337  ->withBackgroundColor($bgcol);
338  $html = $this->normalizeHTML($r->render($b));
339  $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #000000;" data-action="#" id="id_1">tag</button>';
340  $this->assertEquals($expected, $html);
341 
342  $fcol = $df->color('#ddd');
343  $b = $b->withForegroundColor($fcol);
344  $html = $this->normalizeHTML($r->render($b));
345  $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #dddddd;" data-action="#" id="id_2">tag</button>';
346  $this->assertEquals($expected, $html);
347  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
getButtonFactory()
Definition: ButtonTest.php:36
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRenderBtnTagRelevance()

ButtonTest::testRenderBtnTagRelevance ( )

Definition at line 299 of file ButtonTest.php.

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

299  : void
300  {
301  $expectations = array(
302  '<button class="btn btn-tag btn-tag-relevance-verylow" data-action="#" id="id_1">tag</button>',
303  '<button class="btn btn-tag btn-tag-relevance-low" data-action="#" id="id_2">tag</button>',
304  '<button class="btn btn-tag btn-tag-relevance-middle" data-action="#" id="id_3">tag</button>',
305  '<button class="btn btn-tag btn-tag-relevance-high" data-action="#" id="id_4">tag</button>',
306  '<button class="btn btn-tag btn-tag-relevance-veryhigh" data-action="#" id="id_5">tag</button>'
307  );
308 
309  $f = $this->getButtonFactory();
310  $r = $this->getDefaultRenderer();
311  $t = $f->tag('tag', '#');
312  $possible_relevances = array(
313  $t::REL_VERYLOW,
314  $t::REL_LOW,
315  $t::REL_MID,
316  $t::REL_HIGH,
317  $t::REL_VERYHIGH
318  );
319  foreach ($possible_relevances as $w) {
320  $html = $this->normalizeHTML(
321  $r->render($t->withRelevance($w))
322  );
323  $expected = $expectations[array_search($w, $possible_relevances)];
324  $this->assertEquals($expected, $html);
325  }
326  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
getButtonFactory()
Definition: ButtonTest.php:36
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRenderButtonDisabled()

ButtonTest::testRenderButtonDisabled ( string  $factory_method)

getButtonTypeProvider

Definition at line 193 of file ButtonTest.php.

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

193  : void
194  {
195  $ln = "http://www.ilias.de";
196  $f = $this->getButtonFactory();
197  $b = $f->$factory_method("label", $ln)
198  ->withUnavailableAction();
199  $r = $this->getDefaultRenderer();
200 
201  $html = $this->normalizeHTML($r->render($b));
202 
203  $css_classes = self::$canonical_css_classes[$factory_method];
204  $expected = "<button class=\"$css_classes\" data-action=\"$ln\" disabled=\"disabled\">" .
205  "label" .
206  "</button>";
207  $this->assertHTMLEquals($expected, $html);
208  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
getButtonFactory()
Definition: ButtonTest.php:36
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRenderButtonLabel()

ButtonTest::testRenderButtonLabel ( string  $factory_method)

getButtonTypeProvider

Definition at line 174 of file ButtonTest.php.

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

174  : void
175  {
176  $ln = "http://www.ilias.de";
177  $f = $this->getButtonFactory();
178  $b = $f->$factory_method("label", $ln);
179  $r = $this->getDefaultRenderer();
180 
181  $html = $this->normalizeHTML($r->render($b));
182 
183  $css_classes = self::$canonical_css_classes[$factory_method];
184  $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
185  "label" .
186  "</button>";
187  $this->assertHTMLEquals($expected, $html);
188  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
getButtonFactory()
Definition: ButtonTest.php:36
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRenderButtonWithAriaLabel()

ButtonTest::testRenderButtonWithAriaLabel ( string  $factory_method)

getButtonTypeProvider

Definition at line 411 of file ButtonTest.php.

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

411  : void
412  {
413  $ln = "http://www.ilias.de";
414  $f = $this->getButtonFactory();
415  $r = $this->getDefaultRenderer();
416  $b = $f->$factory_method("label", $ln)->withAriaLabel("aria label text");
417  $aria_label = $b->getAriaLabel();
418 
419  $html = $this->normalizeHTML($r->render($b));
420  $css_classes = self::$canonical_css_classes[$factory_method];
421  $expected = "<button class=\"$css_classes\" aria-label=\"$aria_label\" data-action=\"$ln\" id=\"id_1\">" .
422  "label" .
423  "</button>";
424  $this->assertHTMLEquals($expected, $html);
425  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
getButtonFactory()
Definition: ButtonTest.php:36
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRenderButtonWithAriaPressed()

ButtonTest::testRenderButtonWithAriaPressed ( string  $factory_method)

getButtonTypeProvider

Definition at line 430 of file ButtonTest.php.

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

430  : void
431  {
432  $ln = "http://www.ilias.de";
433  $f = $this->getButtonFactory();
434  $r = $this->getDefaultRenderer();
435  $b = $f->$factory_method("label", $ln);
436  if ($b instanceof C\Button\Engageable) {
437  $b = $b->withEngagedState(true);
438 
439  $html = $this->normalizeHTML($r->render($b));
440  $css_classes = self::$canonical_css_classes[$factory_method];
441  $css_classes .= ' engaged';
442  $expected = "<button class=\"$css_classes\" aria-pressed=\"true\" data-action=\"$ln\" id=\"id_1\">" .
443  "label" .
444  "</button>";
445  $this->assertHTMLEquals($expected, $html);
446  } else {
447  $this->assertTrue(self::NOT_APPLICABLE);
448  }
449  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
getButtonFactory()
Definition: ButtonTest.php:36
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRenderButtonWithOnClickAnimation()

ButtonTest::testRenderButtonWithOnClickAnimation ( )

test rendering with on click animation

Definition at line 508 of file ButtonTest.php.

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

508  : void
509  {
510  foreach (["primary", "standard"] as $method) {
511  $ln = "http://www.ilias.de";
512  $f = $this->getButtonFactory();
513  $r = $this->getDefaultRenderer();
514  $b = $f->$method("label", $ln)
515  ->withLoadingAnimationOnClick(true);
516 
517  $html = $this->normalizeHTML($r->render($b));
518 
519  $css_classes = self::$canonical_css_classes[$method];
520  $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
521  "label" .
522  "</button>";
523  $this->assertHTMLEquals($expected, $html);
524  }
525  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
getButtonFactory()
Definition: ButtonTest.php:36
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRenderButtonWithOnLoadCode()

ButtonTest::testRenderButtonWithOnLoadCode ( string  $factory_method)

getButtonTypeProvider

Definition at line 241 of file ButtonTest.php.

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

241  : void
242  {
243  $ln = "http://www.ilias.de";
244  $f = $this->getButtonFactory();
245  $r = $this->getDefaultRenderer();
246  $ids = array();
247  $b = $f->$factory_method("label", $ln)
248  ->withOnLoadCode(function ($id) use (&$ids): string {
249  $ids[] = $id;
250  return "";
251  });
252 
253  $html = $this->normalizeHTML($r->render($b));
254 
255  $this->assertCount(1, $ids);
256 
257  $id = $ids[0];
258  $css_classes = self::$canonical_css_classes[$factory_method];
259  $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"$id\">" .
260  "label" .
261  "</button>";
262  $this->assertHTMLEquals($expected, $html);
263  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
getButtonFactory()
Definition: ButtonTest.php:36
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRenderButtonWithSignal()

ButtonTest::testRenderButtonWithSignal ( string  $factory_method)

getButtonTypeProvider

Definition at line 484 of file ButtonTest.php.

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

484  : void
485  {
486  $ln = "http://www.ilias.de";
487  $f = $this->getButtonFactory();
488  $signal = $this->createMock(Signal::class);
489  $signal->method("__toString")
490  ->willReturn("MOCK_SIGNAL");
491 
492  $b = $f->$factory_method("label", $ln)
493  ->withOnClick($signal);
494  $r = $this->getDefaultRenderer();
495 
496  $html = $this->normalizeHTML($r->render($b));
497 
498  $css_classes = self::$canonical_css_classes[$factory_method];
499  $expected = "<button class=\"$css_classes\" id=\"id_1\">" .
500  "label" .
501  "</button>";
502  $this->assertHTMLEquals($expected, $html);
503  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
getButtonFactory()
Definition: ButtonTest.php:36
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRenderCloseButton()

ButtonTest::testRenderCloseButton ( )

Definition at line 210 of file ButtonTest.php.

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

210  : void
211  {
212  $f = $this->getButtonFactory();
213  $r = $this->getDefaultRenderer();
214  $b = $f->close();
215 
216  $html = $this->normalizeHTML($r->render($b));
217 
218  $expected = "<button type=\"button\" class=\"close\" aria-label=\"close\">" .
219  " <span aria-hidden=\"true\">&times;</span>" .
220  "</button>";
221  $this->assertEquals($expected, $html);
222  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
getButtonFactory()
Definition: ButtonTest.php:36
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRenderCloseButtonWithOnLoadCode()

ButtonTest::testRenderCloseButtonWithOnLoadCode ( )

Definition at line 265 of file ButtonTest.php.

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

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

◆ testRenderMinimizeButton()

ButtonTest::testRenderMinimizeButton ( )

Definition at line 224 of file ButtonTest.php.

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

224  : void
225  {
226  $f = $this->getButtonFactory();
227  $r = $this->getDefaultRenderer();
228  $b = $f->minimize();
229 
230  $html = $this->normalizeHTML($r->render($b));
231 
232  $expected = "<button type=\"button\" class=\"minimize\" aria-label=\"minimize\">" .
233  " <span aria-hidden=\"true\">−</span>" .
234  "</button>";
235  $this->assertEquals($expected, $html);
236  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
getButtonFactory()
Definition: ButtonTest.php:36
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testWithOnClickRemovesAction()

ButtonTest::testWithOnClickRemovesAction ( string  $factory_method)

getButtonTypeProvider

Definition at line 454 of file ButtonTest.php.

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

454  : void
455  {
456  $f = $this->getButtonFactory();
457  $signal = $this->createMock(C\Signal::class);
458  $button = $f->$factory_method("label", "http://www.example.com");
459  $this->assertEquals("http://www.example.com", $button->getAction());
460 
461  $button = $button->withOnClick($signal);
462 
463  $this->assertEquals([$signal], $button->getAction());
464  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getButtonFactory()
Definition: ButtonTest.php:36
+ 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"

Definition at line 41 of file ButtonTest.php.

◆ NOT_APPLICABLE

const ButtonTest::NOT_APPLICABLE = true

Definition at line 34 of file ButtonTest.php.

◆ primary

array ButtonTest::primary
static
Initial value:
=> "btn btn-default btn-primary",
"shy" => "btn btn-link",
"tag" => "btn btn-tag btn-tag-relevance-veryhigh"
]

Definition at line 43 of file ButtonTest.php.


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