19 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../../../vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../Base.php");
35 return new I\Link\Factory();
42 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Link\\Factory",
$f);
43 $this->assertInstanceOf(
44 "ILIAS\\UI\\Component\\Link\\Standard",
45 $f->standard(
"label",
"http://www.ilias.de")
52 $c =
$f->standard(
"label",
"http://www.ilias.de");
54 $this->assertEquals(
"label",
$c->getLabel());
60 $c =
$f->standard(
"label",
"http://www.ilias.de");
62 $this->assertEquals(
"http://www.ilias.de",
$c->getAction());
68 $r = $this->getDefaultRenderer();
70 $c =
$f->standard(
"label",
"http://www.ilias.de");
72 $html =
$r->render(
$c);
75 '<a href="http://www.ilias.de">label</a>';
77 $this->assertHTMLEquals($expected_html, $html);
83 $r = $this->getDefaultRenderer();
85 $c =
$f->standard(
"label",
"http://www.ilias.de")->withOpenInNewViewport(
true);
87 $html =
$r->render(
$c);
90 '<a href="http://www.ilias.de" target="_blank" rel="noopener">label</a>';
92 $this->assertHTMLEquals($expected_html, $html);
97 $language = $this->getMockBuilder(LanguageTag::class)->getMock();
98 $language->method(
'__toString')->willReturn(
'en');
99 $reference = $this->getMockBuilder(LanguageTag::class)->getMock();
100 $reference->method(
'__toString')->willReturn(
'fr');
103 $r = $this->getDefaultRenderer();
105 $c =
$f->standard(
"label",
"http://www.ilias.de")
106 ->withContentLanguage($language)
107 ->withLanguageOfReferencedContent($reference);
109 $html =
$r->render(
$c);
112 '<a lang="en" hreflang="fr" href="http://www.ilias.de">label</a>';
114 $this->assertHTMLEquals($expected_html, $html);
120 $r = $this->getDefaultRenderer();
121 $c =
$f->standard(
"label",
"http://www.ilias.de")
122 ->withHelpTopics(
new \
ILIAS\
UI\Help\Topic(
"a"));
124 $html =
$r->render(
$c);
127 .
'<div class="c-tooltip__container">' 128 .
'<a href="http://www.ilias.de" id="id_2" aria-describedby="id_1">label</a>' 129 .
'<div id="id_1" role="tooltip" class="c-tooltip c-tooltip--hidden"><p>tooltip: a</p></div>' 132 $this->assertHTMLEquals($expected_html, $html);
138 $r = $this->getDefaultRenderer();
139 $c =
$f->standard(
"label",
"http://www.ilias.de")
140 ->withAdditionalRelationshipToReferencedResource(Relationship::LICENSE)
141 ->withAdditionalRelationshipToReferencedResource(Relationship::NOOPENER);
144 '<a href="http://www.ilias.de" rel="license noopener">label</a>';
146 $html =
$r->render(
$c);
147 $this->assertHTMLEquals($expected_html, $html);
153 $r = $this->getDefaultRenderer();
154 $c =
$f->standard(
"label",
"http://www.ilias.de")
155 ->withAdditionalRelationshipToReferencedResource(Relationship::LICENSE)
156 ->withAdditionalRelationshipToReferencedResource(Relationship::NOOPENER)
157 ->withAdditionalRelationshipToReferencedResource(Relationship::LICENSE);
160 '<a href="http://www.ilias.de" rel="license noopener">label</a>';
162 $html =
$r->render(
$c);
163 $this->assertHTMLEquals($expected_html, $html);
169 $r = $this->getDefaultRenderer();
170 $c =
$f->standard(
"label",
"http://www.ilias.de")
171 ->withDisabled(
true);
173 $expected_html =
'<a aria-disabled="true">label</a>';
174 $this->assertHTMLEquals($expected_html,
$r->render(
$c));
Interface Observer Contains several chained tasks and infos about them.
testLinkRenderWithDisabled()
testRenderWithHelpTopic()
testRenderWithNewViewport()
Test on link implementation.
testImplementsFactoryInterface()
testRenderWithDuplicateRelationship()
testRenderWithRelationships()
Relationship
Note that not all valid values of the rel-attribute of anchor tags are included here (see https://htm...