ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
LinkTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
21 require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
22 require_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 }
test_render_with_new_viewport()
Definition: LinkTest.php:78
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...
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getLinkFactory()
Definition: LinkTest.php:31
test_get_action()
Definition: LinkTest.php:55
test_render_link()
Definition: LinkTest.php:63
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: LinkTest.php:29
Provides common functionality for UI tests.
Definition: Base.php:298
test_implements_factory_interface()
Definition: LinkTest.php:36
test_get_label()
Definition: LinkTest.php:47