ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\MetaData\Copyright\RendererTest Class Reference
+ Inheritance diagram for ILIAS\MetaData\Copyright\RendererTest:
+ Collaboration diagram for ILIAS\MetaData\Copyright\RendererTest:

Public Member Functions

 testToUIComponentsWithLinkAndImage ()
 
 testToUIComponentsEmpty ()
 
 testToUIComponentsWithoutLink ()
 
 testToUIComponentsWithLinkNoImage ()
 
 testToUIComponentsLinkWithoutFullName ()
 
 testToUIComponentsWithImageFromLink ()
 
 testToUIComponentsWithImageFromIRSS ()
 
 testToUIComponentsWithFallbackImage ()
 

Protected Member Functions

 getMockRenderer (Icon $icon, Link $link, Legacy $legacy, string $src_from_irss)
 
 getMockIcon ()
 
 getMockLink ()
 
 getMockLegacy ()
 
 getMockURI (string $link)
 

Detailed Description

Definition at line 37 of file RendererTest.php.

Member Function Documentation

◆ getMockIcon()

◆ getMockLegacy()

◆ getMockLink()

ILIAS\MetaData\Copyright\RendererTest::getMockLink ( )
protected

◆ getMockRenderer()

ILIAS\MetaData\Copyright\RendererTest::getMockRenderer ( Icon  $icon,
Link  $link,
Legacy  $legacy,
string  $src_from_irss 
)
protected

PhpUndefinedMethodInspection

PhpUndefinedMethodInspection

PhpUndefinedMethodInspection

Definition at line 39 of file RendererTest.php.

References ILIAS\__construct(), ILIAS\UI\examples\MainControls\Slate\Legacy\legacy(), and ILIAS\Repository\link().

Referenced by ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsEmpty(), ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsLinkWithoutFullName(), ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsWithFallbackImage(), ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsWithImageFromIRSS(), ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsWithImageFromLink(), ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsWithLinkAndImage(), ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsWithLinkNoImage(), and ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsWithoutLink().

44  : Renderer {
45  return new class ($icon, $link, $legacy, $src_from_irss) extends Renderer {
46  public function __construct(
47  protected Icon $icon,
48  protected Link $link,
49  protected Legacy $legacy,
50  protected string $src_from_irss
51  ) {
52  }
53 
54  protected function getFallBackSrc(): string
55  {
56  return 'fallback src';
57  }
58 
59  protected function customIcon(string $src, string $alt): Icon
60  {
62  $this->icon->checkParams($src, $alt);
63  return $this->icon;
64  }
65 
66  protected function standardLink(string $label, string $action): Link
67  {
69  $this->link->checkParams($label, $action);
70  return $this->link;
71  }
72 
73  protected function textInLegacy(string $text): Legacy
74  {
76  $this->legacy->checkParams($text);
77  return $this->legacy;
78  }
79 
80  protected function getSourceFromIRSS(string $string_id): string
81  {
82  return $this->src_from_irss;
83  }
84  };
85  }
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:62
link(string $caption, string $href, bool $new_viewport=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMockURI()

ILIAS\MetaData\Copyright\RendererTest::getMockURI ( string  $link)
protected

Definition at line 112 of file RendererTest.php.

Referenced by ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsLinkWithoutFullName(), ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsWithImageFromIRSS(), ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsWithImageFromLink(), ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsWithLinkAndImage(), ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsWithLinkNoImage(), and ILIAS\MetaData\Copyright\RendererTest\testToUIComponentsWithoutLink().

112  : URI
113  {
114  $uri = $this->getMockBuilder(URI::class)
115  ->disableOriginalConstructor()
116  ->getMock();
117  $uri->method('__toString')->willReturn($link);
118  return $uri;
119  }
+ Here is the caller graph for this function:

◆ testToUIComponentsEmpty()

ILIAS\MetaData\Copyright\RendererTest::testToUIComponentsEmpty ( )

Definition at line 187 of file RendererTest.php.

References ILIAS\MetaData\Copyright\RendererTest\getMockIcon(), ILIAS\MetaData\Copyright\RendererTest\getMockLegacy(), ILIAS\MetaData\Copyright\RendererTest\getMockLink(), and ILIAS\MetaData\Copyright\RendererTest\getMockRenderer().

187  : void
188  {
189  $legacy = $this->getMockLegacy();
190 
191  $renderer = $this->getMockRenderer(
192  $this->getMockIcon(),
193  $this->getMockLink(),
194  $legacy,
195  ''
196  );
197 
198  $result = $renderer->toUIComponents(new NullCopyrightData());
199  $this->assertSame(0, count($result));
200  }
getMockRenderer(Icon $icon, Link $link, Legacy $legacy, string $src_from_irss)
+ Here is the call graph for this function:

◆ testToUIComponentsLinkWithoutFullName()

ILIAS\MetaData\Copyright\RendererTest::testToUIComponentsLinkWithoutFullName ( )

Definition at line 296 of file RendererTest.php.

References $data, ILIAS\__construct(), ILIAS\MetaData\Copyright\RendererTest\getMockIcon(), ILIAS\MetaData\Copyright\RendererTest\getMockLegacy(), ILIAS\MetaData\Copyright\RendererTest\getMockLink(), ILIAS\MetaData\Copyright\RendererTest\getMockRenderer(), ILIAS\MetaData\Copyright\RendererTest\getMockURI(), and ILIAS\Repository\link().

296  : void
297  {
298  $link = $this->getMockLink();
299  $link->expects($this->once())
300  ->method('checkParams')
301  ->with('link', 'link');
302  $link->expects($this->once())
303  ->method('withAdditionalRelationshipToReferencedResource')
304  ->with(Relationship::LICENSE);
305  $uri = $this->getMockURI('link');
306 
307  $renderer = $this->getMockRenderer(
308  $this->getMockIcon(),
309  $link,
310  $this->getMockLegacy(),
311  ''
312  );
313  $data = new class ($uri) extends NullCopyrightData {
314  public function __construct(protected URI $uri)
315  {
316  }
317 
318  public function link(): ?URI
319  {
320  return $this->uri;
321  }
322  };
323 
324  $result = $renderer->toUIComponents($data);
325  $this->assertSame(1, count($result));
326  $this->assertInstanceOf(Link::class, $result[0]);
327  }
getMockRenderer(Icon $icon, Link $link, Legacy $legacy, string $src_from_irss)
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:62
link(string $caption, string $href, bool $new_viewport=false)
+ Here is the call graph for this function:

◆ testToUIComponentsWithFallbackImage()

ILIAS\MetaData\Copyright\RendererTest::testToUIComponentsWithFallbackImage ( )

Definition at line 414 of file RendererTest.php.

References $data, ILIAS\MetaData\Copyright\RendererTest\getMockIcon(), ILIAS\MetaData\Copyright\RendererTest\getMockLegacy(), ILIAS\MetaData\Copyright\RendererTest\getMockLink(), and ILIAS\MetaData\Copyright\RendererTest\getMockRenderer().

414  : void
415  {
416  $icon = $this->getMockIcon();
417  $icon->expects($this->once())
418  ->method('checkParams')
419  ->with('fallback src');
420 
421  $renderer = $this->getMockRenderer(
422  $icon,
423  $this->getMockLink(),
424  $this->getMockLegacy(),
425  ''
426  );
427  $data = new class () extends NullCopyrightData {
428  public function fallBackToDefaultImage(): bool
429  {
430  return true;
431  }
432  };
433 
434  $result = $renderer->toUIComponents($data);
435  $this->assertSame(1, count($result));
436  $this->assertInstanceOf(Icon::class, $result[0]);
437  }
getMockRenderer(Icon $icon, Link $link, Legacy $legacy, string $src_from_irss)
+ Here is the call graph for this function:

◆ testToUIComponentsWithImageFromIRSS()

ILIAS\MetaData\Copyright\RendererTest::testToUIComponentsWithImageFromIRSS ( )

Definition at line 374 of file RendererTest.php.

References $data, ILIAS\__construct(), ILIAS\MetaData\Copyright\RendererTest\getMockIcon(), ILIAS\MetaData\Copyright\RendererTest\getMockLegacy(), ILIAS\MetaData\Copyright\RendererTest\getMockLink(), ILIAS\MetaData\Copyright\RendererTest\getMockRenderer(), and ILIAS\MetaData\Copyright\RendererTest\getMockURI().

374  : void
375  {
376  $icon = $this->getMockIcon();
377  $icon->expects($this->once())
378  ->method('checkParams')
379  ->with('image link', 'alt text');
380  $uri = $this->getMockURI('image link');
381 
382  $renderer = $this->getMockRenderer(
383  $icon,
384  $this->getMockLink(),
385  $this->getMockLegacy(),
386  'image link'
387  );
388  $data = new class ($uri) extends NullCopyrightData {
389  public function __construct(protected URI $uri)
390  {
391  }
392 
393  public function hasImage(): bool
394  {
395  return true;
396  }
397 
398  public function imageFile(): string
399  {
400  return 'some string';
401  }
402 
403  public function altText(): string
404  {
405  return 'alt text';
406  }
407  };
408 
409  $result = $renderer->toUIComponents($data);
410  $this->assertSame(1, count($result));
411  $this->assertInstanceOf(Icon::class, $result[0]);
412  }
getMockRenderer(Icon $icon, Link $link, Legacy $legacy, string $src_from_irss)
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:62
+ Here is the call graph for this function:

◆ testToUIComponentsWithImageFromLink()

ILIAS\MetaData\Copyright\RendererTest::testToUIComponentsWithImageFromLink ( )

Definition at line 329 of file RendererTest.php.

References $data, ILIAS\__construct(), ILIAS\MetaData\Copyright\RendererTest\getMockIcon(), ILIAS\MetaData\Copyright\RendererTest\getMockLegacy(), ILIAS\MetaData\Copyright\RendererTest\getMockLink(), ILIAS\MetaData\Copyright\RendererTest\getMockRenderer(), and ILIAS\MetaData\Copyright\RendererTest\getMockURI().

329  : void
330  {
331  $icon = $this->getMockIcon();
332  $icon->expects($this->once())
333  ->method('checkParams')
334  ->with('image link', 'alt text');
335  $uri = $this->getMockURI('image link');
336 
337  $renderer = $this->getMockRenderer(
338  $icon,
339  $this->getMockLink(),
340  $this->getMockLegacy(),
341  ''
342  );
343  $data = new class ($uri) extends NullCopyrightData {
344  public function __construct(protected URI $uri)
345  {
346  }
347 
348  public function hasImage(): bool
349  {
350  return true;
351  }
352 
353  public function isImageLink(): bool
354  {
355  return true;
356  }
357 
358  public function imageLink(): ?URI
359  {
360  return $this->uri;
361  }
362 
363  public function altText(): string
364  {
365  return 'alt text';
366  }
367  };
368 
369  $result = $renderer->toUIComponents($data);
370  $this->assertSame(1, count($result));
371  $this->assertInstanceOf(Icon::class, $result[0]);
372  }
getMockRenderer(Icon $icon, Link $link, Legacy $legacy, string $src_from_irss)
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:62
+ Here is the call graph for this function:

◆ testToUIComponentsWithLinkAndImage()

ILIAS\MetaData\Copyright\RendererTest::testToUIComponentsWithLinkAndImage ( )

Definition at line 121 of file RendererTest.php.

References $data, ILIAS\__construct(), ILIAS\MetaData\Copyright\RendererTest\getMockIcon(), ILIAS\MetaData\Copyright\RendererTest\getMockLegacy(), ILIAS\MetaData\Copyright\RendererTest\getMockLink(), ILIAS\MetaData\Copyright\RendererTest\getMockRenderer(), ILIAS\MetaData\Copyright\RendererTest\getMockURI(), and ILIAS\Repository\link().

121  : void
122  {
123  $icon = $this->getMockIcon();
124  $icon->expects($this->once())
125  ->method('checkParams')
126  ->with('image link', 'alt text');
127  $link = $this->getMockLink();
128  $link->expects($this->once())
129  ->method('checkParams')
130  ->with('full name', 'link');
131  $link->expects($this->once())
132  ->method('withAdditionalRelationshipToReferencedResource')
133  ->with(Relationship::LICENSE);
134  $uri = $this->getMockURI('link');
135  $img_uri = $this->getMockURI('image link');
136 
137  $renderer = $this->getMockRenderer(
138  $icon,
139  $link,
140  $this->getMockLegacy(),
141  ''
142  );
143  $data = new class ($uri, $img_uri) extends NullCopyrightData {
144  public function __construct(
145  protected URI $uri,
146  protected URI $img_uri
147  ) {
148  }
149 
150  public function fullName(): string
151  {
152  return 'full name';
153  }
154 
155  public function link(): ?URI
156  {
157  return $this->uri;
158  }
159 
160  public function hasImage(): bool
161  {
162  return true;
163  }
164 
165  public function isImageLink(): bool
166  {
167  return true;
168  }
169 
170  public function imageLink(): ?URI
171  {
172  return $this->img_uri;
173  }
174 
175  public function altText(): string
176  {
177  return 'alt text';
178  }
179  };
180 
181  $result = $renderer->toUIComponents($data);
182  $this->assertSame(2, count($result));
183  $this->assertInstanceOf(Icon::class, $result[0]);
184  $this->assertInstanceOf(Link::class, $result[1]);
185  }
getMockRenderer(Icon $icon, Link $link, Legacy $legacy, string $src_from_irss)
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:62
link(string $caption, string $href, bool $new_viewport=false)
+ Here is the call graph for this function:

◆ testToUIComponentsWithLinkNoImage()

ILIAS\MetaData\Copyright\RendererTest::testToUIComponentsWithLinkNoImage ( )

Definition at line 258 of file RendererTest.php.

References $data, ILIAS\__construct(), ILIAS\MetaData\Copyright\RendererTest\getMockIcon(), ILIAS\MetaData\Copyright\RendererTest\getMockLegacy(), ILIAS\MetaData\Copyright\RendererTest\getMockLink(), ILIAS\MetaData\Copyright\RendererTest\getMockRenderer(), ILIAS\MetaData\Copyright\RendererTest\getMockURI(), and ILIAS\Repository\link().

258  : void
259  {
260  $link = $this->getMockLink();
261  $link->expects($this->once())
262  ->method('checkParams')
263  ->with('full name', 'link');
264  $link->expects($this->once())
265  ->method('withAdditionalRelationshipToReferencedResource')
266  ->with(Relationship::LICENSE);
267  $uri = $this->getMockURI('link');
268 
269  $renderer = $this->getMockRenderer(
270  $this->getMockIcon(),
271  $link,
272  $this->getMockLegacy(),
273  ''
274  );
275  $data = new class ($uri) extends NullCopyrightData {
276  public function __construct(protected URI $uri)
277  {
278  }
279 
280  public function fullName(): string
281  {
282  return 'full name';
283  }
284 
285  public function link(): ?URI
286  {
287  return $this->uri;
288  }
289  };
290 
291  $result = $renderer->toUIComponents($data);
292  $this->assertSame(1, count($result));
293  $this->assertInstanceOf(Link::class, $result[0]);
294  }
getMockRenderer(Icon $icon, Link $link, Legacy $legacy, string $src_from_irss)
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:62
link(string $caption, string $href, bool $new_viewport=false)
+ Here is the call graph for this function:

◆ testToUIComponentsWithoutLink()

ILIAS\MetaData\Copyright\RendererTest::testToUIComponentsWithoutLink ( )

Definition at line 202 of file RendererTest.php.

References $data, ILIAS\__construct(), ILIAS\MetaData\Copyright\RendererTest\getMockIcon(), ILIAS\MetaData\Copyright\RendererTest\getMockLegacy(), ILIAS\MetaData\Copyright\RendererTest\getMockLink(), ILIAS\MetaData\Copyright\RendererTest\getMockRenderer(), and ILIAS\MetaData\Copyright\RendererTest\getMockURI().

202  : void
203  {
204  $legacy = $this->getMockLegacy();
205  $legacy->expects($this->once())
206  ->method('checkParams')
207  ->with('full name');
208 
209  $icon = $this->getMockIcon();
210  $icon->expects($this->once())
211  ->method('checkParams')
212  ->with('image link', 'alt text');
213  $uri = $this->getMockURI('image link');
214 
215  $renderer = $this->getMockRenderer(
216  $icon,
217  $this->getMockLink(),
218  $legacy,
219  ''
220  );
221  $data = new class ($uri) extends NullCopyrightData {
222  public function __construct(protected URI $uri)
223  {
224  }
225 
226  public function fullName(): string
227  {
228  return 'full name';
229  }
230 
231  public function hasImage(): bool
232  {
233  return true;
234  }
235 
236  public function isImageLink(): bool
237  {
238  return true;
239  }
240 
241  public function imageLink(): ?URI
242  {
243  return $this->uri;
244  }
245 
246  public function altText(): string
247  {
248  return 'alt text';
249  }
250  };
251 
252  $result = $renderer->toUIComponents($data);
253  $this->assertSame(2, count($result));
254  $this->assertInstanceOf(Icon::class, $result[0]);
255  $this->assertInstanceOf(Legacy::class, $result[1]);
256  }
getMockRenderer(Icon $icon, Link $link, Legacy $legacy, string $src_from_irss)
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:62
+ Here is the call graph for this function:

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