19 declare(strict_types=1);
    21 require_once(__DIR__ . 
"/../../../../../../vendor/composer/vendor/autoload.php");
    22 require_once(__DIR__ . 
"/../../Base.php");
    43         "standard" => 
"btn btn-default",
    44         "primary" => 
"btn btn-default btn-primary",
    45         "shy" => 
"btn btn-link",
    46         "tag" => 
"btn btn-tag btn-tag-relevance-veryhigh"    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")
    77         $this->expectException(TypeError::class);
    79         $f->$factory_method($this, 
"http://www.ilias.de");
    87         $this->expectException(InvalidArgumentException::class);
    89         $f->$factory_method(
"label", $this);
    98         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de");
   100         $this->assertEquals(
"label", 
$b->getLabel());
   109         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de");
   111         $b2 = 
$b->withLabel(
"label2");
   113         $this->assertEquals(
"label", 
$b->getLabel());
   114         $this->assertEquals(
"label2", $b2->getLabel());
   123         $glyph = 
new Glyph(
C\Symbol\
Glyph\Glyph::LIKE, 
'');
   124         $b = 
$f->$factory_method(
'', 
'')
   125             ->withSymbol($glyph);
   126         $this->assertEquals($glyph, 
$b->getSymbol());
   135         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de");
   137         $this->assertEquals(
"http://www.ilias.de", 
$b->getAction());
   146         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de");
   148         $this->assertTrue(
$b->isActive());
   157         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de")
   158                ->withUnavailableAction();
   160         $this->assertFalse(
$b->isActive());
   161         $this->assertEquals(
"http://www.ilias.de", 
$b->getAction());
   163         $b = $b->withUnavailableAction(
false);
   164         $this->assertTrue($b->isActive());
   173         foreach ([
"standard", 
"primary"] as $method) {
   174             $b = 
$f->$method(
"label", 
"http://www.ilias.de");
   176             $this->assertFalse(
$b->hasLoadingAnimationOnClick());
   178             $b = $b->withLoadingAnimationOnClick(
true);
   180             $this->assertTrue($b->hasLoadingAnimationOnClick());
   189         $ln = 
"http://www.ilias.de";
   191         $b = 
$f->$factory_method(
"label", $ln);
   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\" id=\"id_1\">" .
   200         $this->assertHTMLEquals($expected, $html);
   208         $ln = 
"http://www.ilias.de";
   210         $b = 
$f->$factory_method(
"label", $ln)
   211                ->withUnavailableAction();
   212         $r = $this->getDefaultRenderer();
   214         $html = $this->normalizeHTML(
$r->render(
$b));
   216         $css_classes = self::$canonical_css_classes[$factory_method];
   217         $expected = 
"<button class=\"$css_classes\" data-action=\"$ln\" disabled=\"disabled\">" .
   220         $this->assertHTMLEquals($expected, $html);
   226         $r = $this->getDefaultRenderer();
   229         $html = $this->normalizeHTML(
$r->render(
$b));
   231         $expected = 
"<button type=\"button\" class=\"close\" aria-label=\"close\">" .
   232             "   <span aria-hidden=\"true\">×</span>" .
   234         $this->assertEquals($expected, $html);
   240         $r = $this->getDefaultRenderer();
   243         $html = $this->normalizeHTML(
$r->render(
$b));
   245         $expected = 
"<button type=\"button\" class=\"minimize\" aria-label=\"minimize\">" .
   246             "   <span aria-hidden=\"true\">−</span>" .
   248         $this->assertEquals($expected, $html);
   256         $ln = 
"http://www.ilias.de";
   258         $r = $this->getDefaultRenderer();
   260         $b = 
$f->$factory_method(
"label", $ln)
   261                ->withOnLoadCode(
function (
$id) use (&$ids): 
string {
   266         $html = $this->normalizeHTML(
$r->render(
$b));
   268         $this->assertCount(1, $ids);
   271         $css_classes = self::$canonical_css_classes[$factory_method];
   272         $expected = 
"<button class=\"$css_classes\" data-action=\"$ln\" id=\"$id\">" .
   275         $this->assertHTMLEquals($expected, $html);
   281         $r = $this->getDefaultRenderer();
   284                ->withOnLoadCode(
function (
$id) use (&$ids): 
string {
   289         $html = $this->normalizeHTML(
$r->render(
$b));
   291         $this->assertCount(1, $ids);
   294         $expected = 
"<button type=\"button\" class=\"close\" aria-label=\"close\" id=\"$id\">" .
   295             "   <span aria-hidden=\"true\">×</span>" .
   297         $this->assertEquals($expected, $html);
   303         $b = 
$f->tag(
'tag', 
'#');
   305         $this->expectException(TypeError::class);
   306         $b->withRelevance(0);
   308         $this->expectException(TypeError::class);
   309         $b->withRelevance(
'notsoimportant');
   314         $expectations = array(
   315             '<button class="btn btn-tag btn-tag-relevance-verylow" data-action="#" id="id_1">tag</button>',
   316             '<button class="btn btn-tag btn-tag-relevance-low" data-action="#" id="id_2">tag</button>',
   317             '<button class="btn btn-tag btn-tag-relevance-middle" data-action="#" id="id_3">tag</button>',
   318             '<button class="btn btn-tag btn-tag-relevance-high" data-action="#" id="id_4">tag</button>',
   319             '<button class="btn btn-tag btn-tag-relevance-veryhigh" data-action="#" id="id_5">tag</button>'   323         $r = $this->getDefaultRenderer();
   324         $t = 
$f->tag(
'tag', 
'#');
   325         $possible_relevances = array(
   332         foreach ($possible_relevances as $w) {
   333             $html = $this->normalizeHTML(
   334                 $r->render($t->withRelevance($w))
   336             $expected = $expectations[array_search($w, $possible_relevances)];
   337             $this->assertEquals($expected, $html);
   344         $r = $this->getDefaultRenderer();
   345         $df = new \ILIAS\Data\Factory();
   347         $bgcol = $df->color(
'#00ff00');
   349         $b = 
$f->tag(
'tag', 
'#')
   350                ->withBackgroundColor($bgcol);
   351         $html = $this->normalizeHTML(
$r->render(
$b));
   352         $expected = 
'<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #000000;" data-action="#" id="id_1">tag</button>';
   353         $this->assertEquals($expected, $html);
   355         $fcol = $df->color(
'#ddd');
   356         $b = 
$b->withForegroundColor($fcol);
   357         $html = $this->normalizeHTML(
$r->render(
$b));
   358         $expected = 
'<button class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #dddddd;" data-action="#" id="id_2">tag</button>';
   359         $this->assertEquals($expected, $html);
   365         $r = $this->getDefaultRenderer();
   366         $df = new \ILIAS\Data\Factory();
   368         $classes = array(
'cl1', 
'cl2');
   369         $b = 
$f->tag(
'tag', 
'#')
   370                ->withClasses($classes);
   371         $this->assertEquals($classes, 
$b->getClasses());
   373         $html = $this->normalizeHTML(
$r->render(
$b));
   374         $expected = 
'<button class="btn btn-tag btn-tag-relevance-veryhigh cl1 cl2" data-action="#" id="id_1">tag</button>';
   375         $this->assertEquals($expected, $html);
   384         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de")->withAriaLabel(
"ariatext");
   385         $this->assertEquals(
"ariatext", 
$b->getAriaLabel());
   394         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de");
   396             $this->assertEquals(
false, 
$b->isEngageable());
   397             $b2 = 
$f->$factory_method(
"label", 
"http://www.ilias.de")->withEngagedState(
false);
   398             $this->assertEquals(
true, $b2->isEngageable());
   400             $this->assertTrue(self::NOT_APPLICABLE);
   410         $b = 
$f->$factory_method(
"label", 
"http://www.ilias.de");
   412             $b = 
$b->withEngagedState(
false);
   413             $this->assertEquals(
false, 
$b->isEngaged());
   414             $b2 = 
$f->$factory_method(
"label", 
"http://www.ilias.de")->withEngagedState(
true);
   415             $this->assertEquals(
true, $b2->isEngaged());
   417             $this->assertTrue(self::NOT_APPLICABLE);
   426         $ln = 
"http://www.ilias.de";
   428         $r = $this->getDefaultRenderer();
   429         $b = 
$f->$factory_method(
"label", $ln)->withAriaLabel(
"aria label text");
   430         $aria_label = 
$b->getAriaLabel();
   432         $html = $this->normalizeHTML(
$r->render(
$b));
   433         $css_classes = self::$canonical_css_classes[$factory_method];
   434         $expected = 
"<button class=\"$css_classes\" aria-label=\"$aria_label\" data-action=\"$ln\" id=\"id_1\">" .
   437         $this->assertHTMLEquals($expected, $html);
   445         $ln = 
"http://www.ilias.de";
   447         $r = $this->getDefaultRenderer();
   448         $b = 
$f->$factory_method(
"label", $ln);
   450             $b = 
$b->withEngagedState(
true);
   452             $html = $this->normalizeHTML(
$r->render(
$b));
   453             $css_classes = self::$canonical_css_classes[$factory_method];
   454             $css_classes .= 
' engaged';
   455             $expected = 
"<button class=\"$css_classes\" aria-pressed=\"true\" data-action=\"$ln\" id=\"id_1\">" .
   458             $this->assertHTMLEquals($expected, $html);
   460             $this->assertTrue(self::NOT_APPLICABLE);
   470         $signal = $this->createMock(
C\Signal::class);
   471         $button = 
$f->$factory_method(
"label", 
"http://www.example.com");
   472         $this->assertEquals(
"http://www.example.com", $button->getAction());
   474         $button = $button->withOnClick($signal);
   476         $this->assertEquals([$signal], $button->getAction());
   485         $signal1 = $this->createMock(
C\Signal::class);
   486         $signal2 = $this->createMock(
C\Signal::class);
   487         $button = 
$f->$factory_method(
"label", 
"http://www.example.com");
   489         $button = $button->withOnClick($signal1)->appendOnClick($signal2);
   491         $this->assertEquals([$signal1, $signal2], $button->getAction());
   499         $ln = 
"http://www.ilias.de";
   501         $signal = $this->createMock(Signal::class);
   502         $signal->method(
"__toString")
   503                ->willReturn(
"MOCK_SIGNAL");
   505         $b = 
$f->$factory_method(
"label", $ln)
   506                ->withOnClick($signal);
   507         $r = $this->getDefaultRenderer();
   509         $html = $this->normalizeHTML(
$r->render(
$b));
   511         $css_classes = self::$canonical_css_classes[$factory_method];
   512         $expected = 
"<button class=\"$css_classes\" id=\"id_1\">" .
   515         $this->assertHTMLEquals($expected, $html);
   523         foreach ([
"primary", 
"standard"] as $method) {
   524             $ln = 
"http://www.ilias.de";
   526             $r = $this->getDefaultRenderer();
   527             $b = 
$f->$method(
"label", $ln)
   528                    ->withLoadingAnimationOnClick(
true);
   530             $html = $this->normalizeHTML(
$r->render(
$b));
   532             $css_classes = self::$canonical_css_classes[$method];
   533             $expected = 
"<button class=\"$css_classes\" data-action=\"$ln\" id=\"id_1\">" .
   536             $this->assertHTMLEquals($expected, $html);
   546         $r = $this->getDefaultRenderer();
   547         $ln = 
"http://www.ilias.de";
   550             $f->$factory_method(
"label", $ln)
   551                ->withHelpTopics(
new Help\
Topic(
"a"), 
new Help\
Topic(
"b"));
   553         $css_classes = self::$canonical_css_classes[$factory_method];
   555             "<div class=\"c-tooltip__container\">" .
   556                  "<button class=\"$css_classes\" aria-describedby=\"id_2\" data-action=\"$ln\" id=\"id_1\" >" .
   559                 "<div id=\"id_2\" role=\"tooltip\" class=\"c-tooltip c-tooltip--hidden\">" .
   560                     "<p>tooltip: a</p>" .
   561                     "<p>tooltip: b</p>" .
   565         $html = $this->normalizeHTML(
$r->render($button));
   566         $this->assertHTMLEquals($expected, $html);
   579         $signal = $this->createMock(
C\Signal::class);
   581         $button = 
$f->$factory_method(
"label", $signal);
   583         $this->assertEquals([$signal], $button->getAction());
   599         $r = $this->getDefaultRenderer();
   600         $glyph = 
new Glyph(
C\Symbol\
Glyph\Glyph::LIKE, 
'The Glyph Label');
   601         $button = 
$f->standard(
'The Button Label', 
'')
   602             ->withSymbol($glyph);
   605         $this->assertStringContainsString(
   606             'aria-label="The Glyph Label"',
   611         $expected = $this->brutallyTrimHTML(
   613             <button class="btn btn-default" data-action="">   614                 <span class="glyph" role="img">   615                     <span class="glyphicon il-glyphicon-like" aria-hidden="true"></span>   620         $html = $this->brutallyTrimHTML(
$r->render($button));
   621         $this->assertHTMLEquals($expected, $html);
 
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...
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...