ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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_aria_checked ($factory_method)
 button_type_provider More...
 
 test_render_button_with_aria_label ($factory_method)
 button_type_provider More...
 
 test_render_button_with_aria_checked ($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 ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Static Public Attributes

static $canonical_css_classes
 
static $canonical_css_inactivation_classes
 

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

509  {
510  return array( array("standard")
511  , array("primary")
512  , array("shy")
513  , array("tag")
514  );
515  }

◆ getButtonFactory()

◆ test_____render_close_button_with_on_load_code()

ButtonTest::test_____render_close_button_with_on_load_code ( )

Definition at line 242 of file ButtonTest.php.

References $f, $html, $id, $r, getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

243  {
244  $f = $this->getButtonFactory();
245  $r = $this->getDefaultRenderer();
246  $ids = array();
247  $b = $f->close()
248  ->withOnLoadCode(function ($id) use (&$ids) {
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  $expected = "<button type=\"button\" class=\"close\" data-dismiss=\"modal\" id=\"$id\">" .
259  " <span aria-hidden=\"true\">&times;</span>" .
260  " <span class=\"sr-only\">Close</span>" .
261  "</button>";
262  $this->assertEquals($expected, $html);
263  }
if(!array_key_exists('StateId', $_REQUEST)) $id
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
getButtonFactory()
Definition: ButtonTest.php:16
$r
Definition: example_031.php:79
$html
Definition: example_001.php:87
+ 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 433 of file ButtonTest.php.

References $f, and getButtonFactory().

434  {
435  $f = $this->getButtonFactory();
436  $signal1 = $this->createMock(C\Signal::class);
437  $signal2 = $this->createMock(C\Signal::class);
438  $button = $f->$factory_method("label", "http://www.example.com");
439 
440  $button = $button->withOnClick($signal1)->appendOnClick($signal2);
441 
442  $this->assertEquals([$signal1, $signal2], $button->getAction());
443  }
getButtonFactory()
Definition: ButtonTest.php:16
+ Here is the call graph for this function:

◆ test_btn_tag_relevance()

ButtonTest::test_btn_tag_relevance ( )

Definition at line 265 of file ButtonTest.php.

References $f, and getButtonFactory().

266  {
267  $f = $this->getButtonFactory();
268  $b = $f->tag('tag', '#');
269  try {
270  $b->withRelevance(0);
271  $this->assertFalse("This should not happen");
272  } catch (\InvalidArgumentException $e) {
273  $this->assertTrue(true);
274  }
275  try {
276  $b->withRelevance('notsoimportant');
277  $this->assertFalse("This should not happen");
278  } catch (\InvalidArgumentException $e) {
279  $this->assertTrue(true);
280  }
281  }
getButtonFactory()
Definition: ButtonTest.php:16
+ Here is the call graph for this function:

◆ test_button_action()

ButtonTest::test_button_action (   $factory_method)

button_type_provider

Definition at line 111 of file ButtonTest.php.

References $f, and getButtonFactory().

112  {
113  $f = $this->getButtonFactory();
114  $b = $f->$factory_method("label", "http://www.ilias.de");
115 
116  $this->assertEquals("http://www.ilias.de", $b->getAction());
117  }
getButtonFactory()
Definition: ButtonTest.php:16
+ 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 122 of file ButtonTest.php.

References $f, and getButtonFactory().

123  {
124  $f = $this->getButtonFactory();
125  $b = $f->$factory_method("label", "http://www.ilias.de");
126 
127  $this->assertTrue($b->isActive());
128  }
getButtonFactory()
Definition: ButtonTest.php:16
+ Here is the call graph for this function:

◆ test_button_deactivation()

ButtonTest::test_button_deactivation (   $factory_method)

button_type_provider

Definition at line 133 of file ButtonTest.php.

References $f, and getButtonFactory().

134  {
135  $f = $this->getButtonFactory();
136  $b = $f->$factory_method("label", "http://www.ilias.de")
137  ->withUnavailableAction();
138 
139  $this->assertFalse($b->isActive());
140  $this->assertEquals("http://www.ilias.de", $b->getAction());
141  }
getButtonFactory()
Definition: ButtonTest.php:16
+ Here is the call graph for this function:

◆ test_button_label()

ButtonTest::test_button_label (   $factory_method)

button_type_provider

Definition at line 86 of file ButtonTest.php.

References $f, and getButtonFactory().

87  {
88  $f = $this->getButtonFactory();
89  $b = $f->$factory_method("label", "http://www.ilias.de");
90 
91  $this->assertEquals("label", $b->getLabel());
92  }
getButtonFactory()
Definition: ButtonTest.php:16
+ 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 60 of file ButtonTest.php.

References $f, and getButtonFactory().

61  {
62  $f = $this->getButtonFactory();
63  try {
64  $f->$factory_method($this, "http://www.ilias.de");
65  $this->assertFalse("This should not happen");
66  } catch (\InvalidArgumentException $e) {
67  }
68  }
getButtonFactory()
Definition: ButtonTest.php:16
+ 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 73 of file ButtonTest.php.

References $f, and getButtonFactory().

74  {
75  $f = $this->getButtonFactory();
76  try {
77  $f->$factory_method("label", $this);
78  $this->assertFalse("This should not happen");
79  } catch (\InvalidArgumentException $e) {
80  }
81  }
getButtonFactory()
Definition: ButtonTest.php:16
+ Here is the call graph for this function:

◆ test_button_with_aria_checked()

ButtonTest::test_button_with_aria_checked (   $factory_method)

button_type_provider

Definition at line 361 of file ButtonTest.php.

References $f, and getButtonFactory().

362  {
363  $f = $this->getButtonFactory();
364  $b = $f->$factory_method("label", "http://www.ilias.de");
365  $this->assertEquals(false, $b->isAriaChecked());
366  $b2 = $f->$factory_method("label", "http://www.ilias.de")->withAriaChecked();
367  $this->assertEquals(true, $b2->isAriaChecked());
368  }
getButtonFactory()
Definition: ButtonTest.php:16
+ 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 351 of file ButtonTest.php.

References $f, and getButtonFactory().

352  {
353  $f = $this->getButtonFactory();
354  $b = $f->$factory_method("label", "http://www.ilias.de")->withAriaLabel("ariatext");
355  $this->assertEquals("ariatext", $b->getAriaLabel());
356  }
getButtonFactory()
Definition: ButtonTest.php:16
+ 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 97 of file ButtonTest.php.

References $f, and getButtonFactory().

98  {
99  $f = $this->getButtonFactory();
100  $b = $f->$factory_method("label", "http://www.ilias.de");
101 
102  $b2 = $b->withLabel("label2");
103 
104  $this->assertEquals("label", $b->getLabel());
105  $this->assertEquals("label2", $b2->getLabel());
106  }
getButtonFactory()
Definition: ButtonTest.php:16
+ 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 146 of file ButtonTest.php.

References $f, and getButtonFactory().

147  {
148  $f = $this->getButtonFactory();
149  foreach (["standard", "primary"] as $method) {
150  $b = $f->$method("label", "http://www.ilias.de");
151 
152  $this->assertFalse($b->hasLoadingAnimationOnClick());
153 
154  $b = $b->withLoadingAnimationOnClick(true);
155 
156  $this->assertTrue($b->hasLoadingAnimationOnClick());
157  }
158  }
getButtonFactory()
Definition: ButtonTest.php:16
+ 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 498 of file ButtonTest.php.

References $f, and getButtonFactory().

499  {
500  $f = $this->getButtonFactory();
501  $signal = $this->createMock(C\Signal::class);
502 
503  $button = $f->$factory_method("label", $signal);
504 
505  $this->assertEquals([$signal], $button->getAction());
506  }
getButtonFactory()
Definition: ButtonTest.php:16
+ Here is the call graph for this function:

◆ test_implements_factory_interface()

ButtonTest::test_implements_factory_interface ( )

Definition at line 34 of file ButtonTest.php.

References $f, and getButtonFactory().

35  {
36  $f = $this->getButtonFactory();
37 
38  $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Factory", $f);
39  $this->assertInstanceOf(
40  "ILIAS\\UI\\Component\\Button\\Standard",
41  $f->standard("label", "http://www.ilias.de")
42  );
43  $this->assertInstanceOf(
44  "ILIAS\\UI\\Component\\Button\\Primary",
45  $f->primary("label", "http://www.ilias.de")
46  );
47  $this->assertInstanceOf(
48  "ILIAS\\UI\\Component\\Button\\Close",
49  $f->close()
50  );
51  $this->assertInstanceOf(
52  "ILIAS\\UI\\Component\\Button\\Shy",
53  $f->shy("label", "http://www.ilias.de")
54  );
55  }
getButtonFactory()
Definition: ButtonTest.php:16
+ Here is the call graph for this function:

◆ test_render_btn_tag_classes()

ButtonTest::test_render_btn_tag_classes ( )

Definition at line 333 of file ButtonTest.php.

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

334  {
335  $f = $this->getButtonFactory();
336  $r = $this->getDefaultRenderer();
337  $df = new \ILIAS\Data\Factory;
338 
339  $classes = array('cl1', 'cl2');
340  $b = $f->tag('tag', '#')
341  ->withClasses($classes);
342  $this->assertEquals($classes, $b->getClasses());
343 
344  $html = $this->normalizeHTML($r->render($b));
345  $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh cl1 cl2" data-action="#" id="id_1">tag</button>';
346  $this->assertEquals($expected, $html);
347  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
getButtonFactory()
Definition: ButtonTest.php:16
$r
Definition: example_031.php:79
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_btn_tag_colors()

ButtonTest::test_render_btn_tag_colors ( )

Definition at line 312 of file ButtonTest.php.

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

313  {
314  $f = $this->getButtonFactory();
315  $r = $this->getDefaultRenderer();
316  $df = new \ILIAS\Data\Factory;
317 
318  $bgcol = $df->color('#00ff00');
319 
320  $b = $f->tag('tag', '#')
321  ->withBackgroundColor($bgcol);
322  $html = $this->normalizeHTML($r->render($b));
323  $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #000000;" data-action="#" id="id_1">tag</button>';
324  $this->assertEquals($expected, $html);
325 
326  $fcol = $df->color('#ddd');
327  $b = $b->withForegroundColor($fcol);
328  $html = $this->normalizeHTML($r->render($b));
329  $expected = '<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #dddddd;" data-action="#" id="id_2">tag</button>';
330  $this->assertEquals($expected, $html);
331  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
getButtonFactory()
Definition: ButtonTest.php:16
$r
Definition: example_031.php:79
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_btn_tag_relevance()

ButtonTest::test_render_btn_tag_relevance ( )

Definition at line 283 of file ButtonTest.php.

References $f, $html, $r, $t, $w, getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

284  {
285  $expectations = array(
286  '<button class="btn btn-tag btn-tag-relevance-verylow" data-action="#" id="id_1">tag</button>',
287  '<button class="btn btn-tag btn-tag-relevance-low" data-action="#" id="id_2">tag</button>',
288  '<button class="btn btn-tag btn-tag-relevance-middle" data-action="#" id="id_3">tag</button>',
289  '<button class="btn btn-tag btn-tag-relevance-high" data-action="#" id="id_4">tag</button>',
290  '<button class="btn btn-tag btn-tag-relevance-veryhigh" data-action="#" id="id_5">tag</button>'
291  );
292 
293  $f = $this->getButtonFactory();
294  $r = $this->getDefaultRenderer();
295  $t = $f->tag('tag', '#');
296  $possible_relevances = array(
297  $t::REL_VERYLOW,
298  $t::REL_LOW,
299  $t::REL_MID,
300  $t::REL_HIGH,
301  $t::REL_VERYHIGH
302  );
303  foreach ($possible_relevances as $w) {
304  $html = $this->normalizeHTML(
305  $r->render($t->withRelevance($w))
306  );
307  $expected = $expectations[array_search($w, $possible_relevances)];
308  $this->assertEquals($expected, $html);
309  }
310  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$w
getButtonFactory()
Definition: ButtonTest.php:16
$r
Definition: example_031.php:79
$html
Definition: example_001.php:87
+ 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 182 of file ButtonTest.php.

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

183  {
184  $ln = "http://www.ilias.de";
185  $f = $this->getButtonFactory();
186  $b = $f->$factory_method("label", $ln)
187  ->withUnavailableAction();
188  $r = $this->getDefaultRenderer();
189 
190  $html = $this->normalizeHTML($r->render($b));
191 
192  $css_classes = self::$canonical_css_classes[$factory_method];
193  $css_class_inactive = self::$canonical_css_inactivation_classes[$factory_method];
194  $expected = "<button class=\"$css_classes $css_class_inactive\" data-action=\"$ln\">" .
195  "label" .
196  "</button>";
197  $this->assertHTMLEquals($expected, $html);
198  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
getButtonFactory()
Definition: ButtonTest.php:16
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$html
Definition: example_001.php:87
+ 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 163 of file ButtonTest.php.

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

164  {
165  $ln = "http://www.ilias.de";
166  $f = $this->getButtonFactory();
167  $b = $f->$factory_method("label", $ln);
168  $r = $this->getDefaultRenderer();
169 
170  $html = $this->normalizeHTML($r->render($b));
171 
172  $css_classes = self::$canonical_css_classes[$factory_method];
173  $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
174  "label" .
175  "</button>";
176  $this->assertHTMLEquals($expected, $html);
177  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
getButtonFactory()
Definition: ButtonTest.php:16
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_button_with_aria_checked()

ButtonTest::test_render_button_with_aria_checked (   $factory_method)

button_type_provider

Definition at line 396 of file ButtonTest.php.

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

397  {
398  //only standard buttons have aria labels in the template. Should the others accept aria stuff?
399  //if yes, remove this conditional
400  if ($factory_method == "standard") {
401  $ln = "http://www.ilias.de";
402  $f = $this->getButtonFactory();
403  $r = $this->getDefaultRenderer();
404  $b = $f->$factory_method("label", $ln)->withAriaChecked();
405 
406  $html = $this->normalizeHTML($r->render($b));
407  $css_classes = self::$canonical_css_classes[$factory_method];
408  $expected = "<button class=\"$css_classes\" aria-checked=\"true\" data-action=\"$ln\" id=\"id_1\">" .
409  "label" .
410  "</button>";
411  $this->assertHTMLEquals($expected, $html);
412  }
413  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
getButtonFactory()
Definition: ButtonTest.php:16
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$html
Definition: example_001.php:87
+ 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 373 of file ButtonTest.php.

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

374  {
375  //only standard buttons have aria labels in the template. Should the others accept aria stuff?
376  //if yes, remove this conditional
377  if ($factory_method == "standard") {
378  $ln = "http://www.ilias.de";
379  $f = $this->getButtonFactory();
380  $r = $this->getDefaultRenderer();
381  $b = $f->$factory_method("label", $ln)->withAriaLabel("aria label text");
382  $aria_label = $b->getAriaLabel();
383 
384  $html = $this->normalizeHTML($r->render($b));
385  $css_classes = self::$canonical_css_classes[$factory_method];
386  $expected = "<button class=\"$css_classes\" aria-label=\"$aria_label\" data-action=\"$ln\" id=\"id_1\">" .
387  "label" .
388  "</button>";
389  $this->assertHTMLEquals($expected, $html);
390  }
391  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
getButtonFactory()
Definition: ButtonTest.php:16
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$html
Definition: example_001.php:87
+ 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 472 of file ButtonTest.php.

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

473  {
474  foreach (["primary", "standard"] as $method) {
475  $ln = "http://www.ilias.de";
476  $f = $this->getButtonFactory();
477  $r = $this->getDefaultRenderer();
478  $b = $f->$method("label", $ln)
479  ->withLoadingAnimationOnClick(true);
480 
481  $html = $this->normalizeHTML($r->render($b));
482 
483  $css_classes = self::$canonical_css_classes[$method];
484  $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
485  "label" .
486  "</button>";
487  $this->assertHTMLEquals($expected, $html);
488  }
489  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
getButtonFactory()
Definition: ButtonTest.php:16
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$html
Definition: example_001.php:87
+ 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 218 of file ButtonTest.php.

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

219  {
220  $ln = "http://www.ilias.de";
221  $f = $this->getButtonFactory();
222  $r = $this->getDefaultRenderer();
223  $ids = array();
224  $b = $f->$factory_method("label", $ln)
225  ->withOnLoadCode(function ($id) use (&$ids) {
226  $ids[] = $id;
227  return "";
228  });
229 
230  $html = $this->normalizeHTML($r->render($b));
231 
232  $this->assertCount(1, $ids);
233 
234  $id = $ids[0];
235  $css_classes = self::$canonical_css_classes[$factory_method];
236  $expected = "<button class=\"$css_classes\" data-action=\"$ln\" id=\"$id\">" .
237  "label" .
238  "</button>";
239  $this->assertHTMLEquals($expected, $html);
240  }
if(!array_key_exists('StateId', $_REQUEST)) $id
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
getButtonFactory()
Definition: ButtonTest.php:16
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$html
Definition: example_001.php:87
+ 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 448 of file ButtonTest.php.

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

449  {
450  $ln = "http://www.ilias.de";
451  $f = $this->getButtonFactory();
452  $signal = $this->createMock(Signal::class);
453  $signal->method("__toString")
454  ->willReturn("MOCK_SIGNAL");
455 
456  $b = $f->$factory_method("label", $ln)
457  ->withOnClick($signal);
458  $r = $this->getDefaultRenderer();
459 
460  $html = $this->normalizeHTML($r->render($b));
461 
462  $css_classes = self::$canonical_css_classes[$factory_method];
463  $expected = "<button class=\"$css_classes\" id=\"id_1\">" .
464  "label" .
465  "</button>";
466  $this->assertHTMLEquals($expected, $html);
467  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
getButtonFactory()
Definition: ButtonTest.php:16
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_close_button()

ButtonTest::test_render_close_button ( )

Definition at line 200 of file ButtonTest.php.

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

201  {
202  $f = $this->getButtonFactory();
203  $r = $this->getDefaultRenderer();
204  $b = $f->close();
205 
206  $html = $this->normalizeHTML($r->render($b));
207 
208  $expected = "<button type=\"button\" class=\"close\" data-dismiss=\"modal\">" .
209  " <span aria-hidden=\"true\">&times;</span>" .
210  " <span class=\"sr-only\">Close</span>" .
211  "</button>";
212  $this->assertEquals($expected, $html);
213  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
getButtonFactory()
Definition: ButtonTest.php:16
$r
Definition: example_031.php:79
$html
Definition: example_001.php:87
+ 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 418 of file ButtonTest.php.

References $f, and getButtonFactory().

419  {
420  $f = $this->getButtonFactory();
421  $signal = $this->createMock(C\Signal::class);
422  $button = $f->$factory_method("label", "http://www.example.com");
423  $this->assertEquals("http://www.example.com", $button->getAction());
424 
425  $button = $button->withOnClick($signal);
426 
427  $this->assertEquals([$signal], $button->getAction());
428  }
getButtonFactory()
Definition: ButtonTest.php:16
+ 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 21 of file ButtonTest.php.

◆ $canonical_css_inactivation_classes

ButtonTest::$canonical_css_inactivation_classes
static
Initial value:
= array( "standard" => "ilSubmitInactive disabled"
, "primary" => "ilSubmitInactive disabled"
, "shy" => "ilSubmitInactive disabled"
, "tag" => "btn-tag-inactive"
)

Definition at line 27 of file ButtonTest.php.


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