Test on button implementation.
More...
Test on button implementation.
Definition at line 33 of file ButtonTest.php.
◆ getButtonFactory()
ButtonTest::getButtonFactory |
( |
| ) |
|
Definition at line 37 of file ButtonTest.php.
Referenced by testAppendOnClickAppendsToAction(), testBtnTagRelevance(), testButtonAction(), testButtonActivatedOnDefault(), testButtonDeactivation(), testButtonLabel(), testButtonLabelOrGlyphOnly(), testButtonRendersTooltip(), testButtonStringActionOnly(), testButtonWithAriaLabel(), testButtonWithEngageable(), testButtonWithEngaged(), testButtonWithGlyphLabel(), testButtonWithLabel(), testButtonWithLoadingAnimation(), testFactoryAcceptsSignalAsAction(), testImplementsFactoryInterface(), testRenderBtnTagClasses(), testRenderBtnTagColors(), testRenderBtnTagRelevance(), testRenderButtonDisabled(), testRenderButtonLabel(), testRenderButtonWithAriaLabel(), testRenderButtonWithAriaPressed(), testRenderButtonWithOnClickAnimation(), testRenderButtonWithOnLoadCode(), testRenderButtonWithSignal(), testRenderButtonWithSymbolAndLabel(), testRenderCloseButton(), testRenderCloseButtonWithOnLoadCode(), testRenderMinimizeButton(), and testWithOnClickRemovesAction().
◆ getButtonTypeProvider()
static ButtonTest::getButtonTypeProvider |
( |
| ) |
|
|
static |
◆ testAppendOnClickAppendsToAction()
ButtonTest::testAppendOnClickAppendsToAction |
( |
string |
$factory_method | ) |
|
Definition at line 446 of file ButtonTest.php.
References Vendor\Package\$f, and 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");
453 $button = $button->withOnClick($signal1)->appendOnClick($signal2);
455 $this->assertEquals([$signal1, $signal2], $button->getAction());
◆ testBtnTagRelevance()
ButtonTest::testBtnTagRelevance |
( |
| ) |
|
◆ testButtonAction()
ButtonTest::testButtonAction |
( |
string |
$factory_method | ) |
|
◆ testButtonActivatedOnDefault()
ButtonTest::testButtonActivatedOnDefault |
( |
string |
$factory_method | ) |
|
◆ testButtonDeactivation()
ButtonTest::testButtonDeactivation |
( |
string |
$factory_method | ) |
|
Definition at line 138 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, and getButtonFactory().
141 $b =
$f->$factory_method(
"label",
"http://www.ilias.de")
142 ->withUnavailableAction();
144 $this->assertFalse(
$b->isActive());
145 $this->assertEquals(
"http://www.ilias.de",
$b->getAction());
147 $b = $b->withUnavailableAction(
false);
148 $this->assertTrue($b->isActive());
◆ testButtonLabel()
ButtonTest::testButtonLabel |
( |
string |
$factory_method | ) |
|
◆ testButtonLabelOrGlyphOnly()
ButtonTest::testButtonLabelOrGlyphOnly |
( |
string |
$factory_method | ) |
|
◆ testButtonRendersTooltip()
ButtonTest::testButtonRendersTooltip |
( |
string |
$factory_method | ) |
|
Definition at line 503 of file ButtonTest.php.
References Vendor\Package\$f, $r, and getButtonFactory().
506 $r = $this->getDefaultRenderer();
507 $ln =
"http://www.ilias.de";
510 $f->$factory_method(
"label", $ln)
511 ->withHelpTopics(
new Help\
Topic(
"a"),
new Help\
Topic(
"b"));
513 $css_classes = self::$canonical_css_classes[$factory_method];
515 "<div class=\"c-tooltip__container\">" .
516 "<button class=\"$css_classes\" aria-describedby=\"id_2\" data-action=\"$ln\" id=\"id_1\" >" .
519 "<div id=\"id_2\" role=\"tooltip\" class=\"c-tooltip c-tooltip--hidden\">" .
520 "<p>tooltip: a</p>" .
521 "<p>tooltip: b</p>" .
525 $html = $this->normalizeHTML(
$r->render($button));
526 $this->assertHTMLEquals($expected, $html);
This is just a class that marks a string as a help topic.
◆ testButtonStringActionOnly()
ButtonTest::testButtonStringActionOnly |
( |
string |
$factory_method | ) |
|
◆ testButtonWithAriaLabel()
ButtonTest::testButtonWithAriaLabel |
( |
string |
$factory_method | ) |
|
◆ testButtonWithEngageable()
ButtonTest::testButtonWithEngageable |
( |
string |
$factory_method | ) |
|
Definition at line 365 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, and getButtonFactory().
368 $b =
$f->$factory_method(
"label",
"http://www.ilias.de");
370 $this->assertEquals(
false,
$b->isEngageable());
371 $b2 =
$f->$factory_method(
"label",
"http://www.ilias.de")->withEngagedState(
false);
372 $this->assertEquals(
true, $b2->isEngageable());
374 $this->assertTrue(self::NOT_APPLICABLE);
◆ testButtonWithEngaged()
ButtonTest::testButtonWithEngaged |
( |
string |
$factory_method | ) |
|
Definition at line 379 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, and getButtonFactory().
382 $b =
$f->$factory_method(
"label",
"http://www.ilias.de");
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());
389 $this->assertTrue(self::NOT_APPLICABLE);
◆ testButtonWithGlyphLabel()
ButtonTest::testButtonWithGlyphLabel |
( |
string |
$factory_method | ) |
|
◆ testButtonWithLabel()
ButtonTest::testButtonWithLabel |
( |
string |
$factory_method | ) |
|
◆ testButtonWithLoadingAnimation()
ButtonTest::testButtonWithLoadingAnimation |
( |
| ) |
|
test loading animation
Definition at line 154 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, and getButtonFactory().
157 foreach ([
"standard",
"primary"] as $method) {
158 $b =
$f->$method(
"label",
"http://www.ilias.de");
160 $this->assertFalse(
$b->hasLoadingAnimationOnClick());
162 $b = $b->withLoadingAnimationOnClick(
true);
164 $this->assertTrue($b->hasLoadingAnimationOnClick());
◆ testFactoryAcceptsSignalAsAction()
ButtonTest::testFactoryAcceptsSignalAsAction |
( |
string |
$factory_method | ) |
|
◆ testImplementsFactoryInterface()
ButtonTest::testImplementsFactoryInterface |
( |
| ) |
|
Definition at line 49 of file ButtonTest.php.
References Vendor\Package\$f, and getButtonFactory().
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")
58 $this->assertInstanceOf(
59 "ILIAS\\UI\\Component\\Button\\Primary",
60 $f->primary(
"label",
"http://www.ilias.de")
62 $this->assertInstanceOf(
63 "ILIAS\\UI\\Component\\Button\\Close",
66 $this->assertInstanceOf(
67 "ILIAS\\UI\\Component\\Button\\Shy",
68 $f->shy(
"label",
"http://www.ilias.de")
◆ testRenderBtnTagClasses()
ButtonTest::testRenderBtnTagClasses |
( |
| ) |
|
Definition at line 340 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, $r, and getButtonFactory().
343 $r = $this->getDefaultRenderer();
344 $df = new \ILIAS\Data\Factory();
346 $classes = array(
'cl1',
'cl2');
347 $b =
$f->tag(
'tag',
'#')
348 ->withClasses($classes);
349 $this->assertEquals($classes,
$b->getClasses());
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);
◆ testRenderBtnTagColors()
ButtonTest::testRenderBtnTagColors |
( |
| ) |
|
Definition at line 319 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, $r, and getButtonFactory().
322 $r = $this->getDefaultRenderer();
323 $df = new \ILIAS\Data\Factory();
325 $bgcol = $df->color(
'#00ff00');
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);
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);
◆ testRenderBtnTagRelevance()
ButtonTest::testRenderBtnTagRelevance |
( |
| ) |
|
Definition at line 290 of file ButtonTest.php.
References Vendor\Package\$f, $r, and getButtonFactory().
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>' 301 $r = $this->getDefaultRenderer();
302 $t =
$f->tag(
'tag',
'#');
303 $possible_relevances = array(
310 foreach ($possible_relevances as $w) {
311 $html = $this->normalizeHTML(
312 $r->render($t->withRelevance($w))
314 $expected = $expectations[array_search($w, $possible_relevances)];
315 $this->assertEquals($expected, $html);
◆ testRenderButtonDisabled()
ButtonTest::testRenderButtonDisabled |
( |
string |
$factory_method | ) |
|
Definition at line 186 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, $r, and getButtonFactory().
188 $ln =
"http://www.ilias.de";
190 $b =
$f->$factory_method(
"label", $ln)
191 ->withUnavailableAction();
192 $r = $this->getDefaultRenderer();
194 $html = $this->normalizeHTML(
$r->render(
$b));
196 $css_classes = self::$canonical_css_classes[$factory_method];
197 $expected =
"<button class=\"$css_classes\" data-action=\"$ln\" disabled=\"disabled\">" .
200 $this->assertHTMLEquals($expected, $html);
◆ testRenderButtonLabel()
ButtonTest::testRenderButtonLabel |
( |
string |
$factory_method | ) |
|
Definition at line 169 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, $r, and getButtonFactory().
171 $ln =
"http://www.ilias.de";
173 $b =
$f->$factory_method(
"label", $ln);
174 $r = $this->getDefaultRenderer();
176 $html = $this->normalizeHTML(
$r->render(
$b));
178 $css_classes = self::$canonical_css_classes[$factory_method];
179 $expected =
"<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
182 $this->assertHTMLEquals($expected, $html);
◆ testRenderButtonWithAriaLabel()
ButtonTest::testRenderButtonWithAriaLabel |
( |
string |
$factory_method | ) |
|
Definition at line 394 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, $r, and getButtonFactory().
396 $ln =
"http://www.ilias.de";
398 $r = $this->getDefaultRenderer();
399 $b =
$f->$factory_method(
"label", $ln)->withAriaLabel(
"aria label text");
400 $aria_label =
$b->getAriaLabel();
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\">" .
407 $this->assertHTMLEquals($expected, $html);
◆ testRenderButtonWithAriaPressed()
ButtonTest::testRenderButtonWithAriaPressed |
( |
string |
$factory_method | ) |
|
Definition at line 411 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, $r, and getButtonFactory().
413 $ln =
"http://www.ilias.de";
415 $r = $this->getDefaultRenderer();
416 $b =
$f->$factory_method(
"label", $ln);
418 $b =
$b->withEngagedState(
true);
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\">" .
426 $this->assertHTMLEquals($expected, $html);
428 $this->assertTrue(self::NOT_APPLICABLE);
◆ testRenderButtonWithOnClickAnimation()
ButtonTest::testRenderButtonWithOnClickAnimation |
( |
| ) |
|
test rendering with on click animation
Definition at line 483 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, $r, and getButtonFactory().
485 foreach ([
"primary",
"standard"] as $method) {
486 $ln =
"http://www.ilias.de";
488 $r = $this->getDefaultRenderer();
489 $b =
$f->$method(
"label", $ln)
490 ->withLoadingAnimationOnClick(
true);
492 $html = $this->normalizeHTML(
$r->render(
$b));
494 $css_classes = self::$canonical_css_classes[$method];
495 $expected =
"<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
498 $this->assertHTMLEquals($expected, $html);
◆ testRenderButtonWithOnLoadCode()
ButtonTest::testRenderButtonWithOnLoadCode |
( |
string |
$factory_method | ) |
|
Definition at line 232 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, $id, $r, and getButtonFactory().
234 $ln =
"http://www.ilias.de";
236 $r = $this->getDefaultRenderer();
238 $b =
$f->$factory_method(
"label", $ln)
239 ->withOnLoadCode(
function (
$id) use (&$ids):
string {
244 $html = $this->normalizeHTML(
$r->render(
$b));
246 $this->assertCount(1, $ids);
249 $css_classes = self::$canonical_css_classes[$factory_method];
250 $expected =
"<button class=\"$css_classes\" data-action=\"$ln\" id=\"$id\">" .
253 $this->assertHTMLEquals($expected, $html);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
◆ testRenderButtonWithSignal()
ButtonTest::testRenderButtonWithSignal |
( |
string |
$factory_method | ) |
|
Definition at line 459 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, $r, and getButtonFactory().
461 $ln =
"http://www.ilias.de";
463 $signal = $this->createMock(Signal::class);
464 $signal->method(
"__toString")
465 ->willReturn(
"MOCK_SIGNAL");
467 $b =
$f->$factory_method(
"label", $ln)
468 ->withOnClick($signal);
469 $r = $this->getDefaultRenderer();
471 $html = $this->normalizeHTML(
$r->render(
$b));
473 $css_classes = self::$canonical_css_classes[$factory_method];
474 $expected =
"<button class=\"$css_classes\" id=\"id_1\">" .
477 $this->assertHTMLEquals($expected, $html);
◆ testRenderButtonWithSymbolAndLabel()
ButtonTest::testRenderButtonWithSymbolAndLabel |
( |
| ) |
|
Definition at line 553 of file ButtonTest.php.
References Vendor\Package\$f, $r, and 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);
562 $this->assertStringContainsString(
563 'aria-label="The Glyph Label"',
568 $expected = $this->brutallyTrimHTML(
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> 577 $html = $this->brutallyTrimHTML(
$r->render($button));
578 $this->assertHTMLEquals($expected, $html);
◆ testRenderCloseButton()
ButtonTest::testRenderCloseButton |
( |
| ) |
|
Definition at line 203 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, $r, and getButtonFactory().
206 $r = $this->getDefaultRenderer();
209 $html = $this->normalizeHTML(
$r->render(
$b));
211 $expected =
"<button type=\"button\" class=\"close\" aria-label=\"close\">" .
212 " <span aria-hidden=\"true\">×</span>" .
214 $this->assertEquals($expected, $html);
◆ testRenderCloseButtonWithOnLoadCode()
ButtonTest::testRenderCloseButtonWithOnLoadCode |
( |
| ) |
|
Definition at line 256 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, $id, $r, and getButtonFactory().
259 $r = $this->getDefaultRenderer();
262 ->withOnLoadCode(
function (
$id) use (&$ids):
string {
267 $html = $this->normalizeHTML(
$r->render(
$b));
269 $this->assertCount(1, $ids);
272 $expected =
"<button type=\"button\" class=\"close\" aria-label=\"close\" id=\"$id\">" .
273 " <span aria-hidden=\"true\">×</span>" .
275 $this->assertEquals($expected, $html);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
◆ testRenderMinimizeButton()
ButtonTest::testRenderMinimizeButton |
( |
| ) |
|
Definition at line 217 of file ButtonTest.php.
References Vendor\Package\$b, Vendor\Package\$f, $r, and getButtonFactory().
220 $r = $this->getDefaultRenderer();
223 $html = $this->normalizeHTML(
$r->render(
$b));
225 $expected =
"<button type=\"button\" class=\"minimize\" aria-label=\"minimize\">" .
226 " <span aria-hidden=\"true\">−</span>" .
228 $this->assertEquals($expected, $html);
◆ testWithOnClickRemovesAction()
ButtonTest::testWithOnClickRemovesAction |
( |
string |
$factory_method | ) |
|
Definition at line 433 of file ButtonTest.php.
References Vendor\Package\$f, and 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());
440 $button = $button->withOnClick($signal);
442 $this->assertEquals([$signal], $button->getAction());
◆ $canonical_css_classes
array ButtonTest::$canonical_css_classes |
|
static |
Initial value:= [
"standard" => "btn btn-default"
Definition at line 42 of file ButtonTest.php.
◆ NOT_APPLICABLE
const ButtonTest::NOT_APPLICABLE = true |
◆ 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 44 of file ButtonTest.php.
The documentation for this class was generated from the following file: