Skip to content

Commit f187dc3

Browse files
author
swiniker
authored
This changes the role-attribute in BulkyLinks for Menu-Items (ILIAS-eLearning#3737)
Fix for: https://mantis.ilias.de/view.php?id=31552
1 parent 26d9d83 commit f187dc3

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<a class="il-link link-bulky" href="{HREF}" <!-- BEGIN open_in_new_viewport --> target="_blank" rel="noopener"<!-- END open_in_new_viewport --><!-- BEGIN with_id --> id="{ID}"<!-- END with_id --> <!-- BEGIN with_aria_role --> aria-role="{ARIA_ROLE}"<!-- END with_aria_role --> >{SYMBOL}<span class="bulky-label">{LABEL}</span></a>
1+
<a class="il-link link-bulky" href="{HREF}" <!-- BEGIN open_in_new_viewport --> target="_blank" rel="noopener"<!-- END open_in_new_viewport --><!-- BEGIN with_id --> id="{ID}"<!-- END with_id --> <!-- BEGIN with_aria_role --> role="{ARIA_ROLE}"<!-- END with_aria_role --> >{SYMBOL}<span class="bulky-label">{LABEL}</span></a>

tests/UI/Component/Link/BulkyLinkTest.php

+40
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ public function testWrongConstruction()
3838
$this->expectException(\TypeError::class);
3939
$link = $this->factory->bulky('wrong param', "label", $this->target);
4040
}
41+
42+
public function testWithAriaRole()
43+
{
44+
try {
45+
$b = $this->factory->bulky($this->glyph, "label", $this->target)
46+
->withAriaRole(I\Button\Bulky::MENUITEM);
47+
$this->assertEquals("menuitem", $b->getAriaRole());
48+
} catch (\InvalidArgumentException $e) {
49+
$this->assertFalse("This should not happen");
50+
}
51+
}
52+
53+
public function testWithAriaRoleIncorrect()
54+
{
55+
try {
56+
$this->factory->bulky($this->glyph, "label", $this->target)
57+
->withAriaRole("loremipsum");
58+
$this->assertFalse("This should not happen");
59+
} catch (\InvalidArgumentException $e) {
60+
$this->assertTrue(true);
61+
}
62+
}
4163

4264
public function testGetLabell()
4365
{
@@ -129,4 +151,22 @@ public function testRenderingWithId()
129151
$r->render($b)
130152
);
131153
}
154+
155+
public function testRenderWithAriaRoleMenuitem()
156+
{
157+
$r = $this->getDefaultRenderer();
158+
$b = $this->factory->bulky($this->icon, "label", $this->target)
159+
->withAriaRole(I\Button\Bulky::MENUITEM);
160+
161+
$expected = ''
162+
. '<a class="il-link link-bulky" href="http://www.ilias.de" role="menuitem">'
163+
. '<img class="icon someExample small" src="./templates/default/images/icon_default.svg" alt="Example"/>'
164+
. ' <span class="bulky-label">label</span>'
165+
. '</a>';
166+
167+
$this->assertHTMLEquals(
168+
$expected,
169+
$r->render($b)
170+
);
171+
}
132172
}

0 commit comments

Comments
 (0)