ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)
 
 testButtonStringActionOnly (string $factory_method)
 
 testButtonLabel (string $factory_method)
 
 testButtonWithLabel (string $factory_method)
 
 testButtonWithGlyphLabel (string $factory_method)
 
 testButtonAction (string $factory_method)
 
 testButtonActivatedOnDefault (string $factory_method)
 
 testButtonDeactivation (string $factory_method)
 
 testButtonWithLoadingAnimation ()
 test loading animation More...
 
 testRenderButtonLabel (string $factory_method)
 
 testRenderButtonDisabled (string $factory_method)
 
 testRenderCloseButton ()
 
 testRenderMinimizeButton ()
 
 testRenderButtonWithOnLoadCode (string $factory_method)
 
 testRenderCloseButtonWithOnLoadCode ()
 
 testBtnTagRelevance ()
 
 testRenderBtnTagRelevance ()
 
 testRenderBtnTagColors ()
 
 testRenderBtnTagClasses ()
 
 testButtonWithAriaLabel (string $factory_method)
 
 testButtonWithEngageable (string $factory_method)
 
 testButtonWithEngaged (string $factory_method)
 
 testRenderButtonWithAriaLabel (string $factory_method)
 
 testRenderButtonWithAriaPressed (string $factory_method)
 
 testWithOnClickRemovesAction (string $factory_method)
 
 testAppendOnClickAppendsToAction (string $factory_method)
 
 testRenderButtonWithSignal (string $factory_method)
 
 testRenderButtonWithOnClickAnimation ()
 test rendering with on click animation More...
 
 testButtonRendersTooltip (string $factory_method)
 
 testFactoryAcceptsSignalAsAction (string $factory_method)
 
 testRenderButtonWithSymbolAndLabel ()
 

Static Public Member Functions

static getButtonTypeProvider ()
 

Data Fields

const NOT_APPLICABLE = true
 

Static Public Attributes

static array $canonical_css_classes
 

Detailed Description

Test on button implementation.

Definition at line 33 of file ButtonTest.php.

Member Function Documentation

◆ getButtonFactory()

◆ getButtonTypeProvider()

static ButtonTest::getButtonTypeProvider ( )
static

Definition at line 543 of file ButtonTest.php.

543 : array
544 {
545 return [
546 ['standard'],
547 ['primary'],
548 ['shy'],
549 ['tag']
550 ];
551 }

◆ testAppendOnClickAppendsToAction()

ButtonTest::testAppendOnClickAppendsToAction ( string  $factory_method)

Definition at line 446 of file ButtonTest.php.

446 : void
447 {
448 $f = $this->getButtonFactory();
449 $signal1 = $this->createMock(C\Signal::class);
450 $signal2 = $this->createMock(C\Signal::class);
451 $button = $f->$factory_method("label", "http://www.example.com");
452
453 $button = $button->withOnClick($signal1)->appendOnClick($signal2);
454
455 $this->assertEquals([$signal1, $signal2], $button->getAction());
456 }
getButtonFactory()
Definition: ButtonTest.php:37

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

+ Here is the call graph for this function:

◆ testBtnTagRelevance()

ButtonTest::testBtnTagRelevance ( )

Definition at line 278 of file ButtonTest.php.

278 : void
279 {
280 $f = $this->getButtonFactory();
281 $b = $f->tag('tag', '#');
282
283 $this->expectException(TypeError::class);
284 $b->withRelevance(0);
285
286 $this->expectException(TypeError::class);
287 $b->withRelevance('notsoimportant');
288 }

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

+ Here is the call graph for this function:

◆ testButtonAction()

ButtonTest::testButtonAction ( string  $factory_method)

Definition at line 120 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testButtonActivatedOnDefault()

ButtonTest::testButtonActivatedOnDefault ( string  $factory_method)

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:

◆ testButtonDeactivation()

ButtonTest::testButtonDeactivation ( string  $factory_method)

Definition at line 138 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testButtonLabel()

ButtonTest::testButtonLabel ( string  $factory_method)

Definition at line 89 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testButtonLabelOrGlyphOnly()

ButtonTest::testButtonLabelOrGlyphOnly ( string  $factory_method)

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:

◆ testButtonRendersTooltip()

ButtonTest::testButtonRendersTooltip ( string  $factory_method)

Definition at line 503 of file ButtonTest.php.

503 : void
504 {
505 $f = $this->getButtonFactory();
506 $r = $this->getDefaultRenderer();
507 $ln = "http://www.ilias.de";
508
509 $button =
510 $f->$factory_method("label", $ln)
511 ->withHelpTopics(new Help\Topic("a"), new Help\Topic("b"));
512
513 $css_classes = self::$canonical_css_classes[$factory_method];
514 $expected =
515 "<div class=\"c-tooltip__container\">" .
516 "<button class=\"$css_classes\" aria-describedby=\"id_2\" data-action=\"$ln\" id=\"id_1\" >" .
517 "label" .
518 "</button>" .
519 "<div id=\"id_2\" role=\"tooltip\" class=\"c-tooltip c-tooltip--hidden\">" .
520 "<p>tooltip: a</p>" .
521 "<p>tooltip: b</p>" .
522 "</div>" .
523 "</div>";
524
525 $html = $this->normalizeHTML($r->render($button));
526 $this->assertHTMLEquals($expected, $html);
527 }
This is just a class that marks a string as a help topic.
Definition: Topic.php:27

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

+ Here is the call graph for this function:

◆ testButtonStringActionOnly()

ButtonTest::testButtonStringActionOnly ( string  $factory_method)

Definition at line 81 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testButtonWithAriaLabel()

ButtonTest::testButtonWithAriaLabel ( string  $factory_method)

Definition at line 357 of file ButtonTest.php.

357 : void
358 {
359 $f = $this->getButtonFactory();
360 $b = $f->$factory_method("label", "http://www.ilias.de")->withAriaLabel("ariatext");
361 $this->assertEquals("ariatext", $b->getAriaLabel());
362 }

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

+ Here is the call graph for this function:

◆ testButtonWithEngageable()

ButtonTest::testButtonWithEngageable ( string  $factory_method)

Definition at line 365 of file ButtonTest.php.

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

+ Here is the call graph for this function:

◆ testButtonWithEngaged()

ButtonTest::testButtonWithEngaged ( string  $factory_method)

Definition at line 379 of file ButtonTest.php.

379 : void
380 {
381 $f = $this->getButtonFactory();
382 $b = $f->$factory_method("label", "http://www.ilias.de");
383 if ($b instanceof C\Button\Engageable) {
384 $b = $b->withEngagedState(false);
385 $this->assertEquals(false, $b->isEngaged());
386 $b2 = $f->$factory_method("label", "http://www.ilias.de")->withEngagedState(true);
387 $this->assertEquals(true, $b2->isEngaged());
388 } else {
389 $this->assertTrue(self::NOT_APPLICABLE);
390 }
391 }

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

+ Here is the call graph for this function:

◆ testButtonWithGlyphLabel()

ButtonTest::testButtonWithGlyphLabel ( string  $factory_method)

Definition at line 110 of file ButtonTest.php.

110 : void
111 {
112 $f = $this->getButtonFactory();
113 $glyph = new Glyph(C\Symbol\Glyph\Glyph::LIKE, '');
114 $b = $f->$factory_method('', '')
115 ->withSymbol($glyph);
116 $this->assertEquals($glyph, $b->getSymbol());
117 }

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

+ Here is the call graph for this function:

◆ testButtonWithLabel()

ButtonTest::testButtonWithLabel ( string  $factory_method)

Definition at line 98 of file ButtonTest.php.

98 : void
99 {
100 $f = $this->getButtonFactory();
101 $b = $f->$factory_method("label", "http://www.ilias.de");
102
103 $b2 = $b->withLabel("label2");
104
105 $this->assertEquals("label", $b->getLabel());
106 $this->assertEquals("label2", $b2->getLabel());
107 }

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

+ Here is the call graph for this function:

◆ testButtonWithLoadingAnimation()

ButtonTest::testButtonWithLoadingAnimation ( )

test loading animation

Definition at line 154 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testFactoryAcceptsSignalAsAction()

ButtonTest::testFactoryAcceptsSignalAsAction ( string  $factory_method)

Definition at line 533 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

ButtonTest::testImplementsFactoryInterface ( )

Definition at line 49 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testRenderBtnTagClasses()

ButtonTest::testRenderBtnTagClasses ( )

Definition at line 340 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testRenderBtnTagColors()

ButtonTest::testRenderBtnTagColors ( )

Definition at line 319 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testRenderBtnTagRelevance()

ButtonTest::testRenderBtnTagRelevance ( )

Definition at line 290 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testRenderButtonDisabled()

ButtonTest::testRenderButtonDisabled ( string  $factory_method)

Definition at line 186 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testRenderButtonLabel()

ButtonTest::testRenderButtonLabel ( string  $factory_method)

Definition at line 169 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testRenderButtonWithAriaLabel()

ButtonTest::testRenderButtonWithAriaLabel ( string  $factory_method)

Definition at line 394 of file ButtonTest.php.

394 : void
395 {
396 $ln = "http://www.ilias.de";
397 $f = $this->getButtonFactory();
398 $r = $this->getDefaultRenderer();
399 $b = $f->$factory_method("label", $ln)->withAriaLabel("aria label text");
400 $aria_label = $b->getAriaLabel();
401
402 $html = $this->normalizeHTML($r->render($b));
403 $css_classes = self::$canonical_css_classes[$factory_method];
404 $expected = "<button class=\"$css_classes\" aria-label=\"$aria_label\" data-action=\"$ln\" id=\"id_1\">" .
405 "label" .
406 "</button>";
407 $this->assertHTMLEquals($expected, $html);
408 }

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

+ Here is the call graph for this function:

◆ testRenderButtonWithAriaPressed()

ButtonTest::testRenderButtonWithAriaPressed ( string  $factory_method)

Definition at line 411 of file ButtonTest.php.

411 : void
412 {
413 $ln = "http://www.ilias.de";
414 $f = $this->getButtonFactory();
415 $r = $this->getDefaultRenderer();
416 $b = $f->$factory_method("label", $ln);
417 if ($b instanceof C\Button\Engageable) {
418 $b = $b->withEngagedState(true);
419
420 $html = $this->normalizeHTML($r->render($b));
421 $css_classes = self::$canonical_css_classes[$factory_method];
422 $css_classes .= ' engaged';
423 $expected = "<button class=\"$css_classes\" aria-pressed=\"true\" data-action=\"$ln\" id=\"id_1\">" .
424 "label" .
425 "</button>";
426 $this->assertHTMLEquals($expected, $html);
427 } else {
428 $this->assertTrue(self::NOT_APPLICABLE);
429 }
430 }

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

+ Here is the call graph for this function:

◆ testRenderButtonWithOnClickAnimation()

ButtonTest::testRenderButtonWithOnClickAnimation ( )

test rendering with on click animation

Definition at line 483 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testRenderButtonWithOnLoadCode()

ButtonTest::testRenderButtonWithOnLoadCode ( string  $factory_method)

Definition at line 232 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testRenderButtonWithSignal()

ButtonTest::testRenderButtonWithSignal ( string  $factory_method)

Definition at line 459 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testRenderButtonWithSymbolAndLabel()

ButtonTest::testRenderButtonWithSymbolAndLabel ( )

Definition at line 553 of file ButtonTest.php.

553 : void
554 {
555 $f = $this->getButtonFactory();
556 $r = $this->getDefaultRenderer();
557 $glyph = new Glyph(C\Symbol\Glyph\Glyph::LIKE, 'The Glyph Label');
558 $button = $f->standard('The Button Label', '')
559 ->withSymbol($glyph);
560
561 // the glyph still contains its aria-label
562 $this->assertStringContainsString(
563 'aria-label="The Glyph Label"',
564 $r->render($glyph)
565 );
566
567 //but not in button context
568 $expected = $this->brutallyTrimHTML(
569 '
570 <button class="btn btn-default" data-action="">
571 <span class="glyph" role="img">
572 <span class="glyphicon il-glyphicon-like" aria-hidden="true"></span>
573 </span>
574 The Button Label
575 </button>'
576 );
577 $html = $this->brutallyTrimHTML($r->render($button));
578 $this->assertHTMLEquals($expected, $html);
579 }

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

+ Here is the call graph for this function:

◆ testRenderCloseButton()

ButtonTest::testRenderCloseButton ( )

Definition at line 203 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testRenderCloseButtonWithOnLoadCode()

ButtonTest::testRenderCloseButtonWithOnLoadCode ( )

Definition at line 256 of file ButtonTest.php.

256 : void
257 {
258 $f = $this->getButtonFactory();
259 $r = $this->getDefaultRenderer();
260 $ids = array();
261 $b = $f->close()
262 ->withOnLoadCode(function ($id) use (&$ids): string {
263 $ids[] = $id;
264 return "";
265 });
266
267 $html = $this->normalizeHTML($r->render($b));
268
269 $this->assertCount(1, $ids);
270
271 $id = $ids[0];
272 $expected = "<button type=\"button\" class=\"close\" aria-label=\"close\" id=\"$id\">" .
273 " <span aria-hidden=\"true\">&times;</span>" .
274 "</button>";
275 $this->assertEquals($expected, $html);
276 }

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

+ Here is the call graph for this function:

◆ testRenderMinimizeButton()

ButtonTest::testRenderMinimizeButton ( )

Definition at line 217 of file ButtonTest.php.

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

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

+ Here is the call graph for this function:

◆ testWithOnClickRemovesAction()

ButtonTest::testWithOnClickRemovesAction ( string  $factory_method)

Definition at line 433 of file ButtonTest.php.

433 : void
434 {
435 $f = $this->getButtonFactory();
436 $signal = $this->createMock(C\Signal::class);
437 $button = $f->$factory_method("label", "http://www.example.com");
438 $this->assertEquals("http://www.example.com", $button->getAction());
439
440 $button = $button->withOnClick($signal);
441
442 $this->assertEquals([$signal], $button->getAction());
443 }

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

◆ NOT_APPLICABLE

const ButtonTest::NOT_APPLICABLE = true

Definition at line 35 of file ButtonTest.php.


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