5require_once(
"libs/composer/vendor/autoload.php");
 
    6require_once(__DIR__.
"/../../Base.php");
 
    8use \ILIAS\UI\Component as 
C;
 
   15                return new \ILIAS\UI\Implementation\Component\Glyph\Factory();
 
   19                return new \ILIAS\UI\Implementation\Component\Counter\Factory();
 
   23                ( 
C\Glyph\Glyph::SETTINGS                       => 
"glyphicon glyphicon-cog" 
   24                , 
C\Glyph\Glyph::EXPAND                         => 
"glyphicon glyphicon-triangle-right" 
   25                , 
C\Glyph\Glyph::COLLAPSE                       => 
"glyphicon glyphicon-triangle-bottom" 
   26                , 
C\Glyph\Glyph::ADD                            => 
"glyphicon glyphicon-plus-sign" 
   27                , 
C\Glyph\Glyph::REMOVE                         => 
"glyphicon glyphicon-minus-sign" 
   28                , 
C\Glyph\Glyph::UP                                     => 
"glyphicon glyphicon-circle-arrow-up" 
   29                , 
C\Glyph\Glyph::DOWN                           => 
"glyphicon glyphicon-circle-arrow-down" 
   30                , 
C\Glyph\Glyph::BACK                           => 
"glyphicon glyphicon-chevron-left" 
   31                , 
C\Glyph\Glyph::NEXT                           => 
"glyphicon glyphicon-chevron-right" 
   32                , 
C\Glyph\Glyph::SORT_ASCENDING         => 
"glyphicon glyphicon-arrow-up" 
   33                , 
C\Glyph\Glyph::SORT_DESCENDING        => 
"glyphicon glyphicon-arrow-down" 
   34                , 
C\Glyph\Glyph::USER                           => 
"glyphicon glyphicon-user" 
   35                , 
C\Glyph\Glyph::MAIL                           => 
"glyphicon glyphicon-envelope" 
   36                , 
C\Glyph\Glyph::NOTIFICATION           => 
"glyphicon glyphicon-bell" 
   37                , 
C\Glyph\Glyph::TAG                            => 
"glyphicon glyphicon-tag" 
   38                , 
C\Glyph\Glyph::NOTE                           => 
"glyphicon glyphicon-pushpin" 
   39                , 
C\Glyph\Glyph::COMMENT                        => 
"glyphicon glyphicon-comment" 
   43                  C\Glyph\Glyph::SETTINGS                       => 
"settings" 
   44                , 
C\Glyph\Glyph::EXPAND                         => 
"expand_content" 
   45                , 
C\Glyph\Glyph::COLLAPSE                       => 
"collapse_content" 
   46                , 
C\Glyph\Glyph::ADD                            => 
"add" 
   47                , 
C\Glyph\Glyph::REMOVE                         => 
"remove" 
   48                , 
C\Glyph\Glyph::UP                                     => 
"up" 
   49                , 
C\Glyph\Glyph::DOWN                           => 
"down" 
   50                , 
C\Glyph\Glyph::BACK                           => 
"back" 
   51                , 
C\Glyph\Glyph::NEXT                           => 
"next" 
   52                , 
C\Glyph\Glyph::SORT_ASCENDING         => 
"sort_ascending" 
   53                , 
C\Glyph\Glyph::SORT_DESCENDING        => 
"sort_descending" 
   54                , 
C\Glyph\Glyph::USER                           => 
"show_who_is_online" 
   55                , 
C\Glyph\Glyph::MAIL                           => 
"mail" 
   56                , 
C\Glyph\Glyph::NOTIFICATION           => 
"notifications" 
   57                , 
C\Glyph\Glyph::TAG                            => 
"tags" 
   58                , 
C\Glyph\Glyph::NOTE                           => 
"notes" 
   59                , 
C\Glyph\Glyph::COMMENT                        => 
"comments" 
   68                $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Glyph\\Factory", $f);
 
   69                $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Glyph\\Glyph", $f->$factory_method(
"http://www.ilias.de"));
 
   77                $g = $f->$factory_method();
 
   79                $this->assertNotNull($g);
 
   80                $this->assertEquals($factory_method, $g->getType());
 
   88                $g = $f->$factory_method(
"http://www.ilias.de");
 
   90                $this->assertNotNull($g);
 
   91                $this->assertEquals(
"http://www.ilias.de", $g->getAction());
 
   99                $g = $f->$factory_method();
 
  101                $this->assertNotNull($g);
 
  102                $this->assertEquals(
null, $g->getAction());
 
  114                $g2 = $g->withHighlight();
 
  116                $this->assertFalse($g->isHighlighted());
 
  117                $this->assertTrue($g2->isHighlighted());
 
  125                $g = $f->$factory_method();
 
  127                $this->assertCount(0, $g->getCounters());
 
  141                                $cf->$counter_type($number)
 
  144                $counters = $g->getCounters();
 
  145                $this->assertCount(1, $counters);
 
  147                $this->assertEquals($counter_type, $c->getType());
 
  148                $this->assertEquals($number, $c->getNumber());
 
  160                                $cf->status($number_s)
 
  163                                $cf->novelty($number_n)
 
  166                $counters = $g->getCounters();
 
  167                $this->assertCount(2, $counters);
 
  168                $vals = array_map(
function($c) {
 
  169                        return array($c->getType(), $c->getNumber());
 
  171                $this->assertContains(array(
"status", $number_s), $vals);
 
  172                $this->assertContains(array(
"novelty", $number_n), $vals);
 
  185                                $cf->status($number_s)
 
  188                                $cf->novelty($number_n1)
 
  191                                $cf->novelty($number_n2)
 
  194                $counters = $g->getCounters();
 
  195                $this->assertCount(2, $counters);
 
  196                $vals = array_map(
function($c) {
 
  197                        return array($c->getType(), $c->getNumber());
 
  199                $this->assertContains(array(
"status", $number_s), $vals);
 
  200                $this->assertContains(array(
"novelty", $number_n2), $vals);
 
  213                $counters = $g->getCounters();
 
  214                $this->assertCount(0, $counters);
 
  219                        new \ILIAS\UI\Implementation\Component\Glyph\Glyph(
"FOO", 
"http://www.ilias.de");
 
  220                        $this->assertFalse(
"We should not get here");
 
  222                catch (\InvalidArgumentException $e) {}
 
  227                        ( array(
C\Glyph\Glyph::SETTINGS)
 
  228                        , array(
C\Glyph\Glyph::EXPAND)
 
  229                        , array(
C\Glyph\Glyph::COLLAPSE)
 
  230                        , array(
C\Glyph\Glyph::ADD)
 
  231                        , array(
C\Glyph\Glyph::REMOVE)
 
  232                        , array(
C\Glyph\Glyph::UP)
 
  233                        , array(
C\Glyph\Glyph::DOWN)
 
  234                        , array(
C\Glyph\Glyph::BACK)
 
  235                        , array(
C\Glyph\Glyph::NEXT)
 
  236                        , array(
C\Glyph\Glyph::SORT_ASCENDING)
 
  237                        , array(
C\Glyph\Glyph::SORT_DESCENDING)
 
  238                        , array(
C\Glyph\Glyph::USER)
 
  239                        , array(
C\Glyph\Glyph::MAIL)
 
  240                        , array(
C\Glyph\Glyph::NOTIFICATION)
 
  241                        , array(
C\Glyph\Glyph::TAG)
 
  242                        , array(
C\Glyph\Glyph::NOTE)
 
  243                        , array(
C\Glyph\Glyph::COMMENT)
 
  260                $c = $f->$type(
"http://www.ilias.de");
 
  264                $css_classes = self::$canonical_css_classes[$type];
 
  265                $aria_label = self::$aria_labels[$type];
 
  267                $expected = 
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
 
  268                $this->assertEquals($expected, 
$html);
 
  278                $c = $fg->mail(
"http://www.ilias.de")->withCounter($fc->$type(42));
 
  282                $css_classes = self::$canonical_css_classes[C\Glyph\Glyph::MAIL];
 
  283                $aria_label = self::$aria_labels[C\Glyph\Glyph::MAIL];
 
  285                $expected = 
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">".
 
  286                                        "<span class=\"$css_classes\" aria-hidden=\"true\"></span>".
 
  287                                        "<span class=\"badge badge-notify il-counter-$type\">42</span>".
 
  288                                        "<span class=\"il-counter-spacer\">42</span>".
 
  290                $this->assertEquals($expected, 
$html);
 
  297                $c = $fg->mail(
"http://www.ilias.de")
 
  298                                ->withCounter($fc->novelty(42))
 
  299                                ->withCounter($fc->status(7));
 
  303                $css_classes = self::$canonical_css_classes[C\Glyph\Glyph::MAIL];
 
  304                $aria_label = self::$aria_labels[C\Glyph\Glyph::MAIL];
 
  305                $expected = 
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\">".
 
  306                                        "<span class=\"$css_classes\" aria-hidden=\"true\"></span>".
 
  307                                        "<span class=\"badge badge-notify il-counter-status\">7</span>".
 
  308                                        "<span class=\"badge badge-notify il-counter-novelty\">42</span>".
 
  309                                        "<span class=\"il-counter-spacer\">42</span>".
 
  311                $this->assertEquals($expected, 
$html);
 
  319                        $r->render($f->status(0), $this->getDefaultRenderer());
 
  320                        $this->assertFalse(
"This should not happen!");
 
  332                $c = $f->$type(
"http://www.ilias.de")
 
  333                                ->withOnLoadCode(
function($id) use (&$ids) {
 
  340                $this->assertCount(1, $ids);
 
  342                $css_classes = self::$canonical_css_classes[$type];
 
  343                $aria_label = self::$aria_labels[$type];
 
  346                $expected = 
"<a class=\"glyph\" href=\"http://www.ilias.de\" aria-label=\"$aria_label\" id=\"$id\"><span class=\"$css_classes\" aria-hidden=\"true\"></span></a>";
 
  347                $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_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_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.