5require_once(
"libs/composer/vendor/autoload.php");
 
    6require_once(__DIR__ . 
"/../../Base.php");
 
    8use \ILIAS\UI\Component as 
C;
 
   17        return new \ILIAS\UI\Implementation\Component\Glyph\Factory();
 
   22        return new \ILIAS\UI\Implementation\Component\Counter\Factory();
 
   26        , 
C\Glyph\Glyph::EXPAND => 
"glyphicon glyphicon-triangle-right" 
   27        , 
C\Glyph\Glyph::COLLAPSE => 
"glyphicon glyphicon-triangle-bottom" 
   28        , 
C\Glyph\Glyph::ADD => 
"glyphicon glyphicon-plus-sign" 
   29        , 
C\Glyph\Glyph::REMOVE => 
"glyphicon glyphicon-minus-sign" 
   30        , 
C\Glyph\Glyph::UP => 
"glyphicon glyphicon-circle-arrow-up" 
   31        , 
C\Glyph\Glyph::DOWN => 
"glyphicon glyphicon-circle-arrow-down" 
   32        , 
C\Glyph\Glyph::BACK => 
"glyphicon glyphicon-chevron-left" 
   33        , 
C\Glyph\Glyph::NEXT => 
"glyphicon glyphicon-chevron-right" 
   34        , 
C\Glyph\Glyph::SORT_ASCENDING => 
"glyphicon glyphicon-arrow-up" 
   35        , 
C\Glyph\Glyph::SORT_DESCENDING => 
"glyphicon glyphicon-arrow-down" 
   36        , 
C\Glyph\Glyph::USER => 
"glyphicon glyphicon-user" 
   37        , 
C\Glyph\Glyph::MAIL => 
"glyphicon glyphicon-envelope" 
   38        , 
C\Glyph\Glyph::NOTIFICATION => 
"glyphicon glyphicon-bell" 
   39        , 
C\Glyph\Glyph::TAG => 
"glyphicon glyphicon-tag" 
   40        , 
C\Glyph\Glyph::NOTE => 
"glyphicon glyphicon-pushpin" 
   41        , 
C\Glyph\Glyph::COMMENT => 
"glyphicon glyphicon-comment" 
   42        , 
C\Glyph\Glyph::LIKE => 
"glyphicon il-glyphicon-like" 
   43        , 
C\Glyph\Glyph::LOVE => 
"glyphicon il-glyphicon-love" 
   44        , 
C\Glyph\Glyph::DISLIKE => 
"glyphicon il-glyphicon-dislike" 
   45        , 
C\Glyph\Glyph::LAUGH => 
"glyphicon il-glyphicon-laugh" 
   46        , 
C\Glyph\Glyph::ASTOUNDED => 
"glyphicon il-glyphicon-astounded" 
   47        , 
C\Glyph\Glyph::SAD => 
"glyphicon il-glyphicon-sad" 
   48        , 
C\Glyph\Glyph::ANGRY => 
"glyphicon il-glyphicon-angry" 
   49        , 
C\Glyph\Glyph::ATTACHMENT => 
"glyphicon glyphicon-paperclip" 
   50        , 
C\Glyph\Glyph::RESET => 
"glyphicon glyphicon-repeat" 
   51        , 
C\Glyph\Glyph::APPLY => 
"glyphicon glyphicon-ok" 
   55          C\Glyph\Glyph::SETTINGS => 
"settings" 
   56        , 
C\Glyph\Glyph::EXPAND => 
"expand_content" 
   57        , 
C\Glyph\Glyph::COLLAPSE => 
"collapse_content" 
   58        , 
C\Glyph\Glyph::ADD => 
"add" 
   59        , 
C\Glyph\Glyph::REMOVE => 
"remove" 
   60        , 
C\Glyph\Glyph::UP => 
"up" 
   61        , 
C\Glyph\Glyph::DOWN => 
"down" 
   62        , 
C\Glyph\Glyph::BACK => 
"back" 
   63        , 
C\Glyph\Glyph::NEXT => 
"next" 
   64        , 
C\Glyph\Glyph::SORT_ASCENDING => 
"sort_ascending" 
   65        , 
C\Glyph\Glyph::SORT_DESCENDING => 
"sort_descending" 
   66        , 
C\Glyph\Glyph::USER => 
"show_who_is_online" 
   67        , 
C\Glyph\Glyph::MAIL => 
"mail" 
   68        , 
C\Glyph\Glyph::NOTIFICATION => 
"notifications" 
   69        , 
C\Glyph\Glyph::TAG => 
"tags" 
   70        , 
C\Glyph\Glyph::NOTE => 
"notes" 
   71        , 
C\Glyph\Glyph::COMMENT => 
"comments" 
   72        , 
C\Glyph\Glyph::LIKE => 
"like" 
   73        , 
C\Glyph\Glyph::LOVE => 
"love" 
   74        , 
C\Glyph\Glyph::DISLIKE => 
"dislike" 
   75        , 
C\Glyph\Glyph::LAUGH => 
"laugh" 
   76        , 
C\Glyph\Glyph::ASTOUNDED => 
"astounded" 
   77        , 
C\Glyph\Glyph::SAD => 
"sad" 
   78        , 
C\Glyph\Glyph::ANGRY => 
"angry" 
   79        , 
C\Glyph\Glyph::ATTACHMENT => 
"attachment" 
   80        , 
C\Glyph\Glyph::RESET => 
"reset" 
   81        , 
C\Glyph\Glyph::APPLY => 
"apply" 
   91        $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Glyph\\Factory", 
$f);
 
   92        $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Glyph\\Glyph", 
$f->$factory_method(
"http://www.ilias.de"));
 
  101        $g = 
$f->$factory_method();
 
  103        $this->assertNotNull($g);
 
  104        $this->assertEquals($factory_method, $g->getType());
 
  113        $g = 
$f->$factory_method(
"http://www.ilias.de");
 
  115        $this->assertNotNull($g);
 
  116        $this->assertEquals(
"http://www.ilias.de", $g->getAction());
 
  125        $g = 
$f->$factory_method();
 
  127        $this->assertNotNull($g);
 
  128        $this->assertEquals(
null, $g->getAction());
 
  137        $g = 
$f->$factory_method();
 
  138        $g2 = 
$f->$factory_method()->withUnavailableAction();
 
  140        $this->assertTrue($g->isActive());
 
  141        $this->assertFalse($g2->isActive());
 
  154        $g2 = $g->withHighlight();
 
  156        $this->assertFalse($g->isHighlighted());
 
  157        $this->assertTrue($g2->isHighlighted());
 
  166        $g = 
$f->$factory_method();
 
  168        $this->assertCount(0, $g->getCounters());
 
  183                $cf->$counter_type($number)
 
  186        $counters = $g->getCounters();
 
  187        $this->assertCount(1, $counters);
 
  189        $this->assertEquals($counter_type, 
$c->getType());
 
  190        $this->assertEquals($number, 
$c->getNumber());
 
  203                $cf->status($number_s)
 
  206                $cf->novelty($number_n)
 
  209        $counters = $g->getCounters();
 
  210        $this->assertCount(2, $counters);
 
  211        $vals = array_map(
function (
$c) {
 
  212            return array(
$c->getType(), 
$c->getNumber());
 
  214        $this->assertContains(array(
"status", $number_s), $vals);
 
  215        $this->assertContains(array(
"novelty", $number_n), $vals);
 
  229                $cf->status($number_s)
 
  232                $cf->novelty($number_n1)
 
  235                $cf->novelty($number_n2)
 
  238        $counters = $g->getCounters();
 
  239        $this->assertCount(2, $counters);
 
  240        $vals = array_map(
function (
$c) {
 
  241            return array(
$c->getType(), 
$c->getNumber());
 
  243        $this->assertContains(array(
"status", $number_s), $vals);
 
  244        $this->assertContains(array(
"novelty", $number_n2), $vals);
 
  258        $counters = $g->getCounters();
 
  259        $this->assertCount(0, $counters);
 
  265            new \ILIAS\UI\Implementation\Component\Glyph\Glyph(
"FOO", 
"http://www.ilias.de");
 
  266            $this->assertFalse(
"We should not get here");
 
  267        } 
catch (\InvalidArgumentException $e) {
 
  273        return array( array(
C\Glyph\Glyph::SETTINGS)
 
  274            , array(
C\Glyph\Glyph::EXPAND)
 
  275            , array(
C\Glyph\Glyph::COLLAPSE)
 
  276            , array(
C\Glyph\Glyph::ADD)
 
  277            , array(
C\Glyph\Glyph::REMOVE)
 
  278            , array(
C\Glyph\Glyph::UP)
 
  279            , array(
C\Glyph\Glyph::DOWN)
 
  280            , array(
C\Glyph\Glyph::BACK)
 
  281            , array(
C\Glyph\Glyph::NEXT)
 
  282            , array(
C\Glyph\Glyph::SORT_ASCENDING)
 
  283            , array(
C\Glyph\Glyph::SORT_DESCENDING)
 
  284            , array(
C\Glyph\Glyph::USER)
 
  285            , array(
C\Glyph\Glyph::MAIL)
 
  286            , array(
C\Glyph\Glyph::NOTIFICATION)
 
  287            , array(
C\Glyph\Glyph::TAG)
 
  288            , array(
C\Glyph\Glyph::NOTE)
 
  289            , array(
C\Glyph\Glyph::COMMENT)
 
  290            , array(
C\Glyph\Glyph::LIKE)
 
  291            , array(
C\Glyph\Glyph::LOVE)
 
  292            , array(
C\Glyph\Glyph::DISLIKE)
 
  293            , array(
C\Glyph\Glyph::LAUGH)
 
  294            , array(
C\Glyph\Glyph::ASTOUNDED)
 
  295            , array(
C\Glyph\Glyph::SAD)
 
  296            , array(
C\Glyph\Glyph::ANGRY)
 
  297            , array(
C\Glyph\Glyph::ATTACHMENT)
 
  298            , array(
C\Glyph\Glyph::RESET)
 
  299            , array(
C\Glyph\Glyph::APPLY)
 
  305        return array( array(
"status")
 
  317        $c = 
$f->$type(
"http://www.ilias.de");
 
  321        $css_classes = self::$canonical_css_classes[
$type];
 
  322        $aria_label = self::$aria_labels[
$type];
 
  324        $expected = 
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
 
  325        $this->assertEquals($expected, 
$html);
 
  335        $c = 
$f->$type(
"http://www.ilias.de")->withUnavailableAction();
 
  339        $css_classes = self::$canonical_css_classes[
$type];
 
  340        $aria_label = self::$aria_labels[
$type];
 
  342        $expected = 
"<a class=\"glyph disabled\" aria-label=\"$aria_label\" " .
 
  343                    "aria-disabled=\"true\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
 
  344        $this->assertEquals($expected, 
$html);
 
  355        $c = $fg->mail(
"http://www.ilias.de")->withCounter($fc->$type(42));
 
  359        $css_classes = self::$canonical_css_classes[C\Glyph\Glyph::MAIL];
 
  360        $aria_label = self::$aria_labels[C\Glyph\Glyph::MAIL];
 
  362        $expected = 
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">" .
 
  363                    "<span class=\"$css_classes\" aria-hidden=\"true\"></span>" .
 
  364                    "<span class=\"badge badge-notify il-counter-$type\">42</span>" .
 
  365                    "<span class=\"il-counter-spacer\">42</span>" .
 
  367        $this->assertEquals($expected, 
$html);
 
  375        $c = $fg->mail(
"http://www.ilias.de")
 
  376                ->withCounter($fc->novelty(42))
 
  377                ->withCounter($fc->status(7));
 
  381        $css_classes = self::$canonical_css_classes[C\Glyph\Glyph::MAIL];
 
  382        $aria_label = self::$aria_labels[C\Glyph\Glyph::MAIL];
 
  383        $expected = 
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">" .
 
  384                    "<span class=\"$css_classes\" aria-hidden=\"true\"></span>" .
 
  385                    "<span class=\"badge badge-notify il-counter-status\">7</span>" .
 
  386                    "<span class=\"badge badge-notify il-counter-novelty\">42</span>" .
 
  387                    "<span class=\"il-counter-spacer\">42</span>" .
 
  389        $this->assertEquals($expected, 
$html);
 
  398            $r->render(
$f->status(0), $this->getDefaultRenderer());
 
  399            $this->assertFalse(
"This should not happen!");
 
  400        } 
catch (\LogicException $e) {
 
  412        $c = 
$f->$type(
"http://www.ilias.de")
 
  413                ->withOnLoadCode(
function (
$id) use (&$ids) {
 
  420        $this->assertCount(1, $ids);
 
  422        $css_classes = self::$canonical_css_classes[
$type];
 
  423        $aria_label = self::$aria_labels[
$type];
 
  426        $expected = 
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\" id=\"$id\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
 
  427        $this->assertEquals($expected, 
$html);
 
An exception for terminatinating execution or to throw for unit testing.
Test on glyph implementation.
test_dont_render_counter()
test_render_with_on_load_code($type)
@dataProvider glyph_type_provider
test_render_simple($type)
@dataProvider glyph_type_provider
test_render_with_unavailable_action($type)
@dataProvider glyph_type_provider
test_with_highlight($counter_type)
@dataProvider counter_type_provider
test_glyph_types($factory_method)
@dataProvider glyph_type_provider
static $canonical_css_classes
test_no_counter($factory_method)
@dataProvider glyph_type_provider
test_render_withTwoCounters()
test_with_unavailable_action($factory_method)
@dataProvider glyph_type_provider
test_one_counter($counter_type)
@dataProvider counter_type_provider
test_render_withCounter($type)
@dataProvider counter_type_provider
test_immutability_withCounter()
test_implements_factory_interface($factory_method)
@dataProvider glyph_type_provider
test_glyph_no_action($factory_method)
@dataProvider glyph_type_provider
test_glyph_action($factory_method)
@dataProvider glyph_type_provider
Provides common functionality for UI tests.
getDefaultRenderer(JavaScriptBinding $js_binding=null)
if(!array_key_exists('StateId', $_REQUEST)) $id