ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
BulkyLinkTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
6require_once(__DIR__ . "/../../Base.php");
7
8use \ILIAS\UI\Component\Link as C;
9use \ILIAS\UI\Implementation\Component as I;
10
15{
16 public function setUp() : void
17 {
18 $this->factory = new I\Link\Factory();
19 $this->glyph = new I\Symbol\Glyph\Glyph("briefcase", "briefcase");
20 $this->icon = new I\Symbol\Icon\Standard("someExample", "Example", "small", false);
21 $this->target = new \ILIAS\Data\URI("http://www.ilias.de");
22 }
23
24 public function testImplementsInterfaces()
25 {
26 $link = $this->factory->bulky($this->glyph, "label", $this->target);
27 $this->assertInstanceOf(C\Bulky::class, $link);
28 $this->assertInstanceOf(C\Link::class, $link);
29 }
30
31 public function testWrongConstruction()
32 {
33 $this->expectException(\TypeError::class);
34 $link = $this->factory->bulky('wrong param', "label", $this->target);
35 }
36
37 public function testGetLabell()
38 {
39 $label = 'some label for the link';
40 $link = $this->factory->bulky($this->glyph, $label, $this->target);
41 $this->assertEquals($label, $link->getLabel());
42 }
43
44 public function testGetGlyphSymbol()
45 {
46 $link = $this->factory->bulky($this->glyph, "label", $this->target);
47 $this->assertEquals($this->glyph, $link->getSymbol());
48 $link = $this->factory->bulky($this->icon, "label", $this->target);
49 $this->assertEquals($this->icon, $link->getSymbol());
50 }
51
52 public function testRenderingGlyph()
53 {
54 $r = $this->getDefaultRenderer();
55 $b = $this->factory->bulky($this->glyph, "label", $this->target);
56
57 $expected = ''
58 . '<a class="il-link link-bulky" href="http://www.ilias.de">'
59 . ' <span class="glyph" aria-label="briefcase">'
60 . ' <span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span>'
61 . ' </span>'
62 . ' <span class="bulky-label">label</span>'
63 . '</a>';
64
65 $this->assertHTMLEquals(
66 $expected,
67 $r->render($b)
68 );
69 }
70
71 public function testRenderingIcon()
72 {
73 $r = $this->getDefaultRenderer();
74 $b = $this->factory->bulky($this->icon, "label", $this->target);
75
76 $expected = ''
77 . '<a class="il-link link-bulky" href="http://www.ilias.de">'
78 . ' <div class="icon someExample small" aria-label="Example"></div>'
79 . ' <span class="bulky-label">label</span>'
80 . '</a>';
81
82 $this->assertHTMLEquals(
83 $expected,
84 $r->render($b)
85 );
86 }
87 public function testRenderingWithId()
88 {
89 $r = $this->getDefaultRenderer();
90 $b = $this->factory->bulky($this->icon, "label", $this->target)
91 ->withAdditionalOnloadCode(function ($id) {
92 return '';
93 });
94
95 $expected = ''
96 . '<a class="il-link link-bulky" href="http://www.ilias.de" id="id_1">'
97 . ' <div class="icon someExample small" aria-label="Example"></div>'
98 . ' <span class="bulky-label">label</span>'
99 . '</a>';
100
101 $this->assertHTMLEquals(
102 $expected,
103 $r->render($b)
104 );
105 }
106}
Testing behavior of the Bulky Link.
An exception for terminatinating execution or to throw for unit testing.
Provides common functionality for UI tests.
Definition: Base.php:225
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268