ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
LinkTransferTest Class Reference
+ Inheritance diagram for LinkTransferTest:
+ Collaboration diagram for LinkTransferTest:

Public Member Functions

 getUIFactory ()
 
 getRefinery ()
 
 testRenderWithClipboardTransferMechanism ()
 
 testRenderWithWebShreTransferMechanism ()
 
 testRenderWithQrCodeTransferMechanism ()
 
 testWithAdditionalTransferMechanismOrderPreservation ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

string $uri_stub_value
 
ILIAS Data URI &Stub $uri_stub
 
string $glyph_stub_html
 
I Symbol Glyph Glyph &Stub $glyph_stub
 
string $button_mock_html
 
I Button Standard &MockObject $button_mock
 
string $modal_mock_html
 
I Modal RoundTrip &MockObject $modal_mock
 
string $image_mock_html
 
I Image Image &MockObject $image_mock
 
I Button Factory &MockObject $button_factory_mock
 
I Modal Factory &MockObject $modal_factory_mock
 
I Image Factory &MockObject $image_factory_mock
 
ILIAS Refinery Transformation &MockObject $to_svg_qr_code_mock
 
ILIAS Refinery Transformation &MockObject $from_svg_mock
 

Detailed Description

Author
Thibeau Fuhrer thibe.nosp@m.au@s.nosp@m.r.sol.nosp@m.utio.nosp@m.ns

Definition at line 31 of file LinkTransferTest.php.

Member Function Documentation

◆ getRefinery()

LinkTransferTest::getRefinery ( )

Definition at line 137 of file LinkTransferTest.php.

138 {
139 $uri_group_stub = $this->createStub(\ILIAS\Refinery\URI\Group::class);
140 $uri_group_stub->method('toSvgQrCode')->willReturn($this->to_svg_qr_code_mock);
141 $uri_group_stub->method('fromSvg')->willReturn($this->from_svg_mock);
142
143 $refinery_stub = $this->createStub(\ILIAS\Refinery\Factory::class);
144 $refinery_stub->method('uri')->willReturn($uri_group_stub);
145
146 return $refinery_stub;
147 }
Builds data types.
Definition: Factory.php:36
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ getUIFactory()

LinkTransferTest::getUIFactory ( )

Definition at line 90 of file LinkTransferTest.php.

91 {
92 $glyph_factory_stub = $this->createStub(I\Symbol\Glyph\Factory::class);
93 $glyph_factory_stub->method($this->anything())->willReturn($this->glyph_stub);
94 $symbol_factory_stub = $this->createStub(I\Symbol\Factory::class);
95 $symbol_factory_stub->method('glyph')->willReturn($glyph_factory_stub);
96
97 $real_transfer_factory = new I\Transfer\Factory();
98
99 return new class (
100 $symbol_factory_stub,
104 $real_transfer_factory,
105 ) extends \NoUIFactory {
106 public function __construct(
107 protected I\Symbol\Factory $symbol_factory,
108 protected I\Button\Factory $button_factory,
109 protected I\Modal\Factory $modal_factory,
110 protected I\Image\Factory $image_factory,
111 protected I\Transfer\Factory $transfer_factory,
112 ) {
113 }
114 public function symbol(): I\Symbol\Factory
115 {
116 return $this->symbol_factory;
117 }
118 public function button(): I\Button\Factory
119 {
120 return $this->button_factory;
121 }
122 public function modal(): I\Modal\Factory
123 {
124 return $this->modal_factory;
125 }
126 public function image(): I\Image\Factory
127 {
128 return $this->image_factory;
129 }
130 public function transfer(): I\Transfer\Factory
131 {
132 return $this->transfer_factory;
133 }
134 };
135 }
I Image Factory &MockObject $image_factory_mock
I Modal Factory &MockObject $modal_factory_mock
I Button Factory &MockObject $button_factory_mock
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
modal(string $title="", string $cancel_label="")
button(string $caption, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21

References $button_factory_mock, $image_factory_mock, $modal_factory_mock, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\button(), ILIAS\Repository\modal(), and ILIAS\Repository\symbol().

Referenced by testRenderWithClipboardTransferMechanism(), testRenderWithQrCodeTransferMechanism(), testRenderWithWebShreTransferMechanism(), and testWithAdditionalTransferMechanismOrderPreservation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUp()

LinkTransferTest::setUp ( )
protected

Definition at line 52 of file LinkTransferTest.php.

52 : void
53 {
54 $this->uri_stub_value = sha1(\ILIAS\Data\URI::class);
55 $this->uri_stub = $this->createStub(\ILIAS\Data\URI::class);
56 $this->uri_stub->method('__toString')->willReturn($this->uri_stub_value);
57
58 $this->glyph_stub_html = sha1(I\Symbol\Glyph\Glyph::class);
59 $this->glyph_stub = $this->createStub(I\Symbol\Glyph\Glyph::class);
60 $this->glyph_stub->method('getCanonicalName')->willReturn($this->glyph_stub_html);
61 $this->glyph_stub->method('withLabel')->willReturnSelf();
62
63 $this->button_mock_html = sha1(I\Button\Standard::class);
64 $this->button_mock = $this->createMock(I\Button\Standard::class);
65 $this->button_mock->method('getCanonicalName')->willReturn($this->button_mock_html);
66
67 $this->modal_mock_html = sha1(I\Modal\RoundTrip::class);
68 $this->modal_mock = $this->createMock(I\Modal\RoundTrip::class);
69 $this->modal_mock->method('getCanonicalName')->willReturn($this->modal_mock_html);
70
71 $this->image_mock_html = sha1(I\Image\Image::class);
72 $this->image_mock = $this->createMock(I\Image\Image::class);
73 $this->image_mock->method('getCanonicalName')->willReturn($this->image_mock_html);
74
75 $this->button_factory_mock = $this->createMock(I\Button\Factory::class);
76 $this->button_factory_mock->method('standard')->willReturn($this->button_mock);
77
78 $this->modal_factory_mock = $this->createMock(I\Modal\Factory::class);
79 $this->modal_factory_mock->method('roundtrip')->willReturn($this->modal_mock);
80
81 $this->image_factory_mock = $this->createMock(I\Image\Factory::class);
82 $this->image_factory_mock->method('responsive')->willReturn($this->image_mock);
83
84 $this->to_svg_qr_code_mock = $this->createMock(\ILIAS\Refinery\Transformation::class);
85 $this->from_svg_mock = $this->createMock(\ILIAS\Refinery\Transformation::class);
86
88 }

References setUp().

+ Here is the call graph for this function:

◆ testRenderWithClipboardTransferMechanism()

LinkTransferTest::testRenderWithClipboardTransferMechanism ( )

Definition at line 149 of file LinkTransferTest.php.

149 : void
150 {
151 $link_label = sha1('testRenderWithClipboardTransferMechanism');
152 $link_transfer = $this->getUIFactory()->transfer()->link(
153 C\Transfer\TransferMechanism::CLIPBOARD,
154 $this->uri_stub,
155 $link_label,
156 );
157
158 $renderer = $this->getDefaultRenderer(null, [$this->glyph_stub]);
159
160 $expected_transfer_type = C\Transfer\TransferMechanism::CLIPBOARD->value;
161 $expected = <<<HTML
162<div id="id_2" class="c-transfer c-transfer-link">
163 <label for="id_2_value">$link_label</label>
164 <div class="c-transfer__contents">
165 <input id="id_2_value" class="c-transfer__payload visible" type="url" value="$this->uri_stub_value" readonly="readonly">
166 <div class="c-tooltip__container">
167 <button data-transfer-type="$expected_transfer_type" class="btn btn-default" aria-label="copy_to_clipboard_aria">
168 <span data-transfer-status="default" class="visible">$this->glyph_stub_html</span>
169 <span data-transfer-status="success" data-transfer-message="copy_to_clipboard_success" class="hidden">$this->glyph_stub_html</span>
170 <span data-transfer-status="failure" data-transfer-message="copy_to_clipboard_failure" class="hidden">$this->glyph_stub_html</span>
171 <span>copy_to_clipboard</span>
172 </button>
173 <div id="id_1" role="status" class="c-tooltip c-tooltip--hidden">
174 <p></p>
175 </div>
176 </div>
177 </div>
178</div>
179HTML;
180
181 $actual = $renderer->render($link_transfer);
182
183 $this->assertSame($this->brutallyTrimHTML($expected), $this->brutallyTrimHTML($actual));
184 }
$renderer

References $renderer, ILIAS\Repository\button(), and getUIFactory().

+ Here is the call graph for this function:

◆ testRenderWithQrCodeTransferMechanism()

LinkTransferTest::testRenderWithQrCodeTransferMechanism ( )

Definition at line 223 of file LinkTransferTest.php.

223 : void
224 {
225 $link_label = sha1('testRenderWithQrCodeTransferMechanism');
226
227 // values passed along the transformation chain
228 $svg_stub = $this->createStub(\ILIAS\Data\SVG::class);
229 $svg_data_uri = 'data:image/svg+xml;base64,' . base64_encode($link_label);
230 $show_signal = $this->createStub(C\Signal::class);
231
232 // test url transformations
233 $this->to_svg_qr_code_mock
234 ->expects($this->once())
235 ->method('transform')
236 ->with($this->identicalTo($this->uri_stub))
237 ->willReturn($svg_stub);
238 $this->from_svg_mock
239 ->expects($this->once())
240 ->method('transform')
241 ->with($this->identicalTo($svg_stub))
242 ->willReturn($svg_data_uri);
243
244 // test image compisition
245 $this->image_factory_mock
246 ->expects($this->once())
247 ->method('responsive')
248 ->with($svg_data_uri, $link_label);
249 $this->image_mock
250 ->expects($this->once())
251 ->method('withAction')
252 ->with($this->uri_stub_value)
253 ->willReturnSelf();
254
255 // test modal compisition
256 $this->modal_factory_mock
257 ->expects($this->once())
258 ->method('roundtrip')
259 ->with('use_qr_code', [$this->image_mock]);
260 $this->modal_mock
261 ->expects($this->once())
262 ->method('withCancelButtonLabel')
263 ->with('close')
264 ->willReturnSelf();
265 $this->modal_mock
266 ->expects($this->once())
267 ->method('withCloseWithKeyboard')
268 ->with(true)
269 ->willReturnSelf();
270 $this->modal_mock
271 ->expects($this->once())
272 ->method('getShowSignal')
273 ->willReturn($show_signal);
274
275 // test button compisition
276 $this->button_factory_mock
277 ->expects($this->once())
278 ->method('standard')
279 ->with('show_qr_code', '');
280 $this->button_mock
281 ->expects($this->once())
282 ->method('withAriaLabel')
283 ->with('show_qr_code_aria')
284 ->willReturnSelf();
285 $this->button_mock
286 ->expects($this->once())
287 ->method('withSymbol')
288 ->with($this->identicalTo($this->glyph_stub))
289 ->willReturnSelf();
290 $this->button_mock
291 ->expects($this->once())
292 ->method('withOnClick')
293 ->with($this->identicalTo($show_signal))
294 ->willReturnSelf();
295
296 $link_transfer = $this->getUIFactory()->transfer()->link(
298 $this->uri_stub,
299 $link_label,
300 );
301
302 // only the button and modal are rendered directly; the image and glyph
303 // are consumed by mocked components and never reach the renderer.
304 $renderer = $this->getDefaultRenderer(null, [$this->button_mock, $this->modal_mock]);
305
306 $expected = <<<HTML
307<div id="id_1" class="c-transfer c-transfer-link">
308 <label for="id_1_value">$link_label</label>
309 <div class="c-transfer__contents">
310 <input id="id_1_value" class="c-transfer__payload visible" type="url" value="$this->uri_stub_value" readonly="readonly">
311 $this->button_mock_html{$this->modal_mock_html}
312 </div>
313</div>
314HTML;
315
316 $actual = $renderer->render($link_transfer);
317
318 $this->assertSame($this->brutallyTrimHTML($expected), $this->brutallyTrimHTML($actual));
319 }
@ QR_CODE
Transfer information by copying its contents to the computers clipboard.

References $renderer, getUIFactory(), and ILIAS\UI\Component\Transfer\QR_CODE.

+ Here is the call graph for this function:

◆ testRenderWithWebShreTransferMechanism()

LinkTransferTest::testRenderWithWebShreTransferMechanism ( )

Definition at line 186 of file LinkTransferTest.php.

186 : void
187 {
188 $link_label = sha1('testRenderWithWebShreTransferMechanism');
189 $link_transfer = $this->getUIFactory()->transfer()->link(
190 C\Transfer\TransferMechanism::WEB_SHARE,
191 $this->uri_stub,
192 $link_label,
193 );
194
195 $renderer = $this->getDefaultRenderer(null, [$this->glyph_stub]);
196
197 $expected_transfer_type = C\Transfer\TransferMechanism::WEB_SHARE->value;
198 $expected = <<<HTML
199<div id="id_2" class="c-transfer c-transfer-link">
200 <label for="id_2_value">$link_label</label>
201 <div class="c-transfer__contents">
202 <input id="id_2_value" class="c-transfer__payload visible" type="url" value="$this->uri_stub_value" readonly="readonly">
203 <div class="c-tooltip__container">
204 <button data-transfer-type="$expected_transfer_type" class="btn btn-default" aria-label="open_web_share_api_aria">
205 <span data-transfer-status="default" class="visible">$this->glyph_stub_html</span>
206 <span data-transfer-status="success" data-transfer-message="open_web_share_api_success" class="hidden">$this->glyph_stub_html</span>
207 <span data-transfer-status="failure" data-transfer-message="open_web_share_api_failure" class="hidden">$this->glyph_stub_html</span>
208 <span>open_web_share_api</span>
209 </button>
210 <div id="id_1" role="status" class="c-tooltip c-tooltip--hidden">
211 <p></p>
212 </div>
213 </div>
214 </div>
215</div>
216HTML;
217
218 $actual = $renderer->render($link_transfer);
219
220 $this->assertSame($this->brutallyTrimHTML($expected), $this->brutallyTrimHTML($actual));
221 }

References $renderer, ILIAS\Repository\button(), and getUIFactory().

+ Here is the call graph for this function:

◆ testWithAdditionalTransferMechanismOrderPreservation()

LinkTransferTest::testWithAdditionalTransferMechanismOrderPreservation ( )

Definition at line 321 of file LinkTransferTest.php.

321 : void
322 {
323 $initial = C\Transfer\TransferMechanism::CLIPBOARD;
324 $first = C\Transfer\TransferMechanism::WEB_SHARE;
326
327 $link_transfer = $this->getUIFactory()->transfer()->link($initial, $this->uri_stub, '');
328 $this->assertSame([$initial], array_values($link_transfer->getTransferMechanisms()));
329
330 $link_transfer = $link_transfer->withAdditionalTransferMechanism($first);
331 $this->assertSame([$initial, $first], array_values($link_transfer->getTransferMechanisms()));
332
333 $link_transfer = $link_transfer->withAdditionalTransferMechanism($second);
334 $this->assertSame([$initial, $first, $second], array_values($link_transfer->getTransferMechanisms()));
335
336 // should not alter the previous ordering
337 $link_transfer = $link_transfer->withAdditionalTransferMechanism($second);
338 $link_transfer = $link_transfer->withAdditionalTransferMechanism($first);
339
340 $this->assertSame([$initial, $first, $second], array_values($link_transfer->getTransferMechanisms()));
341 }

References getUIFactory(), and ILIAS\UI\Component\Transfer\QR_CODE.

+ Here is the call graph for this function:

Field Documentation

◆ $button_factory_mock

I Button Factory& MockObject LinkTransferTest::$button_factory_mock
protected

Definition at line 45 of file LinkTransferTest.php.

Referenced by getUIFactory().

◆ $button_mock

I Button Standard& MockObject LinkTransferTest::$button_mock
protected

Definition at line 39 of file LinkTransferTest.php.

◆ $button_mock_html

string LinkTransferTest::$button_mock_html
protected

Definition at line 38 of file LinkTransferTest.php.

◆ $from_svg_mock

ILIAS Refinery Transformation& MockObject LinkTransferTest::$from_svg_mock
protected

Definition at line 50 of file LinkTransferTest.php.

◆ $glyph_stub

I Symbol Glyph Glyph& Stub LinkTransferTest::$glyph_stub
protected

Definition at line 36 of file LinkTransferTest.php.

◆ $glyph_stub_html

string LinkTransferTest::$glyph_stub_html
protected

Definition at line 35 of file LinkTransferTest.php.

◆ $image_factory_mock

I Image Factory& MockObject LinkTransferTest::$image_factory_mock
protected

Definition at line 47 of file LinkTransferTest.php.

Referenced by getUIFactory().

◆ $image_mock

I Image Image& MockObject LinkTransferTest::$image_mock
protected

Definition at line 43 of file LinkTransferTest.php.

◆ $image_mock_html

string LinkTransferTest::$image_mock_html
protected

Definition at line 42 of file LinkTransferTest.php.

◆ $modal_factory_mock

I Modal Factory& MockObject LinkTransferTest::$modal_factory_mock
protected

Definition at line 46 of file LinkTransferTest.php.

Referenced by getUIFactory().

◆ $modal_mock

I Modal RoundTrip& MockObject LinkTransferTest::$modal_mock
protected

Definition at line 41 of file LinkTransferTest.php.

◆ $modal_mock_html

string LinkTransferTest::$modal_mock_html
protected

Definition at line 40 of file LinkTransferTest.php.

◆ $to_svg_qr_code_mock

ILIAS Refinery Transformation& MockObject LinkTransferTest::$to_svg_qr_code_mock
protected

Definition at line 49 of file LinkTransferTest.php.

◆ $uri_stub

ILIAS Data URI& Stub LinkTransferTest::$uri_stub
protected

Definition at line 34 of file LinkTransferTest.php.

◆ $uri_stub_value

string LinkTransferTest::$uri_stub_value
protected

Definition at line 33 of file LinkTransferTest.php.


The documentation for this class was generated from the following file: