19declare(strict_types=1);
23use PHPUnit\Framework\TestCase;
33use PHPUnit\Framework\MockObject\MockObject;
45 return new class ($icon, $link, $legacy, $src_from_irss) extends
Renderer {
46 protected ?string $icon_src = null;
47 protected ?
string $icon_alt =
null;
48 protected ?
string $link_label =
null;
49 protected ?
string $link_action =
null;
51 protected ?
bool $link_disabled =
null;
52 protected ?
string $legacy_text =
null;
58 protected string $src_from_irss
62 protected function getFallBackSrc(): string
64 return 'fallback src';
67 protected function customIcon(
string $src,
string $alt): Icon
69 $this->icon_src = $src;
70 $this->icon_alt = $alt;
74 protected function standardLink(
80 $this->link_label = $label;
81 $this->link_action = $action;
82 $this->link_relationship = $relationship;
83 $this->link_disabled = $disabled;
87 protected function textInLegacy(
string $text): Content
89 $this->legacy_text =
$text;
93 protected function getSourceFromIRSS(
string $string_id): string
95 return $this->src_from_irss;
98 public function exposeImageData(): array
101 'icon_src' => $this->icon_src,
102 'icon_alt' => $this->icon_alt
106 public function exposeLinkData(): array
109 'link_label' => $this->link_label,
110 'link_action' => $this->link_action,
111 'link_relationship' => $this->link_relationship,
112 'link_disabled' => $this->link_disabled
116 public function exposeLegacyData(): array
119 'legacy_text' => $this->legacy_text
127 return $this->getMockBuilder(IIcon::class)
128 ->disableOriginalConstructor()
134 return $this->getMockBuilder(ILink::class)
135 ->disableOriginalConstructor()
136 ->onlyMethods([
'withAdditionalRelationshipToReferencedResource'])
142 return $this->getMockBuilder(ILegacy::class)
143 ->disableOriginalConstructor()
149 $uri = $this->getMockBuilder(URI::class)
150 ->disableOriginalConstructor()
152 $uri->method(
'__toString')->willReturn($link);
158 $link = $this->getMockLink();
159 $uri = $this->getMockURI(
'link');
160 $img_uri = $this->getMockURI(
'image link');
163 $this->getMockIcon(),
165 $this->getMockLegacy(),
171 protected URI $img_uri
175 public function fullName():
string
185 public function hasImage():
bool
190 public function isImageLink():
bool
195 public function imageLink(): ?
URI
197 return $this->img_uri;
200 public function altText():
string
207 $this->assertSame(2, count($result));
208 $this->assertInstanceOf(Icon::class, $result[0]);
209 $this->assertInstanceOf(Link::class, $result[1]);
212 'icon_src' =>
'image link',
213 'icon_alt' =>
'alt text'
219 'link_label' =>
'full name',
220 'link_action' =>
'link',
221 'link_relationship' => Relationship::LICENSE,
222 'link_disabled' =>
false
230 $legacy = $this->getMockLegacy();
233 $this->getMockIcon(),
234 $this->getMockLink(),
240 $this->assertSame(0, count($result));
245 $uri = $this->getMockURI(
'image link');
248 $this->getMockIcon(),
249 $this->getMockLink(),
250 $this->getMockLegacy(),
258 public function fullName():
string
263 public function hasImage():
bool
268 public function isImageLink():
bool
273 public function imageLink(): ?
URI
278 public function altText():
string
285 $this->assertSame(2, count($result));
286 $this->assertInstanceOf(Icon::class, $result[0]);
287 $this->assertInstanceOf(Content::class, $result[1]);
290 'icon_src' =>
'image link',
291 'icon_alt' =>
'alt text'
296 [
'legacy_text' =>
'full name'],
303 $link = $this->getMockLink();
304 $uri = $this->getMockURI(
'link');
307 $this->getMockIcon(),
309 $this->getMockLegacy(),
317 public function fullName():
string
329 $this->assertSame(1, count($result));
330 $this->assertInstanceOf(Link::class, $result[0]);
333 'link_label' =>
'full name',
334 'link_action' =>
'link',
335 'link_relationship' => Relationship::LICENSE,
336 'link_disabled' =>
false
344 $link = $this->getMockLink();
345 $uri = $this->getMockURI(
'link');
348 $this->getMockIcon(),
350 $this->getMockLegacy(),
365 $this->assertSame(1, count($result));
366 $this->assertInstanceOf(Link::class, $result[0]);
369 'link_label' =>
'link',
370 'link_action' =>
'link',
371 'link_relationship' => Relationship::LICENSE,
372 'link_disabled' =>
false
380 $uri = $this->getMockURI(
'image link');
383 $this->getMockIcon(),
384 $this->getMockLink(),
385 $this->getMockLegacy(),
393 public function hasImage():
bool
398 public function isImageLink():
bool
403 public function imageLink(): ?
URI
408 public function altText():
string
415 $this->assertSame(1, count($result));
416 $this->assertInstanceOf(Icon::class, $result[0]);
419 'icon_src' =>
'image link',
420 'icon_alt' =>
'alt text'
428 $uri = $this->getMockURI(
'image link');
431 $this->getMockIcon(),
432 $this->getMockLink(),
433 $this->getMockLegacy(),
441 public function hasImage():
bool
446 public function imageFile():
string
448 return 'some string';
451 public function altText():
string
458 $this->assertSame(1, count($result));
459 $this->assertInstanceOf(Icon::class, $result[0]);
462 'icon_src' =>
'image link',
463 'icon_alt' =>
'alt text'
472 $this->getMockIcon(),
473 $this->getMockLink(),
474 $this->getMockLegacy(),
478 public function fallBackToDefaultImage():
bool
485 $this->assertSame(1, count($result));
486 $this->assertInstanceOf(Icon::class, $result[0]);
489 'icon_src' =>
'fallback src',
498 $uri = $this->getMockURI(
'image link');
501 $this->getMockIcon(),
502 $this->getMockLink(),
503 $this->getMockLegacy(),
511 public function hasImage():
bool
516 public function isImageLink():
bool
521 public function imageLink(): ?
URI
526 public function altText():
string
533 $this->assertNotNull($result);
536 'icon_src' =>
'image link',
537 'icon_alt' =>
'alt text'
545 $uri = $this->getMockURI(
'image link');
548 $this->getMockIcon(),
549 $this->getMockLink(),
550 $this->getMockLegacy(),
558 public function hasImage():
bool
563 public function imageFile():
string
565 return 'some string';
568 public function altText():
string
575 $this->assertNotNull($result);
578 'icon_src' =>
'image link',
579 'icon_alt' =>
'alt text'
588 $this->getMockIcon(),
589 $this->getMockLink(),
590 $this->getMockLegacy(),
594 public function fallBackToDefaultImage():
bool
601 $this->assertNotNull($result);
604 'icon_src' =>
'fallback src',
614 $this->getMockIcon(),
615 $this->getMockLink(),
616 $this->getMockLegacy(),
622 $this->assertNull($result);
627 $link = $this->getMockLink();
628 $uri = $this->getMockURI(
'link');
631 $this->getMockIcon(),
633 $this->getMockLegacy(),
642 public function fullName():
string
654 $this->assertNotNull($result);
657 'link_label' =>
'full name',
658 'link_action' =>
'link',
659 'link_relationship' => Relationship::LICENSE,
660 'link_disabled' =>
false
669 $this->getMockIcon(),
670 $this->getMockLink(),
671 $this->getMockLegacy(),
676 $this->assertNull($result);
681 $link = $this->getMockLink();
683 $this->getMockIcon(),
685 $this->getMockLegacy(),
689 public function fullName():
string
696 $this->assertNotNull($result);
699 'link_label' =>
'full name',
701 'link_relationship' =>
null,
702 'link_disabled' =>
true
710 $link = $this->getMockLink();
711 $uri = $this->getMockURI(
'link');
714 $this->getMockIcon(),
716 $this->getMockLegacy(),
731 $this->assertNotNull($result);
734 'link_label' =>
'link',
735 'link_action' =>
'link',
736 'link_relationship' => Relationship::LICENSE,
737 'link_disabled' =>
false
746 $this->getMockIcon(),
747 $this->getMockLink(),
748 $this->getMockLegacy(),
752 public function fullName():
string
754 return 'full name of copyright';
764 'full name of copyright',
772 $this->getMockIcon(),
773 $this->getMockLink(),
774 $this->getMockLegacy(),
777 $uri = $this->getMockURI(
'http://www.example2.com');
783 public function fullName():
string
795 'http://www.example2.com',
803 $this->getMockIcon(),
804 $this->getMockLink(),
805 $this->getMockLegacy(),
808 $uri = $this->getMockURI(
'http://www.example2.com');
814 public function fullName():
string
816 return 'full name of copyright';
826 'full name of copyright http://www.example2.com',
834 $this->getMockIcon(),
835 $this->getMockLink(),
836 $this->getMockLegacy(),
840 public function fullName():
string
Builds a Color from either hex- or rgb values.
A Link is the often used combination of a label and an URL.
The scope of this class is split ilias-conform URI's into components.
This implements commonalities between Links.
__construct()
Constructor setup ILIAS global object @access public.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
The filesystem interface provides the public interface for the Filesystem service API consumer.
This describes how an icon could be modified during construction of UI.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
link(string $caption, string $href, bool $new_viewport=false)
Relationship
Note that not all valid values of the rel-attribute of anchor tags are included here (see https://htm...