19 declare(strict_types=1);
21 require_once(
"vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../Base.php");
45 protected function setUp(): void
47 $this->link_html = sha1(
C\
Link\Standard::class);
48 $this->icon_html = sha1(
C\Symbol\
Icon\Icon::class);
49 $this->shy_html = sha1(
C\
Button\Shy::class);
50 $this->button_html = sha1(
C\
Button\Standard::class);
51 $this->unordered_html = sha1(
C\Listing\Unordered::class);
53 $this->link_mock = $this->createMock(
I\
Link\Standard::class);
54 $this->link_mock->method(
'getCanonicalName')->willReturn($this->link_html);
56 $this->icon_mock = $this->createMock(
I\Symbol\
Icon\Icon::class);
57 $this->icon_mock->method(
'getCanonicalName')->willReturn($this->icon_html);
59 $this->shy_mock = $this->createMock(
I\
Button\Shy::class);
60 $this->shy_mock->method(
'getCanonicalName')->willReturn($this->shy_html);
62 $this->button_mock = $this->createMock(
I\
Button\Standard::class);
63 $this->button_mock->method(
'getCanonicalName')->willReturn($this->button_html);
65 $this->unordered_mock = $this->createMock(
I\Listing\Unordered::class);
66 $this->unordered_mock->method(
'getCanonicalName')->willReturn($this->unordered_html);
68 $this->button_factory = $this->createMock(
I\
Button\Factory::class);
69 $this->button_factory->method(
'shy')->willReturn($this->shy_mock);
70 $this->button_factory->method(
'standard')->willReturn($this->button_mock);
72 $this->link_factory = $this->createMock(
I\
Link\Factory::class);
73 $this->link_factory->method(
'standard')->willReturn($this->link_mock);
75 $this->listing_factory = $this->createMock(
I\Listing\Factory::class);
76 $this->listing_factory->method(
'unordered')->willReturn($this->unordered_mock);
78 $this->uri_mock = $this->createMock(\
ILIAS\
Data\URI::class);
83 public function testSetAndGetModalsWithTrigger():
void 85 $signal_mock = $this->createMock(
C\Signal::class);
87 $modal_mock = $this->createMock(
C\Modal\RoundTrip::class);
88 $modal_mock->method(
'getShowSignal')->willReturn($signal_mock);
91 $shy_mock->expects($this->once())->method(
'withOnClick')->with($signal_mock)->willReturnSelf();
93 $shy_mock = $shy_mock->withOnClick($modal_mock->getShowSignal());
96 $footer = $this->
getUIFactory()->mainControls()->footer();
97 $footer = $footer->withAdditionalLink($shy_mock);
98 $footer = $footer->withAdditionalModal($modal_mock);
100 $this->assertCount(1, $footer->getModals());
101 $this->assertCount(1, $footer->getAdditionalLinks());
106 $footer = $this->
getUIFactory()->mainControls()->footer();
107 $footer = $footer->withPermanentURL($this->uri_mock);
109 $this->button_factory->expects($this->once())->method(
'standard')->with(
'copy_perma_link',
'');
110 $this->button_mock->expects($this->once())->method(
'withAdditionalOnLoadCode')->willReturnSelf();
112 $renderer = $this->getDefaultRenderer(
null, [$this->button_mock]);
113 $actual_html =
$renderer->render($footer);
115 $expected_html = <<<EOT
116 <footer
class=
"c-maincontrols c-maincontrols__footer">
117 <section
class=
"c-maincontrols__footer-grid" data-section=
"permanent-link" aria-label=
"footer_permanent_link" tabindex=
"0">
118 <div
class=
"c-maincontrols__footer-grid__item text-left">
119 <div
class=
"c-tooltip__container c-tooltip--top" aria-live=
"polite">
121 <div
class=
"c-tooltip c-tooltip--hidden" role=
"tooltip">
131 $this->brutallyTrimHTML($expected_html),
132 $this->brutallyTrimHTML($actual_html)
138 $link_group_title = sha1(
'link_group_1');
140 $footer = $this->
getUIFactory()->mainControls()->footer();
141 $footer = $footer->withAdditionalLinkGroup($link_group_title, [$this->link_mock]);
143 $this->listing_factory->expects($this->once())->method(
'unordered')->with([$this->link_mock]);
145 $renderer = $this->getDefaultRenderer(
null, [$this->unordered_mock]);
146 $actual_html =
$renderer->render($footer);
148 $expected_html = <<<EOT
149 <footer
class=
"c-maincontrols c-maincontrols__footer">
150 <section
class=
"c-maincontrols__footer-grid" data-section=
"link-groups" aria-label=
"footer_link_groups" tabindex=
"0">
151 <div
class=
"c-maincontrols__footer-grid__item text-left">
152 <strong>$link_group_title</strong>$this->unordered_html
159 $this->brutallyTrimHTML($expected_html),
160 $this->brutallyTrimHTML($actual_html)
166 $footer = $this->
getUIFactory()->mainControls()->footer();
167 $footer = $footer->withAdditionalLink($this->link_mock);
169 $renderer = $this->getDefaultRenderer(
null, [$this->link_mock]);
170 $actual_html =
$renderer->render($footer);
172 $expected_html = <<<EOT
173 <footer
class=
"c-maincontrols c-maincontrols__footer">
174 <section
class=
"c-maincontrols__footer-grid" data-section=
"links" aria-label=
"footer_links" tabindex=
"0">
175 <div
class=
"c-maincontrols__footer-grid__item text-left">$this->link_html</div>
181 $this->brutallyTrimHTML($expected_html),
182 $this->brutallyTrimHTML($actual_html)
188 $footer = $this->
getUIFactory()->mainControls()->footer();
189 $footer = $footer->withAdditionalIcon($this->icon_mock);
191 $renderer = $this->getDefaultRenderer(
null, [$this->icon_mock]);
192 $actual_html =
$renderer->render($footer);
194 $expected_html = <<<EOT
195 <footer
class=
"c-maincontrols c-maincontrols__footer">
196 <section
class=
"c-maincontrols__footer-grid" data-section=
"icons" aria-label=
"footer_icons" tabindex=
"0">
197 <div
class=
"c-maincontrols__footer-grid__item l-bar__group">
198 <span
class=
"l-bar__element">$this->icon_html</span>
205 $this->brutallyTrimHTML($expected_html),
206 $this->brutallyTrimHTML($actual_html)
212 $text = sha1(
'text_1');
214 $footer = $this->
getUIFactory()->mainControls()->footer();
215 $footer = $footer->withAdditionalText($text);
218 $actual_html =
$renderer->render($footer);
220 $expected_html = <<<EOT
221 <footer
class=
"c-maincontrols c-maincontrols__footer">
222 <section
class=
"c-maincontrols__footer-grid" data-section=
"texts" aria-label=
"footer_texts" tabindex=
"0">
223 <div
class=
"c-maincontrols__footer-grid__item text-left">$text</div>
229 $this->brutallyTrimHTML($expected_html),
230 $this->brutallyTrimHTML($actual_html)
236 $modal_html = sha1(
C\Modal\RoundTrip::class);
237 $modal_mock = $this->createMock(
C\Modal\RoundTrip::class);
238 $modal_mock->method(
'getCanonicalName')->willReturn($modal_html);
239 $modal_mock->method(
'getShowSignal')->willReturn(
240 $this->createMock(
C\Signal::class)
244 $shy_mock->method(
'withOnClick')->willReturnSelf();
246 $shy_mock = $shy_mock->withOnClick($modal_mock->getShowSignal());
248 $footer = $this->
getUIFactory()->mainControls()->footer();
249 $footer = $footer->withAdditionalLink($shy_mock);
250 $footer = $footer->withAdditionalModal($modal_mock);
252 $renderer = $this->getDefaultRenderer(
null, [$modal_mock, $shy_mock]);
253 $actual_html =
$renderer->render($footer);
255 $expected_html = <<<EOT
256 <footer
class=
"c-maincontrols c-maincontrols__footer">
257 <section
class=
"c-maincontrols__footer-grid" data-section=
"links" aria-label=
"footer_links" tabindex=
"0">
258 <div
class=
"c-maincontrols__footer-grid__item text-left">$this->shy_html</div>
264 $this->brutallyTrimHTML($expected_html),
265 $this->brutallyTrimHTML($actual_html)
271 $footer = $this->
getUIFactory()->mainControls()->footer();
274 $actual_html =
$renderer->render($footer);
278 $this->assertEquals($expected_html, $actual_html);
284 $this->createMock(
I\SignalGeneratorInterface::class),
285 $this->createMock(
I\Counter\Factory::class),
286 $this->createMock(
I\Symbol\Factory::class),
292 protected I\SignalGeneratorInterface $signal_generator,
293 protected I\Counter\Factory $counter_factory,
294 protected I\Symbol\Factory $symbol_factory,
295 protected I\
Button\Factory $button_factory,
296 protected I\
Link\Factory $link_factory,
297 protected I\Listing\Factory $listing_factory,
300 public function mainControls(): I\MainControls\Factory
302 return new I\MainControls\Factory(
303 $this->signal_generator,
304 new I\MainControls\Slate\Factory(
305 $this->signal_generator,
306 $this->counter_factory,
307 $this->symbol_factory,
311 public function button(): I\Button\Factory
315 public function link(): I\Link\Factory
319 public function listing(): I\Listing\Factory
button(string $caption, string $cmd)
Interface Observer Contains several chained tasks and infos about them.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(Container $dic, ilPlugin $plugin)
link(string $caption, string $href, bool $new_viewport=false)