ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 button_type_provider More...
 
 test_button_string_action_only ($factory_method)
 button_type_provider More...
 
 test_button_label ($factory_method)
 button_type_provider More...
 
 test_button_with_label ($factory_method)
 button_type_provider More...
 
 test_button_action ($factory_method)
 button_type_provider More...
 
 test_button_activated_on_default ($factory_method)
 button_type_provider More...
 
 test_button_deactivation ($factory_method)
 button_type_provider More...
 
 test_button_with_loading_animation ()
 test loading animation More...
 
 test_render_button_label ($factory_method)
 button_type_provider More...
 
 test_render_button_disabled ($factory_method)
 button_type_provider More...
 
 test_render_close_button ()
 
 test_render_button_with_on_load_code ($factory_method)
 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)
 button_type_provider More...
 
 test_button_with_engageable ($factory_method)
 button_type_provider More...
 
 test_button_with_engaged ($factory_method)
 button_type_provider More...
 
 test_render_button_with_aria_label ($factory_method)
 button_type_provider More...
 
 test_render_button_with_aria_pressed ($factory_method)
 button_type_provider More...
 
 test_withOnClick_removes_action ($factory_method)
 button_type_provider More...
 
 test_appendOnClick_appends_to_action ($factory_method)
 button_type_provider More...
 
 test_render_button_with_signal ($factory_method)
 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)
 button_type_provider More...
 
 button_type_provider ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 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 515 of file ButtonTest.php.

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

◆ getButtonFactory()

◆ test_____render_close_button_with_on_load_code()

ButtonTest::test_____render_close_button_with_on_load_code ( )

Definition at line 230 of file ButtonTest.php.

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

231  {
232  $f = $this->getButtonFactory();
233  $r = $this->getDefaultRenderer();
234  $ids = array();
235  $b = $f->close()
236  ->withOnLoadCode(function ($id) use (&$ids) {
237  $ids[] = $id;
238  return "";
239  });
240 
241  $html = $this->normalizeHTML($r->render($b));
242 
243  $this->assertCount(1, $ids);
244 
245  $id = $ids[0];
246  $expected = "<button type=\"button\" class=\"close\" data-dismiss=\"modal\" id=\"$id\">" .
247  " <span aria-hidden=\"true\">&times;</span>" .
248  " <span class=\"sr-only\">Close</span>" .
249  "</button>";
250  $this->assertEquals($expected, $html);
251  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_appendOnClick_appends_to_action()

ButtonTest::test_appendOnClick_appends_to_action (   $factory_method)

button_type_provider

Definition at line 440 of file ButtonTest.php.

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

441  {
442  $f = $this->getButtonFactory();
443  $signal1 = $this->createMock(C\Signal::class);
444  $signal2 = $this->createMock(C\Signal::class);
445  $button = $f->$factory_method("label", "http://www.example.com");
446 
447  $button = $button->withOnClick($signal1)->appendOnClick($signal2);
448 
449  $this->assertEquals([$signal1, $signal2], $button->getAction());
450  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_btn_tag_relevance()

ButtonTest::test_btn_tag_relevance ( )

Definition at line 253 of file ButtonTest.php.

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

254  {
255  $f = $this->getButtonFactory();
256  $b = $f->tag('tag', '#');
257  try {
258  $b->withRelevance(0);
259  $this->assertFalse("This should not happen");
260  } catch (\InvalidArgumentException $e) {
261  $this->assertTrue(true);
262  }
263  try {
264  $b->withRelevance('notsoimportant');
265  $this->assertFalse("This should not happen");
266  } catch (\InvalidArgumentException $e) {
267  $this->assertTrue(true);
268  }
269  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_button_action()

ButtonTest::test_button_action (   $factory_method)

button_type_provider

Definition at line 100 of file ButtonTest.php.

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

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  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_button_activated_on_default()

ButtonTest::test_button_activated_on_default (   $factory_method)

button_type_provider

Definition at line 111 of file ButtonTest.php.

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

112  {
113  $f = $this->getButtonFactory();
114  $b = $f->$factory_method("label", "http://www.ilias.de");
115 
116  $this->assertTrue($b->isActive());
117  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_button_deactivation()

ButtonTest::test_button_deactivation (   $factory_method)

button_type_provider

Definition at line 122 of file ButtonTest.php.

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

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  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_button_label()

ButtonTest::test_button_label (   $factory_method)

button_type_provider

Definition at line 75 of file ButtonTest.php.

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

76  {
77  $f = $this->getButtonFactory();
78  $b = $f->$factory_method("label", "http://www.ilias.de");
79 
80  $this->assertEquals("label", $b->getLabel());
81  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_button_label_or_glyph_only()

ButtonTest::test_button_label_or_glyph_only (   $factory_method)

button_type_provider

Definition at line 55 of file ButtonTest.php.

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

56  {
57  $this->expectException(\InvalidArgumentException::class);
58  $f = $this->getButtonFactory();
59  $f->$factory_method($this, "http://www.ilias.de");
60  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_button_string_action_only()

ButtonTest::test_button_string_action_only (   $factory_method)

button_type_provider

Definition at line 65 of file ButtonTest.php.

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

66  {
67  $this->expectException(\InvalidArgumentException::class);
68  $f = $this->getButtonFactory();
69  $f->$factory_method("label", $this);
70  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_button_with_aria_label()

ButtonTest::test_button_with_aria_label (   $factory_method)

button_type_provider

Definition at line 339 of file ButtonTest.php.

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

340  {
341  $f = $this->getButtonFactory();
342  $b = $f->$factory_method("label", "http://www.ilias.de")->withAriaLabel("ariatext");
343  $this->assertEquals("ariatext", $b->getAriaLabel());
344  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_button_with_engageable()

ButtonTest::test_button_with_engageable (   $factory_method)

button_type_provider

Definition at line 349 of file ButtonTest.php.

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

350  {
351  $f = $this->getButtonFactory();
352  $b = $f->$factory_method("label", "http://www.ilias.de");
353  if ($b instanceof C\Button\Engageable) {
354  $this->assertEquals(false, $b->isEngageable());
355  $b2 = $f->$factory_method("label", "http://www.ilias.de")->withEngagedState(false);
356  $this->assertEquals(true, $b2->isEngageable());
357  } else {
358  $this->assertTrue(self::NOT_APPLICABLE);
359  }
360  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_button_with_engaged()

ButtonTest::test_button_with_engaged (   $factory_method)

button_type_provider

Definition at line 365 of file ButtonTest.php.

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

366  {
367  $f = $this->getButtonFactory();
368  $b = $f->$factory_method("label", "http://www.ilias.de");
369  if ($b instanceof C\Button\Engageable) {
370  $b = $b->withEngagedState(false);
371  $this->assertEquals(false, $b->isEngaged());
372  $b2 = $f->$factory_method("label", "http://www.ilias.de")->withEngagedState(true);
373  $this->assertEquals(true, $b2->isEngaged());
374  } else {
375  $this->assertTrue(self::NOT_APPLICABLE);
376  }
377  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_button_with_label()

ButtonTest::test_button_with_label (   $factory_method)

button_type_provider

Definition at line 86 of file ButtonTest.php.

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

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  }
getButtonFactory()
Definition: ButtonTest.php:18
+ 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.

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

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  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_factory_accepts_signal_as_action()

ButtonTest::test_factory_accepts_signal_as_action (   $factory_method)

button_type_provider

Definition at line 505 of file ButtonTest.php.

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

506  {
507  $f = $this->getButtonFactory();
508  $signal = $this->createMock(C\Signal::class);
509 
510  $button = $f->$factory_method("label", $signal);
511 
512  $this->assertEquals([$signal], $button->getAction());
513  }
getButtonFactory()
Definition: ButtonTest.php:18
+ 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.

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

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  }
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_render_btn_tag_classes()

ButtonTest::test_render_btn_tag_classes ( )

Definition at line 321 of file ButtonTest.php.

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

322  {
323  $f = $this->getButtonFactory();
324  $r = $this->getDefaultRenderer();
325  $df = new \ILIAS\Data\Factory;
326 
327  $classes = array('cl1', 'cl2');
328  $b = $f->tag('tag', '#')
329  ->withClasses($classes);
330  $this->assertEquals($classes, $b->getClasses());
331 
332  $html = $this->normalizeHTML($r->render($b));
333  $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh cl1 cl2" data-action="#" id="id_1">tag</button>';
334  $this->assertEquals($expected, $html);
335  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_render_btn_tag_colors()

ButtonTest::test_render_btn_tag_colors ( )

Definition at line 300 of file ButtonTest.php.

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

301  {
302  $f = $this->getButtonFactory();
303  $r = $this->getDefaultRenderer();
304  $df = new \ILIAS\Data\Factory;
305 
306  $bgcol = $df->color('#00ff00');
307 
308  $b = $f->tag('tag', '#')
309  ->withBackgroundColor($bgcol);
310  $html = $this->normalizeHTML($r->render($b));
311  $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #000000;" data-action="#" id="id_1">tag</button>';
312  $this->assertEquals($expected, $html);
313 
314  $fcol = $df->color('#ddd');
315  $b = $b->withForegroundColor($fcol);
316  $html = $this->normalizeHTML($r->render($b));
317  $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #dddddd;" data-action="#" id="id_2">tag</button>';
318  $this->assertEquals($expected, $html);
319  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_render_btn_tag_relevance()

ButtonTest::test_render_btn_tag_relevance ( )

Definition at line 271 of file ButtonTest.php.

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

272  {
273  $expectations = array(
274  '<button class="btn btn-tag btn-tag-relevance-verylow" data-action="#" id="id_1">tag</button>',
275  '<button class="btn btn-tag btn-tag-relevance-low" data-action="#" id="id_2">tag</button>',
276  '<button class="btn btn-tag btn-tag-relevance-middle" data-action="#" id="id_3">tag</button>',
277  '<button class="btn btn-tag btn-tag-relevance-high" data-action="#" id="id_4">tag</button>',
278  '<button class="btn btn-tag btn-tag-relevance-veryhigh" data-action="#" id="id_5">tag</button>'
279  );
280 
281  $f = $this->getButtonFactory();
282  $r = $this->getDefaultRenderer();
283  $t = $f->tag('tag', '#');
284  $possible_relevances = array(
285  $t::REL_VERYLOW,
286  $t::REL_LOW,
287  $t::REL_MID,
288  $t::REL_HIGH,
289  $t::REL_VERYHIGH
290  );
291  foreach ($possible_relevances as $w) {
292  $html = $this->normalizeHTML(
293  $r->render($t->withRelevance($w))
294  );
295  $expected = $expectations[array_search($w, $possible_relevances)];
296  $this->assertEquals($expected, $html);
297  }
298  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_render_button_disabled()

ButtonTest::test_render_button_disabled (   $factory_method)

button_type_provider

Definition at line 171 of file ButtonTest.php.

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

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  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getButtonFactory()
Definition: ButtonTest.php:18
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_render_button_label()

ButtonTest::test_render_button_label (   $factory_method)

button_type_provider

Definition at line 152 of file ButtonTest.php.

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

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  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getButtonFactory()
Definition: ButtonTest.php:18
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_render_button_with_aria_label()

ButtonTest::test_render_button_with_aria_label (   $factory_method)

button_type_provider

Definition at line 382 of file ButtonTest.php.

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

383  {
384  $ln = "http://www.ilias.de";
385  $f = $this->getButtonFactory();
386  $r = $this->getDefaultRenderer();
387  $b = $f->$factory_method("label", $ln)->withAriaLabel("aria label text");
388  $aria_label = $b->getAriaLabel();
389 
390  $html = $this->normalizeHTML($r->render($b));
391  $css_classes = self::$canonical_css_classes[$factory_method];
392  $expected = "<button class=\"$css_classes\" aria-label=\"$aria_label\" data-action=\"$ln\" id=\"id_1\">" .
393  "label" .
394  "</button>";
395  $this->assertHTMLEquals($expected, $html);
396  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getButtonFactory()
Definition: ButtonTest.php:18
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_render_button_with_aria_pressed()

ButtonTest::test_render_button_with_aria_pressed (   $factory_method)

button_type_provider

Definition at line 401 of file ButtonTest.php.

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

402  {
403  $ln = "http://www.ilias.de";
404  $f = $this->getButtonFactory();
405  $r = $this->getDefaultRenderer();
406  $b = $f->$factory_method("label", $ln);
407  if ($b instanceof C\Button\Engageable) {
408  $b = $b->withEngagedState(true);
409 
410  $html = $this->normalizeHTML($r->render($b));
411  $css_classes = self::$canonical_css_classes[$factory_method];
412  $css_classes .= ' engaged';
413  $expected = "<button class=\"$css_classes\" aria-pressed=\"true\" data-action=\"$ln\" id=\"id_1\">" .
414  "label" .
415  "</button>";
416  $this->assertHTMLEquals($expected, $html);
417  } else {
418  $this->assertTrue(self::NOT_APPLICABLE);
419  }
420  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getButtonFactory()
Definition: ButtonTest.php:18
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ 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 479 of file ButtonTest.php.

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

480  {
481  foreach (["primary", "standard"] as $method) {
482  $ln = "http://www.ilias.de";
483  $f = $this->getButtonFactory();
484  $r = $this->getDefaultRenderer();
485  $b = $f->$method("label", $ln)
486  ->withLoadingAnimationOnClick(true);
487 
488  $html = $this->normalizeHTML($r->render($b));
489 
490  $css_classes = self::$canonical_css_classes[$method];
491  $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
492  "label" .
493  "</button>";
494  $this->assertHTMLEquals($expected, $html);
495  }
496  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getButtonFactory()
Definition: ButtonTest.php:18
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ 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)

button_type_provider

Definition at line 206 of file ButtonTest.php.

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

207  {
208  $ln = "http://www.ilias.de";
209  $f = $this->getButtonFactory();
210  $r = $this->getDefaultRenderer();
211  $ids = array();
212  $b = $f->$factory_method("label", $ln)
213  ->withOnLoadCode(function ($id) use (&$ids) {
214  $ids[] = $id;
215  return "";
216  });
217 
218  $html = $this->normalizeHTML($r->render($b));
219 
220  $this->assertCount(1, $ids);
221 
222  $id = $ids[0];
223  $css_classes = self::$canonical_css_classes[$factory_method];
224  $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"$id\">" .
225  "label" .
226  "</button>";
227  $this->assertHTMLEquals($expected, $html);
228  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getButtonFactory()
Definition: ButtonTest.php:18
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_render_button_with_signal()

ButtonTest::test_render_button_with_signal (   $factory_method)

button_type_provider

Definition at line 455 of file ButtonTest.php.

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

456  {
457  $ln = "http://www.ilias.de";
458  $f = $this->getButtonFactory();
459  $signal = $this->createMock(Signal::class);
460  $signal->method("__toString")
461  ->willReturn("MOCK_SIGNAL");
462 
463  $b = $f->$factory_method("label", $ln)
464  ->withOnClick($signal);
465  $r = $this->getDefaultRenderer();
466 
467  $html = $this->normalizeHTML($r->render($b));
468 
469  $css_classes = self::$canonical_css_classes[$factory_method];
470  $expected = "<button class=\"$css_classes\" id=\"id_1\">" .
471  "label" .
472  "</button>";
473  $this->assertHTMLEquals($expected, $html);
474  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getButtonFactory()
Definition: ButtonTest.php:18
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ 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.

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

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\" data-dismiss=\"modal\">" .
197  " <span aria-hidden=\"true\">&times;</span>" .
198  " <span class=\"sr-only\">Close</span>" .
199  "</button>";
200  $this->assertEquals($expected, $html);
201  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
getButtonFactory()
Definition: ButtonTest.php:18
+ Here is the call graph for this function:

◆ test_withOnClick_removes_action()

ButtonTest::test_withOnClick_removes_action (   $factory_method)

button_type_provider

Definition at line 425 of file ButtonTest.php.

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

426  {
427  $f = $this->getButtonFactory();
428  $signal = $this->createMock(C\Signal::class);
429  $button = $f->$factory_method("label", "http://www.example.com");
430  $this->assertEquals("http://www.example.com", $button->getAction());
431 
432  $button = $button->withOnClick($signal);
433 
434  $this->assertEquals([$signal], $button->getAction());
435  }
getButtonFactory()
Definition: ButtonTest.php:18
+ 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: