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;
50 protected ?
string $legacy_text =
null;
56 protected string $src_from_irss
60 protected function getFallBackSrc(): string
62 return 'fallback src';
65 protected function customIcon(
string $src,
string $alt): Icon
67 $this->icon_src = $src;
68 $this->icon_alt = $alt;
72 protected function standardLink(
string $label,
string $action):
Link
74 $this->link_label = $label;
75 $this->link_action = $action;
79 protected function textInLegacy(
string $text): Content
81 $this->legacy_text = $text;
85 protected function getSourceFromIRSS(
string $string_id): string
87 return $this->src_from_irss;
90 public function exposeData(): array
93 'icon_src' => $this->icon_src,
94 'icon_alt' => $this->icon_alt,
95 'link_label' => $this->link_label,
96 'link_action' => $this->link_action,
97 'legacy_text' => $this->legacy_text
105 return $this->getMockBuilder(IIcon::class)
106 ->disableOriginalConstructor()
112 return $this->getMockBuilder(ILink::class)
113 ->disableOriginalConstructor()
114 ->onlyMethods([
'withAdditionalRelationshipToReferencedResource'])
120 return $this->getMockBuilder(ILegacy::class)
121 ->disableOriginalConstructor()
127 $uri = $this->getMockBuilder(URI::class)
128 ->disableOriginalConstructor()
130 $uri->method(
'__toString')->willReturn($link);
136 $link = $this->getMockLink();
137 $link->expects($this->once())
138 ->method(
'withAdditionalRelationshipToReferencedResource')
139 ->with(Relationship::LICENSE);
140 $uri = $this->getMockURI(
'link');
141 $img_uri = $this->getMockURI(
'image link');
144 $this->getMockIcon(),
146 $this->getMockLegacy(),
152 protected URI $img_uri
156 public function fullName():
string
166 public function hasImage():
bool
171 public function isImageLink():
bool
176 public function imageLink(): ?
URI
178 return $this->img_uri;
181 public function altText():
string
188 $this->assertSame(2, count($result));
189 $this->assertInstanceOf(Icon::class, $result[0]);
190 $this->assertInstanceOf(Link::class, $result[1]);
193 'icon_src' =>
'image link',
194 'icon_alt' =>
'alt text',
195 'link_label' =>
'full name',
196 'link_action' =>
'link',
197 'legacy_text' =>
null
205 $legacy = $this->getMockLegacy();
208 $this->getMockIcon(),
209 $this->getMockLink(),
215 $this->assertSame(0, count($result));
220 $uri = $this->getMockURI(
'image link');
223 $this->getMockIcon(),
224 $this->getMockLink(),
225 $this->getMockLegacy(),
233 public function fullName():
string
238 public function hasImage():
bool
243 public function isImageLink():
bool
248 public function imageLink(): ?
URI
253 public function altText():
string
260 $this->assertSame(2, count($result));
261 $this->assertInstanceOf(Icon::class, $result[0]);
262 $this->assertInstanceOf(Content::class, $result[1]);
265 'icon_src' =>
'image link',
266 'icon_alt' =>
'alt text',
267 'link_label' =>
null,
268 'link_action' =>
null,
269 'legacy_text' =>
'full name'
277 $link = $this->getMockLink();
278 $link->expects($this->once())
279 ->method(
'withAdditionalRelationshipToReferencedResource')
280 ->with(Relationship::LICENSE);
281 $uri = $this->getMockURI(
'link');
284 $this->getMockIcon(),
286 $this->getMockLegacy(),
294 public function fullName():
string
306 $this->assertSame(1, count($result));
307 $this->assertInstanceOf(Link::class, $result[0]);
312 'link_label' =>
'full name',
313 'link_action' =>
'link',
314 'legacy_text' =>
null
322 $link = $this->getMockLink();
323 $link->expects($this->once())
324 ->method(
'withAdditionalRelationshipToReferencedResource')
325 ->with(Relationship::LICENSE);
326 $uri = $this->getMockURI(
'link');
329 $this->getMockIcon(),
331 $this->getMockLegacy(),
346 $this->assertSame(1, count($result));
347 $this->assertInstanceOf(Link::class, $result[0]);
352 'link_label' =>
'link',
353 'link_action' =>
'link',
354 'legacy_text' =>
null
362 $uri = $this->getMockURI(
'image link');
365 $this->getMockIcon(),
366 $this->getMockLink(),
367 $this->getMockLegacy(),
375 public function hasImage():
bool
380 public function isImageLink():
bool
385 public function imageLink(): ?
URI
390 public function altText():
string
397 $this->assertSame(1, count($result));
398 $this->assertInstanceOf(Icon::class, $result[0]);
401 'icon_src' =>
'image link',
402 'icon_alt' =>
'alt text',
403 'link_label' =>
null,
404 'link_action' =>
null,
405 'legacy_text' =>
null
413 $uri = $this->getMockURI(
'image link');
416 $this->getMockIcon(),
417 $this->getMockLink(),
418 $this->getMockLegacy(),
426 public function hasImage():
bool
431 public function imageFile():
string
433 return 'some string';
436 public function altText():
string
443 $this->assertSame(1, count($result));
444 $this->assertInstanceOf(Icon::class, $result[0]);
447 'icon_src' =>
'image link',
448 'icon_alt' =>
'alt text',
449 'link_label' =>
null,
450 'link_action' =>
null,
451 'legacy_text' =>
null
460 $this->getMockIcon(),
461 $this->getMockLink(),
462 $this->getMockLegacy(),
466 public function fallBackToDefaultImage():
bool
473 $this->assertSame(1, count($result));
474 $this->assertInstanceOf(Icon::class, $result[0]);
477 'icon_src' =>
'fallback src',
479 'link_label' =>
null,
480 'link_action' =>
null,
481 'legacy_text' =>
null
490 $this->getMockIcon(),
491 $this->getMockLink(),
492 $this->getMockLegacy(),
496 public function fullName():
string
498 return 'full name of copyright';
508 'full name of copyright',
516 $this->getMockIcon(),
517 $this->getMockLink(),
518 $this->getMockLegacy(),
521 $uri = $this->getMockURI(
'http://www.example2.com');
527 public function fullName():
string
539 'http://www.example2.com',
547 $this->getMockIcon(),
548 $this->getMockLink(),
549 $this->getMockLegacy(),
552 $uri = $this->getMockURI(
'http://www.example2.com');
558 public function fullName():
string
560 return 'full name of copyright';
570 'full name of copyright http://www.example2.com',
578 $this->getMockIcon(),
579 $this->getMockLink(),
580 $this->getMockLegacy(),
584 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...