19 declare(strict_types=1);
    21 require_once(__DIR__ . 
"/../../../../libs/composer/vendor/autoload.php");
    22 require_once(__DIR__ . 
"/../../Base.php");
    42         "standard" => 
"btn btn-default",
    43         "primary" => 
"btn btn-default btn-primary",
    44         "shy" => 
"btn btn-link",
    45         "tag" => 
"btn btn-tag btn-tag-relevance-veryhigh"    52         $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Button\\Factory", 
$f);
    53         $this->assertInstanceOf(
    54             "ILIAS\\UI\\Component\\Button\\Standard",
    55             $f->standard(
"label", 
"http://www.ilias.de")
    57         $this->assertInstanceOf(
    58             "ILIAS\\UI\\Component\\Button\\Primary",
    59             $f->primary(
"label", 
"http://www.ilias.de")
    61         $this->assertInstanceOf(
    62             "ILIAS\\UI\\Component\\Button\\Close",
    65         $this->assertInstanceOf(
    66             "ILIAS\\UI\\Component\\Button\\Shy",
    67             $f->shy(
"label", 
"http://www.ilias.de")
    76         $this->expectException(TypeError::class);
    78         $f->$factory_method($this, 
"http://www.ilias.de");
    86         $this->expectException(InvalidArgumentException::class);
    88         $f->$factory_method(
"label", $this);
    97         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de");
    99         $this->assertEquals(
"label", 
$b->getLabel());
   108         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de");
   110         $b2 = 
$b->withLabel(
"label2");
   112         $this->assertEquals(
"label", 
$b->getLabel());
   113         $this->assertEquals(
"label2", $b2->getLabel());
   122         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de");
   124         $this->assertEquals(
"http://www.ilias.de", 
$b->getAction());
   133         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de");
   135         $this->assertTrue(
$b->isActive());
   144         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de")
   145                ->withUnavailableAction();
   147         $this->assertFalse(
$b->isActive());
   148         $this->assertEquals(
"http://www.ilias.de", 
$b->getAction());
   150         $b = $b->withUnavailableAction(
false);
   151         $this->assertTrue($b->isActive());
   160         foreach ([
"standard", 
"primary"] as $method) {
   161             $b = 
$f->$method(
"label", 
"http://www.ilias.de");
   163             $this->assertFalse(
$b->hasLoadingAnimationOnClick());
   165             $b = $b->withLoadingAnimationOnClick(
true);
   167             $this->assertTrue($b->hasLoadingAnimationOnClick());
   176         $ln = 
"http://www.ilias.de";
   178         $b = 
$f->$factory_method(
"label", $ln);
   183         $css_classes = self::$canonical_css_classes[$factory_method];
   184         $expected = 
"<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
   195         $ln = 
"http://www.ilias.de";
   197         $b = 
$f->$factory_method(
"label", $ln)
   198                ->withUnavailableAction();
   203         $css_classes = self::$canonical_css_classes[$factory_method];
   204         $expected = 
"<button class=\"$css_classes\" data-action=\"$ln\" disabled=\"disabled\">" .
   218         $expected = 
"<button type=\"button\" class=\"close\" aria-label=\"close\">" .
   219             "   <span aria-hidden=\"true\">×</span>" .
   221         $this->assertEquals($expected, $html);
   232         $expected = 
"<button type=\"button\" class=\"minimize\" aria-label=\"minimize\">" .
   233             "   <span aria-hidden=\"true\">−</span>" .
   235         $this->assertEquals($expected, $html);
   243         $ln = 
"http://www.ilias.de";
   247         $b = 
$f->$factory_method(
"label", $ln)
   248                ->withOnLoadCode(
function (
$id) use (&$ids): 
string {
   255         $this->assertCount(1, $ids);
   258         $css_classes = self::$canonical_css_classes[$factory_method];
   259         $expected = 
"<button class=\"$css_classes\" data-action=\"$ln\" id=\"$id\">" .
   271                ->withOnLoadCode(
function (
$id) use (&$ids): 
string {
   278         $this->assertCount(1, $ids);
   281         $expected = 
"<button type=\"button\" class=\"close\" aria-label=\"close\" id=\"$id\">" .
   282             "   <span aria-hidden=\"true\">×</span>" .
   284         $this->assertEquals($expected, $html);
   290         $b = 
$f->tag(
'tag', 
'#');
   292         $this->expectException(TypeError::class);
   293         $b->withRelevance(0);
   295         $this->expectException(TypeError::class);
   296         $b->withRelevance(
'notsoimportant');
   301         $expectations = array(
   302             '<button class="btn btn-tag btn-tag-relevance-verylow" data-action="#" id="id_1">tag</button>',
   303             '<button class="btn btn-tag btn-tag-relevance-low" data-action="#" id="id_2">tag</button>',
   304             '<button class="btn btn-tag btn-tag-relevance-middle" data-action="#" id="id_3">tag</button>',
   305             '<button class="btn btn-tag btn-tag-relevance-high" data-action="#" id="id_4">tag</button>',
   306             '<button class="btn btn-tag btn-tag-relevance-veryhigh" data-action="#" id="id_5">tag</button>'   311         $t = 
$f->tag(
'tag', 
'#');
   312         $possible_relevances = array(
   319         foreach ($possible_relevances as $w) {
   321                 $r->render($t->withRelevance($w))
   323             $expected = $expectations[array_search($w, $possible_relevances)];
   324             $this->assertEquals($expected, $html);
   332         $df = new \ILIAS\Data\Factory();
   334         $bgcol = $df->color(
'#00ff00');
   336         $b = 
$f->tag(
'tag', 
'#')
   337                ->withBackgroundColor($bgcol);
   339         $expected = 
'<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #000000;" data-action="#" id="id_1">tag</button>';
   340         $this->assertEquals($expected, $html);
   342         $fcol = $df->color(
'#ddd');
   343         $b = 
$b->withForegroundColor($fcol);
   345         $expected = 
'<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #dddddd;" data-action="#" id="id_2">tag</button>';
   346         $this->assertEquals($expected, $html);
   353         $df = new \ILIAS\Data\Factory();
   355         $classes = array(
'cl1', 
'cl2');
   356         $b = 
$f->tag(
'tag', 
'#')
   357                ->withClasses($classes);
   358         $this->assertEquals($classes, 
$b->getClasses());
   361         $expected = 
'<button class="btn btn-tag btn-tag-relevance-veryhigh cl1 cl2" data-action="#" id="id_1">tag</button>';
   362         $this->assertEquals($expected, $html);
   371         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de")->withAriaLabel(
"ariatext");
   372         $this->assertEquals(
"ariatext", 
$b->getAriaLabel());
   381         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de");
   383             $this->assertEquals(
false, 
$b->isEngageable());
   384             $b2 = 
$f->$factory_method(
"label", 
"http://www.ilias.de")->withEngagedState(
false);
   385             $this->assertEquals(
true, $b2->isEngageable());
   387             $this->assertTrue(self::NOT_APPLICABLE);
   397         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de");
   399             $b = 
$b->withEngagedState(
false);
   400             $this->assertEquals(
false, 
$b->isEngaged());
   401             $b2 = 
$f->$factory_method(
"label", 
"http://www.ilias.de")->withEngagedState(
true);
   402             $this->assertEquals(
true, $b2->isEngaged());
   404             $this->assertTrue(self::NOT_APPLICABLE);
   413         $ln = 
"http://www.ilias.de";
   416         $b = 
$f->$factory_method(
"label", $ln)->withAriaLabel(
"aria label text");
   417         $aria_label = 
$b->getAriaLabel();
   420         $css_classes = self::$canonical_css_classes[$factory_method];
   421         $expected = 
"<button class=\"$css_classes\" aria-label=\"$aria_label\" data-action=\"$ln\" id=\"id_1\">" .
   432         $ln = 
"http://www.ilias.de";
   435         $b = 
$f->$factory_method(
"label", $ln);
   437             $b = 
$b->withEngagedState(
true);
   440             $css_classes = self::$canonical_css_classes[$factory_method];
   441             $css_classes .= 
' engaged';
   442             $expected = 
"<button class=\"$css_classes\" aria-pressed=\"true\" data-action=\"$ln\" id=\"id_1\">" .
   447             $this->assertTrue(self::NOT_APPLICABLE);
   457         $signal = $this->createMock(
C\Signal::class);
   458         $button = 
$f->$factory_method(
"label", 
"http://www.example.com");
   459         $this->assertEquals(
"http://www.example.com", $button->getAction());
   461         $button = $button->withOnClick($signal);
   463         $this->assertEquals([$signal], $button->getAction());
   472         $signal1 = $this->createMock(
C\Signal::class);
   473         $signal2 = $this->createMock(
C\Signal::class);
   474         $button = 
$f->$factory_method(
"label", 
"http://www.example.com");
   476         $button = $button->withOnClick($signal1)->appendOnClick($signal2);
   478         $this->assertEquals([$signal1, $signal2], $button->getAction());
   486         $ln = 
"http://www.ilias.de";
   488         $signal = $this->createMock(Signal::class);
   489         $signal->method(
"__toString")
   490                ->willReturn(
"MOCK_SIGNAL");
   492         $b = 
$f->$factory_method(
"label", $ln)
   493                ->withOnClick($signal);
   498         $css_classes = self::$canonical_css_classes[$factory_method];
   499         $expected = 
"<button class=\"$css_classes\" id=\"id_1\">" .
   510         foreach ([
"primary", 
"standard"] as $method) {
   511             $ln = 
"http://www.ilias.de";
   514             $b = 
$f->$method(
"label", $ln)
   515                    ->withLoadingAnimationOnClick(
true);
   519             $css_classes = self::$canonical_css_classes[$method];
   520             $expected = 
"<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
   534         $ln = 
"http://www.ilias.de";
   537             $f->$factory_method(
"label", $ln)
   538                ->withHelpTopics(
new Help\
Topic(
"a"), 
new Help\
Topic(
"b"));
   540         $css_classes = self::$canonical_css_classes[$factory_method];
   542             "<div class=\"c-tooltip__container\">" .
   543                  "<button class=\"$css_classes\" aria-describedby=\"id_2\" data-action=\"$ln\" id=\"id_1\" >" .
   546                 "<div id=\"id_2\" role=\"tooltip\" class=\"c-tooltip c-tooltip--hidden\">" .
   547                     "<p>tooltip: a</p>" .
   548                     "<p>tooltip: b</p>" .
   566         $signal = $this->createMock(
C\Signal::class);
   568         $button = 
$f->$factory_method(
"label", $signal);
   570         $this->assertEquals([$signal], $button->getAction());
 
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
This is just a class that marks a string as a help topic. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
 
Provides common functionality for UI tests. 
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
normalizeHTML(string $html)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...