Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fallback for button-tests otherwise considered risky #1739

Merged
merged 3 commits into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/UI/templates/default/Button/tpl.primary.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<button class="btn btn-default btn-primary<!-- BEGIN disabled --> ilSubmitInactive disabled<!-- END disabled --><!-- BEGIN engaged --> engaged<!-- END engaged -->"<!-- BEGIN with_data_action --> data-action="{ACTION}"<!-- END with_data_action --><!-- BEGIN with_aria_pressed --> aria-pressed="{ARIA_PRESSED}"<!-- END with_aria_pressed --><!-- BEGIN with_id --> id="{ID}"<!-- END with_id -->>{LABEL}</button>
<button class="btn btn-default btn-primary<!-- BEGIN disabled --> ilSubmitInactive disabled<!-- END disabled --><!-- BEGIN engaged --> engaged<!-- END engaged -->"<!-- BEGIN with_aria_pressed --> aria-pressed="{ARIA_PRESSED}"<!-- END with_aria_pressed --><!-- BEGIN with_aria_label --> aria-label="{ARIA_LABEL}"<!-- END with_aria_label --><!-- BEGIN with_data_action --> data-action="{ACTION}"<!-- END with_data_action --><!-- BEGIN with_id --> id="{ID}"<!-- END with_id -->>{LABEL}</button>
2 changes: 1 addition & 1 deletion src/UI/templates/default/Button/tpl.shy.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<button class="btn btn-link<!-- BEGIN disabled --> ilSubmitInactive disabled<!-- END disabled -->"<!-- BEGIN with_data_action --> data-action="{ACTION}"<!-- END with_data_action --><!-- BEGIN with_id --> id="{ID}"<!-- END with_id --> <!-- BEGIN with_aria_label --> aria-label="{ARIA_LABEL}"<!-- END with_aria_label --> >{LABEL}</button>
<button class="btn btn-link<!-- BEGIN disabled --> ilSubmitInactive disabled<!-- END disabled -->"<!-- BEGIN with_aria_label --> aria-label="{ARIA_LABEL}"<!-- END with_aria_label --><!-- BEGIN with_data_action --> data-action="{ACTION}"<!-- END with_data_action --><!-- BEGIN with_id --> id="{ID}"<!-- END with_id -->>{LABEL}</button>
2 changes: 1 addition & 1 deletion src/UI/templates/default/Button/tpl.tag.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<button class="btn btn-tag<!-- BEGIN rel_verylow --> btn-tag-relevance-verylow<!-- END rel_verylow --><!-- BEGIN rel_low --> btn-tag-relevance-low<!-- END rel_low --><!-- BEGIN rel_mid --> btn-tag-relevance-middle<!-- END rel_mid --><!-- BEGIN rel_high --> btn-tag-relevance-high<!-- END rel_high --><!-- BEGIN rel_veryhigh --> btn-tag-relevance-veryhigh<!-- END rel_veryhigh --><!-- BEGIN disabled --> btn-tag-inactive<!-- END disabled --><!-- BEGIN additional_classes --> {CLASSES}<!-- END additional_classes -->"<!-- BEGIN colors --> style="<!-- BEGIN bgcol -->background-color: {BGCOL}; <!-- END bgcol --><!-- BEGIN forecol -->color: {FORECOL};<!-- END forecol -->"<!-- END colors --><!-- BEGIN with_data_action --> data-action="{ACTION}"<!-- END with_data_action --><!-- BEGIN with_id --> id="{ID}"<!-- END with_id -->>{LABEL}</button>
<button class="btn btn-tag<!-- BEGIN rel_verylow --> btn-tag-relevance-verylow<!-- END rel_verylow --><!-- BEGIN rel_low --> btn-tag-relevance-low<!-- END rel_low --><!-- BEGIN rel_mid --> btn-tag-relevance-middle<!-- END rel_mid --><!-- BEGIN rel_high --> btn-tag-relevance-high<!-- END rel_high --><!-- BEGIN rel_veryhigh --> btn-tag-relevance-veryhigh<!-- END rel_veryhigh --><!-- BEGIN disabled --> btn-tag-inactive<!-- END disabled --><!-- BEGIN additional_classes --> {CLASSES}<!-- END additional_classes -->"<!-- BEGIN colors --> style="<!-- BEGIN bgcol -->background-color: {BGCOL}; <!-- END bgcol --><!-- BEGIN forecol -->color: {FORECOL};<!-- END forecol -->"<!-- END colors --><!-- BEGIN with_aria_label --> aria-label="{ARIA_LABEL}"<!-- END with_aria_label --><!-- BEGIN with_data_action --> data-action="{ACTION}"<!-- END with_data_action --><!-- BEGIN with_id --> id="{ID}"<!-- END with_id -->>{LABEL}</button>
54 changes: 28 additions & 26 deletions tests/UI/Component/Button/ButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
/**
* Test on button implementation.
*/
class ButtonTest extends ILIAS_UI_TestBase {
class ButtonTest extends ILIAS_UI_TestBase
{
const NOT_APPLICABLE = true;

public function getButtonFactory() {
return new \ILIAS\UI\Implementation\Component\Button\Factory();
}
Expand Down Expand Up @@ -343,6 +346,8 @@ public function test_button_with_engageable($factory_method) {
$this->assertEquals(false, $b->isEngageable());
$b2 = $f->$factory_method("label", "http://www.ilias.de")->withEngagedState(false);
$this->assertEquals(true,$b2->isEngageable());
} else {
$this->assertTrue(self::NOT_APPLICABLE);
}
}

Expand All @@ -357,44 +362,39 @@ public function test_button_with_engaged($factory_method) {
$this->assertEquals(false, $b->isEngaged());
$b2 = $f->$factory_method("label", "http://www.ilias.de")->withEngagedState(true);
$this->assertEquals(true,$b2->isEngaged());
} else {
$this->assertTrue(self::NOT_APPLICABLE);
}
}

/**
* @dataProvider button_type_provider
*/
public function test_render_button_with_aria_label($factory_method) {
//only standard buttons have aria labels in the template. Should the others accept aria stuff?
//if yes, remove this conditional
if($factory_method == "standard")
{
$ln = "http://www.ilias.de";
$f = $this->getButtonFactory();
$r = $this->getDefaultRenderer();
$b = $f->$factory_method("label", $ln)->withAriaLabel("aria label text");
$aria_label = $b->getAriaLabel();
$ln = "http://www.ilias.de";
$f = $this->getButtonFactory();
$r = $this->getDefaultRenderer();
$b = $f->$factory_method("label", $ln)->withAriaLabel("aria label text");
$aria_label = $b->getAriaLabel();

$html = $this->normalizeHTML($r->render($b));
$css_classes = self::$canonical_css_classes[$factory_method];
$expected = "<button class=\"$css_classes\" aria-label=\"$aria_label\" data-action=\"$ln\" id=\"id_1\">".
"label".
"</button>";
$this->assertHTMLEquals($expected, $html);
}
$html = $this->normalizeHTML($r->render($b));
$css_classes = self::$canonical_css_classes[$factory_method];
$expected = "<button class=\"$css_classes\" aria-label=\"$aria_label\" data-action=\"$ln\" id=\"id_1\">".
"label".
"</button>";
$this->assertHTMLEquals($expected, $html);
}

/**
* @dataProvider button_type_provider
*/
public function test_render_button_with_aria_checked($factory_method) {
//only standard buttons have aria labels in the template. Should the others accept aria stuff?
//if yes, remove this conditional
if($factory_method == "standard")
{
$ln = "http://www.ilias.de";
$f = $this->getButtonFactory();
$r = $this->getDefaultRenderer();
$b = $f->$factory_method("label", $ln)->withEngagedState(true);
public function test_render_button_with_aria_pressed($factory_method) {
$ln = "http://www.ilias.de";
$f = $this->getButtonFactory();
$r = $this->getDefaultRenderer();
$b = $f->$factory_method("label", $ln);
if ($b instanceof C\Button\Engageable) {
$b = $b->withEngagedState(true);

$html = $this->normalizeHTML($r->render($b));
$css_classes = self::$canonical_css_classes[$factory_method];
Expand All @@ -403,6 +403,8 @@ public function test_render_button_with_aria_checked($factory_method) {
"label".
"</button>";
$this->assertHTMLEquals($expected, $html);
} else {
$this->assertTrue(self::NOT_APPLICABLE);
}
}

Expand Down
Loading