5require_once(__DIR__ . 
"/../../../../libs/composer/vendor/autoload.php");
 
    6require_once(__DIR__ . 
"/../../Base.php");
 
    8use \ILIAS\UI\Component as 
C;
 
   17        return new \ILIAS\UI\Implementation\Component\Button\Factory();
 
   21        , 
"primary"      =>      
"btn btn-default btn-primary" 
   22        , 
"shy"  =>      
"btn btn-link" 
   23        , 
"tag"  =>      
"btn btn-tag btn-tag-relevance-veryhigh" 
   27        , 
"primary"     => 
"ilSubmitInactive disabled" 
   28        , 
"shy" => 
"ilSubmitInactive disabled" 
   29        , 
"tag" => 
"btn-tag-inactive" 
   37        $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Button\\Factory", $f);
 
   38        $this->assertInstanceOf(
 
   39            "ILIAS\\UI\\Component\\Button\\Standard",
 
   40            $f->standard(
"label", 
"http://www.ilias.de")
 
   42        $this->assertInstanceOf(
 
   43            "ILIAS\\UI\\Component\\Button\\Primary",
 
   44            $f->primary(
"label", 
"http://www.ilias.de")
 
   46        $this->assertInstanceOf(
 
   47            "ILIAS\\UI\\Component\\Button\\Close",
 
   50        $this->assertInstanceOf(
 
   51            "ILIAS\\UI\\Component\\Button\\Shy",
 
   52            $f->shy(
"label", 
"http://www.ilias.de")
 
   63            $f->$factory_method($this, 
"http://www.ilias.de");
 
   64            $this->assertFalse(
"This should not happen");
 
   65        } 
catch (\InvalidArgumentException $e) {
 
   76            $f->$factory_method(
"label", $this);
 
   77            $this->assertFalse(
"This should not happen");
 
   78        } 
catch (\InvalidArgumentException $e) {
 
   88        $b = $f->$factory_method(
"label", 
"http://www.ilias.de");
 
   90        $this->assertEquals(
"label", $b->getLabel());
 
   99        $b = $f->$factory_method(
"label", 
"http://www.ilias.de");
 
  101        $b2 = $b->withLabel(
"label2");
 
  103        $this->assertEquals(
"label", $b->getLabel());
 
  104        $this->assertEquals(
"label2", $b2->getLabel());
 
  113        $b = $f->$factory_method(
"label", 
"http://www.ilias.de");
 
  115        $this->assertEquals(
"http://www.ilias.de", $b->getAction());
 
  124        $b = $f->$factory_method(
"label", 
"http://www.ilias.de");
 
  126        $this->assertTrue($b->isActive());
 
  135        $b = $f->$factory_method(
"label", 
"http://www.ilias.de")
 
  136                ->withUnavailableAction();
 
  138        $this->assertFalse($b->isActive());
 
  139        $this->assertEquals(
"http://www.ilias.de", $b->getAction());
 
  147        $ln = 
"http://www.ilias.de";
 
  149        $b = $f->$factory_method(
"label", $ln);
 
  154        $css_classes = self::$canonical_css_classes[$factory_method];
 
  155        $expected = 
"<a class=\"$css_classes\" href=\"$ln\" data-action=\"$ln\">" .
 
  166        $ln = 
"http://www.ilias.de";
 
  168        $b = $f->$factory_method(
"label", $ln)
 
  169                ->withUnavailableAction();
 
  174        $css_classes = self::$canonical_css_classes[$factory_method];
 
  175        $css_class_inactive = self::$canonical_css_inactivation_classes[$factory_method];
 
  176        $expected = 
"<a class=\"$css_classes $css_class_inactive\" data-action=\"$ln\">" .
 
  190        $expected = 
"<button type=\"button\" class=\"close\" data-dismiss=\"modal\">" .
 
  191                    "   <span aria-hidden=\"true\">×</span>" .
 
  192                    "   <span class=\"sr-only\">Close</span>" .
 
  194        $this->assertEquals($expected, 
$html);
 
  202        $ln = 
"http://www.ilias.de";
 
  206        $b = $f->$factory_method(
"label", $ln)
 
  207                ->withOnLoadCode(
function (
$id) use (&$ids) {
 
  214        $this->assertCount(1, $ids);
 
  217        $css_classes = self::$canonical_css_classes[$factory_method];
 
  218        $expected = 
"<a class=\"$css_classes\" href=\"$ln\" data-action=\"$ln\" id=\"$id\">" .
 
  230                ->withOnLoadCode(
function (
$id) use (&$ids) {
 
  237        $this->assertCount(1, $ids);
 
  240        $expected = 
"<button type=\"button\" class=\"close\" data-dismiss=\"modal\" id=\"$id\">" .
 
  241                    "   <span aria-hidden=\"true\">×</span>" .
 
  242                    "   <span class=\"sr-only\">Close</span>" .
 
  244        $this->assertEquals($expected, 
$html);
 
  250        $b = $f->tag(
'tag', 
'#');
 
  252            $b->withRelevance(0);
 
  253            $this->assertFalse(
"This should not happen");
 
  254        } 
catch (\InvalidArgumentException $e) {
 
  255            $this->assertTrue(
true);
 
  258            $b->withRelevance(
'notsoimportant');
 
  259            $this->assertFalse(
"This should not happen");
 
  260        } 
catch (\InvalidArgumentException $e) {
 
  261            $this->assertTrue(
true);
 
  267        $expectations = array(
 
  268            '<a class="btn btn-tag btn-tag-relevance-verylow" href="#" data-action="#">tag</a>',
 
  269            '<a class="btn btn-tag btn-tag-relevance-low" href="#" data-action="#">tag</a>',
 
  270            '<a class="btn btn-tag btn-tag-relevance-middle" href="#" data-action="#">tag</a>',
 
  271            '<a class="btn btn-tag btn-tag-relevance-high" href="#" data-action="#">tag</a>',
 
  272            '<a class="btn btn-tag btn-tag-relevance-veryhigh" href="#" data-action="#">tag</a>' 
  277        $t = $f->tag(
'tag', 
'#');
 
  278        $possible_relevances = array(
 
  285        foreach ($possible_relevances as 
$w) {
 
  287                $r->render(
$t->withRelevance($w))
 
  289            $expected = $expectations[array_search(
$w, $possible_relevances)];
 
  290            $this->assertEquals($expected, 
$html);
 
  298        $df = new \ILIAS\Data\Factory;
 
  300        $bgcol = $df->color(
'#00ff00');
 
  302        $b = $f->tag(
'tag', 
'#')
 
  303            ->withBackgroundColor($bgcol);
 
  305        $expected = 
'<a class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #000000;" href="#" data-action="#">tag</a>';
 
  306        $this->assertEquals($expected, 
$html);
 
  308        $fcol = $df->color(
'#ddd');
 
  309        $b = $b->withForegroundColor($fcol);
 
  311        $expected = 
'<a class="btn btn-tag btn-tag-relevance-veryhigh" style="background-color: #00ff00; color: #dddddd;" href="#" data-action="#">tag</a>';
 
  312        $this->assertEquals($expected, 
$html);
 
  319        $df = new \ILIAS\Data\Factory;
 
  321        $classes = array(
'cl1', 
'cl2');
 
  322        $b = $f->tag(
'tag', 
'#')
 
  323            ->withClasses($classes);
 
  324        $this->assertEquals($classes, $b->getClasses());
 
  327        $expected = 
'<a class="btn btn-tag btn-tag-relevance-veryhigh cl1 cl2" href="#" data-action="#">tag</a>';
 
  328        $this->assertEquals($expected, 
$html);
 
  336        $b = $f->$factory_method(
"label", 
"http://www.ilias.de")->withAriaLabel(
"ariatext");
 
  337        $this->assertEquals(
"ariatext", $b->getAriaLabel());
 
  346        $b = $f->$factory_method(
"label", 
"http://www.ilias.de");
 
  347        $this->assertEquals(
false, $b->isAriaChecked());
 
  348        $b2 = $f->$factory_method(
"label", 
"http://www.ilias.de")->withAriaChecked();
 
  349        $this->assertEquals(
true, $b2->isAriaChecked());
 
  359        if ($factory_method == 
"standard") {
 
  360            $ln = 
"http://www.ilias.de";
 
  363            $b = $f->$factory_method(
"label", $ln)->withAriaLabel(
"aria label text");
 
  364            $aria_label = $b->getAriaLabel();
 
  367            $css_classes = self::$canonical_css_classes[$factory_method];
 
  368            $expected = 
"<a class=\"$css_classes\" href=\"$ln\" aria-label=\"$aria_label\" data-action=\"$ln\">" .
 
  382        if ($factory_method == 
"standard") {
 
  383            $ln = 
"http://www.ilias.de";
 
  386            $b = $f->$factory_method(
"label", $ln)->withAriaChecked();
 
  389            $css_classes = self::$canonical_css_classes[$factory_method];
 
  390            $expected = 
"<a class=\"$css_classes\" href=\"$ln\" aria-checked=\"true\" data-action=\"$ln\">" .
 
  400        return array( array(
"standard")
 
An exception for terminatinating execution or to throw for unit testing.
Provides common functionality for UI tests.
assertHTMLEquals($expected_html_as_string, $html_as_string)
getDefaultRenderer(JavaScriptBinding $js_binding=null)
if(!array_key_exists('StateId', $_REQUEST)) $id