ILIAS  release_8 Revision v8.24
BulkyButtonTest Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for BulkyButtonTest:
+ Collaboration diagram for BulkyButtonTest:

Public Member Functions

 setUp ()
 
 test_implements_factory_interface ()
 
 test_glyph_or_icon_for_glyph ()
 
 test_glyph_or_icon_for_icon ()
 
 test_engaged ()
 
 test_engageable_disengaged ()
 
 test_with_aria_role ()
 
 test_with_aria_role_incorrect ()
 
 test_render_with_glyph_in_context ()
 
 test_render_with_glyph_in_context_and_engaged ()
 
 test_render_with_glyph_in_context_and_disengaged ()
 
 test_render_with_icon ()
 
 test_render_button_with_aria_role_menuitem_not_engageable ()
 
 test_render_button_with_aria_role_menuitem_is_engageable ()
 
 testRenderWithLabelAndAltImageSame ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 getHtmlWithGlyph (bool $engeagable=false, bool $engeaged=false)
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Private Attributes

I Component Button Factory $button_factory
 
I Component Symbol Glyph Glyph $glyph
 
I Component Symbol Icon Standard $icon
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Test on button implementation.

Definition at line 30 of file BulkyButtonTest.php.

Member Function Documentation

◆ getHtmlWithGlyph()

BulkyButtonTest::getHtmlWithGlyph ( bool  $engeagable = false,
bool  $engeaged = false 
)
protected

Definition at line 165 of file BulkyButtonTest.php.

165 : string
166 {
167 $aria_pressed = "";
168 $engaged_class = "";
169 if ($engeagable) {
170 if ($engeagable) {
171 $aria_pressed = " aria-pressed='true'";
172 $engaged_class = " engaged";
173 } else {
174 $aria_pressed = " aria-pressed='false'";
175 $engaged_class = " disengaged";
176 }
177 }
178 return ''
179 . '<button class="btn btn-bulky' . $engaged_class . '" data-action="http://www.ilias.de" id="id_1" ' . $aria_pressed . '>'
180 . ' <span class="glyph" role="img">'
181 . ' <span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span>'
182 . ' </span>'
183 . ' <span class="bulky-label">label</span>'
184 . '</button>';
185 }

Referenced by test_render_with_glyph_in_context(), test_render_with_glyph_in_context_and_disengaged(), and test_render_with_glyph_in_context_and_engaged().

+ Here is the caller graph for this function:

◆ setUp()

BulkyButtonTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 36 of file BulkyButtonTest.php.

36 : void
37 {
38 $this->button_factory = new I\Component\Button\Factory();
39 $this->glyph = new I\Component\Symbol\Glyph\Glyph("briefcase", "briefcase");
40 $this->icon = new I\Component\Symbol\Icon\Standard("someExample", "Example", "small", false);
41 }

◆ test_engageable_disengaged()

BulkyButtonTest::test_engageable_disengaged ( )

Definition at line 94 of file BulkyButtonTest.php.

94 : void
95 {
96 $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de");
97 $this->assertFalse($b->isEngaged());
98 $this->assertFalse($b->isEngageable());
99
100 $b = $b->withEngagedState(false);
101 $this->assertInstanceOf(
102 "ILIAS\\UI\\Component\\Button\\Bulky",
103 $b
104 );
105 $this->assertFalse($b->isEngaged());
106 $this->assertTrue($b->isEngageable());
107 }

References Vendor\Package\$b.

◆ test_engaged()

BulkyButtonTest::test_engaged ( )

Definition at line 79 of file BulkyButtonTest.php.

79 : void
80 {
81 $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de");
82 $this->assertFalse($b->isEngaged());
83 $this->assertFalse($b->isEngageable());
84
85 $b = $b->withEngagedState(true);
86 $this->assertInstanceOf(
87 "ILIAS\\UI\\Component\\Button\\Bulky",
88 $b
89 );
90 $this->assertTrue($b->isEngaged());
91 $this->assertTrue($b->isEngageable());
92 }

References Vendor\Package\$b.

◆ test_glyph_or_icon_for_glyph()

BulkyButtonTest::test_glyph_or_icon_for_glyph ( )

Definition at line 61 of file BulkyButtonTest.php.

61 : void
62 {
63 $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de");
64 $this->assertEquals(
65 $this->glyph,
66 $b->getIconOrGlyph()
67 );
68 }

References Vendor\Package\$b.

◆ test_glyph_or_icon_for_icon()

BulkyButtonTest::test_glyph_or_icon_for_icon ( )

Definition at line 70 of file BulkyButtonTest.php.

70 : void
71 {
72 $b = $this->button_factory->bulky($this->icon, "label", "http://www.ilias.de");
73 $this->assertEquals(
74 $this->icon,
75 $b->getIconOrGlyph()
76 );
77 }

References Vendor\Package\$b.

◆ test_implements_factory_interface()

BulkyButtonTest::test_implements_factory_interface ( )

Definition at line 43 of file BulkyButtonTest.php.

43 : void
44 {
45 $this->assertInstanceOf(
46 "ILIAS\\UI\\Component\\Button\\Bulky",
47 $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
48 );
49 }

◆ test_render_button_with_aria_role_menuitem_is_engageable()

BulkyButtonTest::test_render_button_with_aria_role_menuitem_is_engageable ( )

Definition at line 222 of file BulkyButtonTest.php.

222 : void
223 {
224 $r = $this->getDefaultRenderer();
225 $b = $this->button_factory->bulky($this->icon, "label", "http://www.ilias.de")
226 ->withEngagedState(false)
227 ->withAriaRole(I\Component\Button\Bulky::MENUITEM);
228
229 $expected = ''
230 . '<button class="btn btn-bulky" data-action="http://www.ilias.de" id="id_1" role="menuitem" aria-haspopup="true">'
231 . ' <img class="icon someExample small" src="./templates/default/images/icon_default.svg" alt=""/>'
232 . ' <span class="bulky-label">label</span>'
233 . '</button>';
234
235 $this->assertHTMLEquals(
236 $expected,
237 $r->render($b)
238 );
239 }
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: Bulky.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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

+ Here is the call graph for this function:

◆ test_render_button_with_aria_role_menuitem_not_engageable()

BulkyButtonTest::test_render_button_with_aria_role_menuitem_not_engageable ( )

Definition at line 204 of file BulkyButtonTest.php.

204 : void
205 {
206 $r = $this->getDefaultRenderer();
207 $b = $this->button_factory->bulky($this->icon, "label", "http://www.ilias.de")
208 ->withAriaRole(I\Component\Button\Bulky::MENUITEM);
209
210 $expected = ''
211 . '<button class="btn btn-bulky" data-action="http://www.ilias.de" id="id_1" role="menuitem">'
212 . ' <img class="icon someExample small" src="./templates/default/images/icon_default.svg" alt=""/>'
213 . ' <span class="bulky-label">label</span>'
214 . '</button>';
215
216 $this->assertHTMLEquals(
217 $expected,
218 $r->render($b)
219 );
220 }

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

+ Here is the call graph for this function:

◆ test_render_with_glyph_in_context()

BulkyButtonTest::test_render_with_glyph_in_context ( )

Definition at line 131 of file BulkyButtonTest.php.

131 : void
132 {
133 $r = $this->getDefaultRenderer();
134 $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de");
135
136 $this->assertHTMLEquals(
137 $this->getHtmlWithGlyph(),
138 $r->render($b)
139 );
140 }
getHtmlWithGlyph(bool $engeagable=false, bool $engeaged=false)

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

+ Here is the call graph for this function:

◆ test_render_with_glyph_in_context_and_disengaged()

BulkyButtonTest::test_render_with_glyph_in_context_and_disengaged ( )

Definition at line 154 of file BulkyButtonTest.php.

154 : void
155 {
156 $r = $this->getDefaultRenderer();
157 $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
158 ->withEngagedState(true);
159 $this->assertHTMLEquals(
160 $this->getHtmlWithGlyph(true),
161 $r->render($b)
162 );
163 }

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

+ Here is the call graph for this function:

◆ test_render_with_glyph_in_context_and_engaged()

BulkyButtonTest::test_render_with_glyph_in_context_and_engaged ( )

Definition at line 142 of file BulkyButtonTest.php.

142 : void
143 {
144 $r = $this->getDefaultRenderer();
145 $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
146 ->withEngagedState(true);
147
148 $this->assertHTMLEquals(
149 $this->getHtmlWithGlyph(true, true),
150 $r->render($b)
151 );
152 }

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

+ Here is the call graph for this function:

◆ test_render_with_icon()

BulkyButtonTest::test_render_with_icon ( )

Definition at line 187 of file BulkyButtonTest.php.

187 : void
188 {
189 $r = $this->getDefaultRenderer();
190 $b = $this->button_factory->bulky($this->icon, "label", "http://www.ilias.de");
191
192 $expected = ''
193 . '<button class="btn btn-bulky" data-action="http://www.ilias.de" id="id_1">'
194 . ' <img class="icon someExample small" src="./templates/default/images/icon_default.svg" alt=""/>'
195 . ' <span class="bulky-label">label</span>'
196 . '</button>';
197
198 $this->assertHTMLEquals(
199 $expected,
200 $r->render($b)
201 );
202 }

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

+ Here is the call graph for this function:

◆ test_with_aria_role()

BulkyButtonTest::test_with_aria_role ( )

Definition at line 109 of file BulkyButtonTest.php.

109 : void
110 {
111 try {
112 $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
113 ->withAriaRole(I\Component\Button\Bulky::MENUITEM);
114 $this->assertEquals("menuitem", $b->getAriaRole());
115 } catch (InvalidArgumentException $e) {
116 $this->assertFalse("This should not happen");
117 }
118 }

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

◆ test_with_aria_role_incorrect()

BulkyButtonTest::test_with_aria_role_incorrect ( )

Definition at line 120 of file BulkyButtonTest.php.

120 : void
121 {
122 try {
123 $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
124 ->withAriaRole("loremipsum");
125 $this->assertFalse("This should not happen");
126 } catch (InvalidArgumentException $e) {
127 $this->assertTrue(true);
128 }
129 }

References Vendor\Package\$e.

◆ testRenderWithLabelAndAltImageSame()

BulkyButtonTest::testRenderWithLabelAndAltImageSame ( )

Definition at line 241 of file BulkyButtonTest.php.

241 : void
242 {
243 $r = $this->getDefaultRenderer();
244 $b = $this->button_factory->bulky($this->icon, "Example", "http://www.ilias.de")
245 ->withEngagedState(false)
246 ->withAriaRole(I\Component\Button\Bulky::MENUITEM);
247
248 $expected = ''
249 . '<button class="btn btn-bulky" data-action="http://www.ilias.de" id="id_1" role="menuitem" aria-haspopup="true">'
250 . ' <img class="icon someExample small" src="./templates/default/images/icon_default.svg" alt=""/>'
251 . ' <span class="bulky-label">Example</span>'
252 . '</button>';
253
254 $this->assertHTMLEquals(
255 $expected,
256 $r->render($b)
257 );
258 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $button_factory

I Component Button Factory BulkyButtonTest::$button_factory
private

Definition at line 32 of file BulkyButtonTest.php.

◆ $glyph

I Component Symbol Glyph Glyph BulkyButtonTest::$glyph
private

Definition at line 33 of file BulkyButtonTest.php.

◆ $icon

I Component Symbol Icon Standard BulkyButtonTest::$icon
private

Definition at line 34 of file BulkyButtonTest.php.


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