ILIAS  release_7 Revision v7.30-3-g800a261c036
BulkyLinkTest Class Reference

Testing behavior of the Bulky Link. More...

+ Inheritance diagram for BulkyLinkTest:
+ Collaboration diagram for BulkyLinkTest:

Public Member Functions

 setUp ()
 
 testImplementsInterfaces ()
 
 testWrongConstruction ()
 
 testWithAriaRole ()
 
 testWithAriaRoleIncorrect ()
 
 testGetLabell ()
 
 testGetGlyphSymbol ()
 
 testGetAction ()
 
 testRenderingGlyph ()
 
 testRenderingIcon ()
 
 testRenderingWithId ()
 
 testRenderWithAriaRoleMenuitem ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Attributes

 $factory
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Testing behavior of the Bulky Link.

Definition at line 14 of file BulkyLinkTest.php.

Member Function Documentation

◆ setUp()

BulkyLinkTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 21 of file BulkyLinkTest.php.

21 : void
22 {
23 $this->factory = new I\Link\Factory();
24 $this->glyph = new I\Symbol\Glyph\Glyph("briefcase", "briefcase");
25 $this->icon = new I\Symbol\Icon\Standard("someExample", "Example", "small", false);
26 $this->target = new \ILIAS\Data\URI("http://www.ilias.de");
27 }

◆ testGetAction()

BulkyLinkTest::testGetAction ( )

Definition at line 79 of file BulkyLinkTest.php.

80 {
81 $plain = "http://www.ilias.de";
82 $with_query = $plain . "?query1=1";
83 $with_multi_query = $with_query . "&query2=2";
84 $with_fragment = $plain . "#fragment";
85 $with_multi_query_and_fragment_uri = $with_multi_query . $with_fragment;
86
87 $plain_uri = new \ILIAS\Data\URI($plain);
88 $with_query_uri = new \ILIAS\Data\URI($with_query);
89 $with_multi_query_uri = new \ILIAS\Data\URI($with_multi_query);
90 $with_fragment_uri = new \ILIAS\Data\URI($with_fragment);
91 $with_multi_query_and_fragment_uri = new \ILIAS\Data\URI($with_multi_query_and_fragment_uri);
92
93 $this->assertEquals($plain, $this->factory->bulky($this->glyph, "label", $plain_uri)->getAction());
94 $this->assertEquals($with_query, $this->factory->bulky($this->glyph, "label", $with_query_uri)->getAction());
95 $this->assertEquals($with_multi_query, $this->factory->bulky($this->glyph, "label", $with_multi_query_uri)->getAction());
96 $this->assertEquals($with_fragment_uri, $this->factory->bulky($this->glyph, "label", $with_fragment_uri)->getAction());
97 $this->assertEquals($with_multi_query_and_fragment_uri, $this->factory->bulky($this->glyph, "label", $with_multi_query_and_fragment_uri)->getAction());
98 }

◆ testGetGlyphSymbol()

BulkyLinkTest::testGetGlyphSymbol ( )

Definition at line 71 of file BulkyLinkTest.php.

72 {
73 $link = $this->factory->bulky($this->glyph, "label", $this->target);
74 $this->assertEquals($this->glyph, $link->getSymbol());
75 $link = $this->factory->bulky($this->icon, "label", $this->target);
76 $this->assertEquals($this->icon, $link->getSymbol());
77 }

◆ testGetLabell()

BulkyLinkTest::testGetLabell ( )

Definition at line 64 of file BulkyLinkTest.php.

65 {
66 $label = 'some label for the link';
67 $link = $this->factory->bulky($this->glyph, $label, $this->target);
68 $this->assertEquals($label, $link->getLabel());
69 }

◆ testImplementsInterfaces()

BulkyLinkTest::testImplementsInterfaces ( )

Definition at line 29 of file BulkyLinkTest.php.

30 {
31 $link = $this->factory->bulky($this->glyph, "label", $this->target);
32 $this->assertInstanceOf(C\Bulky::class, $link);
33 $this->assertInstanceOf(C\Link::class, $link);
34 }

◆ testRenderingGlyph()

BulkyLinkTest::testRenderingGlyph ( )

Definition at line 100 of file BulkyLinkTest.php.

101 {
102 $r = $this->getDefaultRenderer();
103 $b = $this->factory->bulky($this->glyph, "label", $this->target);
104
105 $expected = ''
106 . '<a class="il-link link-bulky" href="http://www.ilias.de">'
107 . ' <span class="glyph" aria-label="briefcase" role="img">'
108 . ' <span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span>'
109 . ' </span>'
110 . ' <span class="bulky-label">label</span>'
111 . '</a>';
112
113 $this->assertHTMLEquals(
114 $expected,
115 $r->render($b)
116 );
117 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311

References Vendor\Package\$b, ILIAS_UI_TestBase\assertHTMLEquals(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ testRenderingIcon()

BulkyLinkTest::testRenderingIcon ( )

Definition at line 119 of file BulkyLinkTest.php.

120 {
121 $r = $this->getDefaultRenderer();
122 $b = $this->factory->bulky($this->icon, "label", $this->target);
123
124 $expected = ''
125 . '<a class="il-link link-bulky" href="http://www.ilias.de">'
126 . ' <img class="icon someExample small" src="./templates/default/images/icon_default.svg" alt="Example"/>'
127 . ' <span class="bulky-label">label</span>'
128 . '</a>';
129
130 $this->assertHTMLEquals(
131 $expected,
132 $r->render($b)
133 );
134 }

References Vendor\Package\$b, ILIAS_UI_TestBase\assertHTMLEquals(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ testRenderingWithId()

BulkyLinkTest::testRenderingWithId ( )

Definition at line 135 of file BulkyLinkTest.php.

136 {
137 $r = $this->getDefaultRenderer();
138 $b = $this->factory->bulky($this->icon, "label", $this->target)
139 ->withAdditionalOnloadCode(function ($id) {
140 return '';
141 });
142
143 $expected = ''
144 . '<a class="il-link link-bulky" href="http://www.ilias.de" id="id_1">'
145 . '<img class="icon someExample small" src="./templates/default/images/icon_default.svg" alt="Example"/>'
146 . ' <span class="bulky-label">label</span>'
147 . '</a>';
148
149 $this->assertHTMLEquals(
150 $expected,
151 $r->render($b)
152 );
153 }

References Vendor\Package\$b, ILIAS_UI_TestBase\assertHTMLEquals(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ testRenderWithAriaRoleMenuitem()

BulkyLinkTest::testRenderWithAriaRoleMenuitem ( )

Definition at line 155 of file BulkyLinkTest.php.

156 {
157 $r = $this->getDefaultRenderer();
158 $b = $this->factory->bulky($this->icon, "label", $this->target)
159 ->withAriaRole(I\Button\Bulky::MENUITEM);
160
161 $expected = ''
162 . '<a class="il-link link-bulky" href="http://www.ilias.de" role="menuitem">'
163 . '<img class="icon someExample small" src="./templates/default/images/icon_default.svg" alt="Example"/>'
164 . ' <span class="bulky-label">label</span>'
165 . '</a>';
166
167 $this->assertHTMLEquals(
168 $expected,
169 $r->render($b)
170 );
171 }

References Vendor\Package\$b, ILIAS_UI_TestBase\assertHTMLEquals(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ testWithAriaRole()

BulkyLinkTest::testWithAriaRole ( )

Definition at line 42 of file BulkyLinkTest.php.

43 {
44 try {
45 $b = $this->factory->bulky($this->glyph, "label", $this->target)
46 ->withAriaRole(I\Button\Bulky::MENUITEM);
47 $this->assertEquals("menuitem", $b->getAriaRole());
48 } catch (\InvalidArgumentException $e) {
49 $this->assertFalse("This should not happen");
50 }
51 }

References Vendor\Package\$b, and Vendor\Package\$e.

◆ testWithAriaRoleIncorrect()

BulkyLinkTest::testWithAriaRoleIncorrect ( )

Definition at line 53 of file BulkyLinkTest.php.

54 {
55 try {
56 $this->factory->bulky($this->glyph, "label", $this->target)
57 ->withAriaRole("loremipsum");
58 $this->assertFalse("This should not happen");
59 } catch (\InvalidArgumentException $e) {
60 $this->assertTrue(true);
61 }
62 }

References Vendor\Package\$e.

◆ testWrongConstruction()

BulkyLinkTest::testWrongConstruction ( )

Definition at line 36 of file BulkyLinkTest.php.

37 {
38 $this->expectException(\TypeError::class);
39 $link = $this->factory->bulky('wrong param', "label", $this->target);
40 }

Field Documentation

◆ $factory

BulkyLinkTest::$factory
protected

Definition at line 19 of file BulkyLinkTest.php.


The documentation for this class was generated from the following file: