19 declare(strict_types=1);
21 require_once(
"vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../Base.php");
43 protected function setUp(): void
45 $this->link_html = sha1(
C\
Link\Standard::class);
46 $this->icon_html = sha1(
C\Symbol\
Icon\Icon::class);
47 $this->shy_html = sha1(
C\
Button\Shy::class);
48 $this->unordered_html = sha1(
C\Listing\Unordered::class);
50 $this->link_mock = $this->createMock(
I\
Link\Standard::class);
51 $this->link_mock->method(
'getCanonicalName')->willReturn($this->link_html);
53 $this->icon_mock = $this->createMock(
I\Symbol\
Icon\Icon::class);
54 $this->icon_mock->method(
'getCanonicalName')->willReturn($this->icon_html);
56 $this->shy_mock = $this->createMock(
I\
Button\Shy::class);
57 $this->shy_mock->method(
'getCanonicalName')->willReturn($this->shy_html);
59 $this->unordered_mock = $this->createMock(
I\Listing\Unordered::class);
60 $this->unordered_mock->method(
'getCanonicalName')->willReturn($this->unordered_html);
62 $this->button_factory = $this->createMock(
I\
Button\Factory::class);
63 $this->button_factory->method(
'shy')->willReturn($this->shy_mock);
65 $this->link_factory = $this->createMock(
I\
Link\Factory::class);
66 $this->link_factory->method(
'standard')->willReturn($this->link_mock);
68 $this->listing_factory = $this->createMock(
I\Listing\Factory::class);
69 $this->listing_factory->method(
'unordered')->willReturn($this->unordered_mock);
71 $this->uri_mock = $this->createMock(\
ILIAS\
Data\URI::class);
76 public function testSetAndGetModalsWithTrigger():
void 78 $signal_mock = $this->createMock(
C\Signal::class);
80 $modal_mock = $this->createMock(
C\Modal\RoundTrip::class);
81 $modal_mock->method(
'getShowSignal')->willReturn($signal_mock);
84 $shy_mock->expects($this->once())->method(
'withOnClick')->with($signal_mock)->willReturnSelf();
86 $shy_mock = $shy_mock->withOnClick($modal_mock->getShowSignal());
89 $footer = $this->
getUIFactory()->mainControls()->footer();
90 $footer = $footer->withAdditionalLink($shy_mock);
91 $footer = $footer->withAdditionalModal($modal_mock);
93 $this->assertCount(1, $footer->getModals());
94 $this->assertCount(1, $footer->getAdditionalLinks());
99 $footer = $this->
getUIFactory()->mainControls()->footer();
100 $footer = $footer->withPermanentURL($this->uri_mock);
102 $this->button_factory->expects($this->once())->method(
'shy')->with(
'copy_perma_link',
'');
103 $this->shy_mock->expects($this->once())->method(
'withAdditionalOnLoadCode')->willReturnSelf();
105 $renderer = $this->getDefaultRenderer(
null, [$this->shy_mock]);
106 $actual_html =
$renderer->render($footer);
108 $expected_html = <<<EOT
109 <footer
class=
"c-maincontrols c-maincontrols__footer">
110 <section
class=
"c-maincontrols__footer-grid" data-section=
"permanent-link" aria-label=
"footer_permanent_link" tabindex=
"0">
111 <div
class=
"c-maincontrols__footer-grid__item text-left">
112 <div
class=
"c-tooltip__container c-tooltip--top" aria-live=
"polite">
114 <div
class=
"c-tooltip c-tooltip--hidden" role=
"tooltip">
124 $this->brutallyTrimHTML($expected_html),
125 $this->brutallyTrimHTML($actual_html)
131 $link_group_title = sha1(
'link_group_1');
133 $footer = $this->
getUIFactory()->mainControls()->footer();
134 $footer = $footer->withAdditionalLinkGroup($link_group_title, [$this->link_mock]);
136 $this->listing_factory->expects($this->once())->method(
'unordered')->with([$this->link_mock]);
138 $renderer = $this->getDefaultRenderer(
null, [$this->unordered_mock]);
139 $actual_html =
$renderer->render($footer);
141 $expected_html = <<<EOT
142 <footer
class=
"c-maincontrols c-maincontrols__footer">
143 <section
class=
"c-maincontrols__footer-grid" data-section=
"link-groups" aria-label=
"footer_link_groups" tabindex=
"0">
144 <div
class=
"c-maincontrols__footer-grid__item text-left">
145 <strong>$link_group_title</strong>$this->unordered_html
152 $this->brutallyTrimHTML($expected_html),
153 $this->brutallyTrimHTML($actual_html)
159 $footer = $this->
getUIFactory()->mainControls()->footer();
160 $footer = $footer->withAdditionalLink($this->link_mock);
162 $renderer = $this->getDefaultRenderer(
null, [$this->link_mock]);
163 $actual_html =
$renderer->render($footer);
165 $expected_html = <<<EOT
166 <footer
class=
"c-maincontrols c-maincontrols__footer">
167 <section
class=
"c-maincontrols__footer-grid" data-section=
"links" aria-label=
"footer_links" tabindex=
"0">
168 <div
class=
"c-maincontrols__footer-grid__item text-left">$this->link_html</div>
174 $this->brutallyTrimHTML($expected_html),
175 $this->brutallyTrimHTML($actual_html)
181 $footer = $this->
getUIFactory()->mainControls()->footer();
182 $footer = $footer->withAdditionalIcon($this->icon_mock);
184 $renderer = $this->getDefaultRenderer(
null, [$this->icon_mock]);
185 $actual_html =
$renderer->render($footer);
187 $expected_html = <<<EOT
188 <footer
class=
"c-maincontrols c-maincontrols__footer">
189 <section
class=
"c-maincontrols__footer-grid" data-section=
"icons" aria-label=
"footer_icons" tabindex=
"0">
190 <div
class=
"c-maincontrols__footer-grid__item l-bar__group">
191 <span
class=
"l-bar__element">$this->icon_html</span>
198 $this->brutallyTrimHTML($expected_html),
199 $this->brutallyTrimHTML($actual_html)
205 $text = sha1(
'text_1');
207 $footer = $this->
getUIFactory()->mainControls()->footer();
208 $footer = $footer->withAdditionalText($text);
211 $actual_html =
$renderer->render($footer);
213 $expected_html = <<<EOT
214 <footer
class=
"c-maincontrols c-maincontrols__footer">
215 <section
class=
"c-maincontrols__footer-grid" data-section=
"texts" aria-label=
"footer_texts" tabindex=
"0">
216 <div
class=
"c-maincontrols__footer-grid__item text-left">$text</div>
222 $this->brutallyTrimHTML($expected_html),
223 $this->brutallyTrimHTML($actual_html)
229 $modal_html = sha1(
C\Modal\RoundTrip::class);
230 $modal_mock = $this->createMock(
C\Modal\RoundTrip::class);
231 $modal_mock->method(
'getCanonicalName')->willReturn($modal_html);
232 $modal_mock->method(
'getShowSignal')->willReturn(
233 $this->createMock(
C\Signal::class)
237 $shy_mock->method(
'withOnClick')->willReturnSelf();
239 $shy_mock = $shy_mock->withOnClick($modal_mock->getShowSignal());
241 $footer = $this->
getUIFactory()->mainControls()->footer();
242 $footer = $footer->withAdditionalLink($shy_mock);
243 $footer = $footer->withAdditionalModal($modal_mock);
245 $renderer = $this->getDefaultRenderer(
null, [$modal_mock, $shy_mock]);
246 $actual_html =
$renderer->render($footer);
248 $expected_html = <<<EOT
249 <footer
class=
"c-maincontrols c-maincontrols__footer">
250 <section
class=
"c-maincontrols__footer-grid" data-section=
"links" aria-label=
"footer_links" tabindex=
"0">
251 <div
class=
"c-maincontrols__footer-grid__item text-left">$this->shy_html</div>
257 $this->brutallyTrimHTML($expected_html),
258 $this->brutallyTrimHTML($actual_html)
264 $footer = $this->
getUIFactory()->mainControls()->footer();
267 $actual_html =
$renderer->render($footer);
271 $this->assertEquals($expected_html, $actual_html);
277 $this->createMock(
I\SignalGeneratorInterface::class),
278 $this->createMock(
I\Counter\Factory::class),
279 $this->createMock(
I\Symbol\Factory::class),
285 protected I\SignalGeneratorInterface $signal_generator,
286 protected I\Counter\Factory $counter_factory,
287 protected I\Symbol\Factory $symbol_factory,
288 protected I\
Button\Factory $button_factory,
289 protected I\
Link\Factory $link_factory,
290 protected I\Listing\Factory $listing_factory,
293 public function mainControls(): I\MainControls\Factory
295 return new I\MainControls\Factory(
296 $this->signal_generator,
297 new I\MainControls\Slate\Factory(
298 $this->signal_generator,
299 $this->counter_factory,
300 $this->symbol_factory,
304 public function button(): I\Button\Factory
308 public function link(): I\Link\Factory
312 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)