ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
LinkTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2017 Alex Killing <killing@leifos.de> Extended GPL, see docs/LICENSE */
4
5require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
6require_once(__DIR__ . "/../../Base.php");
7
8use \ILIAS\UI\Component as C;
9
14{
15 public function getLinkFactory()
16 {
17 return new \ILIAS\UI\Implementation\Component\Link\Factory();
18 }
19
21 {
22 $f = $this->getLinkFactory();
23
24 $this->assertInstanceOf("ILIAS\\UI\\Component\\Link\\Factory", $f);
25 $this->assertInstanceOf(
26 "ILIAS\\UI\\Component\\Link\\Standard",
27 $f->standard("label", "http://www.ilias.de")
28 );
29 }
30
31 public function test_get_label()
32 {
33 $f = $this->getLinkFactory();
34 $c = $f->standard("label", "http://www.ilias.de");
35
36 $this->assertEquals($c->getLabel(), "label");
37 }
38
39 public function test_get_action()
40 {
41 $f = $this->getLinkFactory();
42 $c = $f->standard("label", "http://www.ilias.de");
43
44 $this->assertEquals($c->getAction(), "http://www.ilias.de");
45 }
46
47 public function test_render_link()
48 {
49 $f = $this->getLinkFactory();
50 $r = $this->getDefaultRenderer();
51
52 $c = $f->standard("label", "http://www.ilias.de");
53
54 $html = $r->render($c);
55
56 $expected_html =
57 '<a href="http://www.ilias.de">label</a>';
58
59 $this->assertHTMLEquals($expected_html, $html);
60 }
61
63 {
64 $f = $this->getLinkFactory();
65 $r = $this->getDefaultRenderer();
66
67 $c = $f->standard("label", "http://www.ilias.de")->withOpenInNewViewport(true);
68
69 $html = $r->render($c);
70
71 $expected_html =
72 '<a href="http://www.ilias.de" target="_blank" rel="noopener">label</a>';
73
74 $this->assertHTMLEquals($expected_html, $html);
75 }
76}
An exception for terminatinating execution or to throw for unit testing.
Provides common functionality for UI tests.
Definition: Base.php:225
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
Test on link implementation.
Definition: LinkTest.php:14
test_implements_factory_interface()
Definition: LinkTest.php:20
test_render_with_new_viewport()
Definition: LinkTest.php:62
test_render_link()
Definition: LinkTest.php:47
test_get_label()
Definition: LinkTest.php:31
test_get_action()
Definition: LinkTest.php:39
getLinkFactory()
Definition: LinkTest.php:15