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->isOn());
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" id=
"id_1" aria-pressed=
"false">
95 <div
class=
"il-toggle-switch"></div>
99 $this->
assertHTMLEquals(
"<div>" . $expected .
"</div>",
"<div>" .
$r->render($button) .
"</div>");
105 $button = $this->
getFactory()->toggle(
"",
"action_on_string",
"action_off_string",
true);
108 .
'<button class="il-toggle-button on" id="id_1" aria-pressed="false">' 109 .
' <div class="il-toggle-switch"></div>' 118 $signal_on = $this->createMock(Signal::class);
119 $signal_on->method(
"__toString")
120 ->willReturn(
"MOCK_SIGNAL");
121 $signal_off = $this->createMock(Signal::class);
122 $signal_off->method(
"__toString")
123 ->willReturn(
"MOCK_SIGNAL");
124 $button = $this->
getFactory()->toggle(
"label", $signal_on, $signal_off);
128 <button
class=
"il-toggle-button" id=
"id_1" aria-pressed=
"false">
129 <div
class=
"il-toggle-switch"></div>
133 $this->
assertHTMLEquals(
"<div>" . $expected .
"</div>",
"<div>" .
$r->render($button) .
"</div>");
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Provides common functionality for UI tests.
assertHTMLEquals($expected_html_as_string, $html_as_string)