5 require_once(__DIR__ .
"/../../../../libs/composer/vendor/autoload.php");
6 require_once(__DIR__ .
"/../../Base.php");
8 use \ILIAS\UI\Component as
C;
9 use \ILIAS\UI\Implementation\Component\Signal;
18 return new \ILIAS\UI\Implementation\Component\Button\Factory();
25 $this->assertInstanceOf(
26 "ILIAS\\UI\\Component\\Button\\Toggle",
27 $f->toggle(
"label",
"action_on_string",
"action_off_string")
35 $f->toggle(
"label", 1,
"action_off_string");
36 $this->assertFalse(
"This should not happen");
38 $this->assertTrue(
true);
46 $f->toggle(
"label",
"action_on_string", 2);
47 $this->assertFalse(
"This should not happen");
49 $this->assertTrue(
true);
56 $button =
$f->toggle(
"label",
"action_on_string",
"action_off_string",
true);
58 $this->assertTrue($button->isEngaged());
64 $signal_on1 = $this->createMock(Signal::class);
65 $signal_on2 = $this->createMock(Signal::class);
66 $signal_off = $this->createMock(Signal::class);
67 $button =
$f->toggle(
"label", $signal_on1, $signal_off);
68 $this->assertEquals([$signal_on1], $button->getActionOn());
70 $button = $button->withAdditionalToggleOnSignal($signal_on2);
71 $this->assertEquals([$signal_on1, $signal_on2], $button->getActionOn());
77 $signal_off1 = $this->createMock(Signal::class);
78 $signal_off2 = $this->createMock(Signal::class);
80 $button =
$f->toggle(
"label",
"action_on", $signal_off1);
81 $this->assertEquals([$signal_off1], $button->getActionOff());
83 $button = $button->withAdditionalToggleOffSignal($signal_off2);
84 $this->assertEquals([$signal_off1, $signal_off2], $button->getActionOff());
90 $button = $this->
getFactory()->toggle(
"label",
"action_on_string",
"action_off_string");
94 <button
class=
"il-toggle-button off" id=
"id_1" aria-pressed=
"false">
95 <span
class=
"il-toggle-label-on">toggle_on</span>
96 <span
class=
"il-toggle-label-off">toggle_off</span>
97 <span
class=
"il-toggle-switch"></span>
101 $this->
assertHTMLEquals(
"<div>" . $expected .
"</div>",
"<div>" . $r->render($button) .
"</div>");
107 $button = $this->
getFactory()->toggle(
"",
"action_on_string",
"action_off_string",
true);
110 .
'<button class="il-toggle-button on" id="id_1" aria-pressed="false">' 111 .
' <span class="il-toggle-label-on">toggle_on</span>' 112 .
' <span class="il-toggle-label-off">toggle_off</span>' 113 .
' <span class="il-toggle-switch"></span>' 123 $signal_on = $this->createMock(Signal::class);
124 $signal_on->method(
"__toString")
125 ->willReturn(
"MOCK_SIGNAL");
126 $signal_off = $this->createMock(Signal::class);
127 $signal_off->method(
"__toString")
128 ->willReturn(
"MOCK_SIGNAL");
129 $button = $this->
getFactory()->toggle(
"label", $signal_on, $signal_off);
133 <button
class=
"il-toggle-button off" id=
"id_1" aria-pressed=
"false">
134 <span
class=
"il-toggle-label-on">toggle_on</span>
135 <span
class=
"il-toggle-label-off">toggle_off</span>
136 <span
class=
"il-toggle-switch"></span>
140 $this->
assertHTMLEquals(
"<div>" . $expected .
"</div>",
"<div>" . $r->render($button) .
"</div>");
149 $button = $button->withUnavailableAction();
151 $html = $r->render($button);
154 .
'<button class="il-toggle-button unavailable" aria-pressed="false" disabled="disabled">' 155 .
' <span class="il-toggle-switch"></span>'
Provides common functionality for UI tests.
assertHTMLEquals($expected_html_as_string, $html_as_string)
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])