19 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../../../vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../Base.php");
36 protected I\Symbol\Glyph\Glyph
$glyph;
37 protected I\Symbol\Icon\Standard
$icon;
42 $this->
factory =
new I\Link\Factory();
43 $this->glyph =
new I\Symbol\Glyph\Glyph(
"briefcase",
"briefcase");
44 $this->icon =
new I\Symbol\Icon\Standard(
"someExample",
"Example",
"small",
false);
45 $this->target =
new Data\URI(
"http://www.ilias.de");
50 $link = $this->
factory->bulky($this->glyph,
"label", $this->target);
51 $this->assertInstanceOf(
C\Bulky::class, $link);
52 $this->assertInstanceOf(
C\Link::class, $link);
57 $this->expectException(\TypeError::class);
58 $this->
factory->bulky(
'wrong param',
"label", $this->target);
64 $b = $this->
factory->bulky($this->glyph,
"label", $this->target)
65 ->withAriaRole(
I\
Button\Bulky::MENUITEM);
66 $this->assertEquals(
"menuitem",
$b->getAriaRole());
68 $this->assertFalse(
"This should not happen");
75 $this->
factory->bulky($this->glyph,
"label", $this->target)
76 ->withAriaRole(
"loremipsum");
77 $this->assertFalse(
"This should not happen");
79 $this->assertTrue(
true);
85 $label =
'some label for the link';
86 $link = $this->
factory->bulky($this->glyph, $label, $this->target);
87 $this->assertEquals($label, $link->getLabel());
92 $link = $this->
factory->bulky($this->glyph,
"label", $this->target);
93 $this->assertEquals($this->glyph, $link->getSymbol());
94 $link = $this->
factory->bulky($this->icon,
"label", $this->target);
95 $this->assertEquals($this->icon, $link->getSymbol());
100 $plain =
"http://www.ilias.de";
101 $with_query = $plain .
"?query1=1";
102 $with_multi_query = $with_query .
"&query2=2";
103 $with_fragment = $plain .
"#fragment";
104 $with_multi_query_and_fragment_uri = $with_multi_query . $with_fragment;
106 $plain_uri =
new Data\URI($plain);
107 $with_query_uri =
new Data\URI($with_query);
108 $with_multi_query_uri =
new Data\URI($with_multi_query);
109 $with_fragment_uri =
new Data\URI($with_fragment);
110 $with_multi_query_and_fragment_uri =
new Data\URI($with_multi_query_and_fragment_uri);
112 $this->assertEquals($plain, $this->
factory->bulky($this->glyph,
"label", $plain_uri)->getAction());
113 $this->assertEquals($with_query, $this->
factory->bulky($this->glyph,
"label", $with_query_uri)->getAction());
114 $this->assertEquals($with_multi_query, $this->
factory->bulky($this->glyph,
"label", $with_multi_query_uri)->getAction());
115 $this->assertEquals($with_fragment_uri, $this->
factory->bulky($this->glyph,
"label", $with_fragment_uri)->getAction());
116 $this->assertEquals($with_multi_query_and_fragment_uri, $this->
factory->bulky($this->glyph,
"label", $with_multi_query_and_fragment_uri)->getAction());
121 $r = $this->getDefaultRenderer();
122 $b = $this->
factory->bulky($this->glyph,
"label", $this->target);
125 .
'<a class="il-link link-bulky" href="http://www.ilias.de">' 126 .
' <span class="glyph" role="img">' 127 .
' <span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span>' 129 .
' <span class="bulky-label">label</span>' 132 $this->assertHTMLEquals(
140 $r = $this->getDefaultRenderer();
141 $b = $this->
factory->bulky($this->icon,
"label", $this->target);
144 .
'<a class="il-link link-bulky" href="http://www.ilias.de">' 145 .
' <img class="icon someExample small" src="./assets/images/standard/icon_default.svg" alt=""/>' 146 .
' <span class="bulky-label">label</span>' 149 $this->assertHTMLEquals(
156 $r = $this->getDefaultRenderer();
157 $b = $this->
factory->bulky($this->icon,
"label", $this->target)
158 ->withAdditionalOnloadCode(
function (
$id) {
163 .
'<a class="il-link link-bulky" href="http://www.ilias.de" id="id_1">' 164 .
'<img class="icon someExample small" src="./assets/images/standard/icon_default.svg" alt=""/>' 165 .
' <span class="bulky-label">label</span>' 168 $this->assertHTMLEquals(
176 $r = $this->getDefaultRenderer();
177 $b = $this->
factory->bulky($this->icon,
"label", $this->target)
178 ->withAriaRole(
I\
Button\Bulky::MENUITEM);
181 .
'<a class="il-link link-bulky" href="http://www.ilias.de" role="menuitem">' 182 .
'<img class="icon someExample small" src="./assets/images/standard/icon_default.svg" alt=""/>' 183 .
' <span class="bulky-label">label</span>' 186 $this->assertHTMLEquals(
194 $r = $this->getDefaultRenderer();
195 $b = $this->
factory->bulky($this->icon,
"Example", $this->target)
196 ->withAriaRole(
I\
Button\Bulky::MENUITEM);
199 .
'<a class="il-link link-bulky" href="http://www.ilias.de" role="menuitem">' 200 .
'<img class="icon someExample small" src="./assets/images/standard/icon_default.svg" alt=""/>' 201 .
' <span class="bulky-label">Example</span>' 204 $this->assertHTMLEquals(
212 $language = $this->getMockBuilder(LanguageTag::class)->getMock();
213 $language->method(
'__toString')->willReturn(
'en');
214 $reference = $this->getMockBuilder(LanguageTag::class)->getMock();
215 $reference->method(
'__toString')->willReturn(
'fr');
217 $r = $this->getDefaultRenderer();
218 $b = $this->
factory->bulky($this->icon,
"label", $this->target)
219 ->withContentLanguage($language)
220 ->withLanguageOfReferencedContent($reference);
223 .
'<a lang="en" hreflang="fr" class="il-link link-bulky" href="http://www.ilias.de">' 224 .
'<img class="icon someExample small" src="./assets/images/standard/icon_default.svg" alt=""/>' 225 .
' <span class="bulky-label">label</span>' 228 $this->assertHTMLEquals(
236 $r = $this->getDefaultRenderer();
237 $b = $this->
factory->bulky($this->icon,
"label", $this->target)
238 ->withHelpTopics(
new \
ILIAS\
UI\Help\Topic(
"a"));
240 $html =
$r->render(
$b);
241 $expected_html = <<<EXP
242 <div
class=
"c-tooltip__container">
243 <a
class=
"il-link link-bulky" aria-describedby=
"id_1" href=
"http://www.ilias.de" id=
"id_2">
244 <img
class=
"icon someExample small" src=
"./assets/images/standard/icon_default.svg" alt=
"" />
245 <span
class=
"bulky-label">label</span>
247 <div
id=
"id_1" role=
"tooltip" class=
"c-tooltip c-tooltip--hidden"><p>tooltip: a</p></div>
251 $this->assertHTMLEquals($expected_html, $html);
256 $r = $this->getDefaultRenderer();
257 $b = $this->
factory->bulky($this->icon,
"label", $this->target)
258 ->withAdditionalRelationshipToReferencedResource(Relationship::LICENSE)
259 ->withAdditionalRelationshipToReferencedResource(Relationship::NOOPENER);
261 $expected_html = <<<EXP
262 <a
class=
"il-link link-bulky" href=
"http://www.ilias.de" rel=
"license noopener">
263 <img
class=
"icon someExample small" src=
"./assets/images/standard/icon_default.svg" alt=
""/>
264 <span
class=
"bulky-label">label</span>
268 $html =
$r->render(
$b);
269 $this->assertHTMLEquals($expected_html, $html);
274 $r = $this->getDefaultRenderer();
275 $b = $this->
factory->bulky($this->icon,
"label", $this->target)
276 ->withAdditionalRelationshipToReferencedResource(Relationship::LICENSE)
277 ->withAdditionalRelationshipToReferencedResource(Relationship::NOOPENER)
278 ->withAdditionalRelationshipToReferencedResource(Relationship::LICENSE);
280 $expected_html = <<<EXP
281 <a
class=
"il-link link-bulky" href=
"http://www.ilias.de" rel=
"license noopener">
282 <img
class=
"icon someExample small" src=
"./assets/images/standard/icon_default.svg" alt=
""/>
283 <span
class=
"bulky-label">label</span>
287 $html =
$r->render(
$b);
288 $this->assertHTMLEquals($expected_html, $html);
293 $r = $this->getDefaultRenderer();
294 $b = $this->
factory->bulky($this->icon,
"label", $this->target)
295 ->withDisabled(
true);
296 $expected_html = <<<EXP
297 <a
class=
"il-link link-bulky" aria-
disabled=
"true">
298 <img
class=
"icon someExample small" src=
"./assets/images/standard/icon_default.svg" alt=
""/>
299 <span
class=
"bulky-label">label</span>
302 $this->assertHTMLEquals($expected_html,
$r->render(
$b));
testRenderWithHelpTopic()
Interface Observer Contains several chained tasks and infos about them.
I Symbol Glyph Glyph $glyph
Testing behavior of the Bulky Link.
testBulkyLinkRenderWithDisabled()
testRenderWithAriaRoleMenuitem()
I Symbol Icon Standard $icon
testRenderWithLabelAndAltImageSame()
testRenderWithRelationships()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
testWithAriaRoleIncorrect()
testImplementsInterfaces()
Relationship
Note that not all valid values of the rel-attribute of anchor tags are included here (see https://htm...
testRenderWithDuplicateRelationship()