ILIAS  release_8 Revision v8.24
LinkTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../Base.php");
23
25
30{
31 public function getLinkFactory(): I\Link\Factory
32 {
33 return new I\Link\Factory();
34 }
35
36 public function test_implements_factory_interface(): void
37 {
38 $f = $this->getLinkFactory();
39
40 $this->assertInstanceOf("ILIAS\\UI\\Component\\Link\\Factory", $f);
41 $this->assertInstanceOf(
42 "ILIAS\\UI\\Component\\Link\\Standard",
43 $f->standard("label", "http://www.ilias.de")
44 );
45 }
46
47 public function test_get_label(): void
48 {
49 $f = $this->getLinkFactory();
50 $c = $f->standard("label", "http://www.ilias.de");
51
52 $this->assertEquals("label", $c->getLabel());
53 }
54
55 public function test_get_action(): void
56 {
57 $f = $this->getLinkFactory();
58 $c = $f->standard("label", "http://www.ilias.de");
59
60 $this->assertEquals("http://www.ilias.de", $c->getAction());
61 }
62
63 public function test_render_link(): void
64 {
65 $f = $this->getLinkFactory();
66 $r = $this->getDefaultRenderer();
67
68 $c = $f->standard("label", "http://www.ilias.de");
69
70 $html = $r->render($c);
71
72 $expected_html =
73 '<a href="http://www.ilias.de">label</a>';
74
75 $this->assertHTMLEquals($expected_html, $html);
76 }
77
78 public function test_render_with_new_viewport(): void
79 {
80 $f = $this->getLinkFactory();
81 $r = $this->getDefaultRenderer();
82
83 $c = $f->standard("label", "http://www.ilias.de")->withOpenInNewViewport(true);
84
85 $html = $r->render($c);
86
87 $expected_html =
88 '<a href="http://www.ilias.de" target="_blank" rel="noopener">label</a>';
89
90 $this->assertHTMLEquals($expected_html, $html);
91 }
92}
Provides common functionality for UI tests.
Definition: Base.php:299
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: LinkTest.php:30
test_implements_factory_interface()
Definition: LinkTest.php:36
test_render_with_new_viewport()
Definition: LinkTest.php:78
test_render_link()
Definition: LinkTest.php:63
test_get_label()
Definition: LinkTest.php:47
test_get_action()
Definition: LinkTest.php:55
getLinkFactory()
Definition: LinkTest.php:31
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...