ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
BulkyButtonTest Class Reference

Test on button implementation. More...

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

Public Member Functions

 setUp ()
 
 test_implements_factory_interface ()
 
 test_construction_icon_type_wrong ()
 
 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 ()
 
- 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 Member Functions

 getHtmlWithGlyph (bool $engeagable=false, bool $engeaged=false)
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Test on button implementation.

Definition at line 15 of file BulkyButtonTest.php.

Member Function Documentation

◆ getHtmlWithGlyph()

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

Definition at line 144 of file BulkyButtonTest.php.

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().

145  {
146  $aria_pressed = "";
147  $engaged_class = "";
148  if ($engeagable) {
149  if ($engeagable) {
150  $aria_pressed = " aria-pressed='true'";
151  $engaged_class = " engaged";
152  } else {
153  $aria_pressed = " aria-pressed='false'";
154  $engaged_class = " disengaged";
155  }
156  }
157  return ''
158  . '<button class="btn btn-bulky' . $engaged_class . '" data-action="http://www.ilias.de" id="id_1" ' . $aria_pressed . '>'
159  . ' <span class="glyph" aria-label="briefcase" role="img">'
160  . ' <span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span>'
161  . ' </span>'
162  . ' <span class="bulky-label">label</span>'
163  . '</button>';
164  }
+ Here is the caller graph for this function:

◆ setUp()

BulkyButtonTest::setUp ( )

Definition at line 17 of file BulkyButtonTest.php.

17  : void
18  {
19  $this->button_factory = new I\Component\Button\Factory();
20  $this->glyph = new I\Component\Symbol\Glyph\Glyph("briefcase", "briefcase");
21  $this->icon = new I\Component\Symbol\Icon\Standard("someExample", "Example", "small", false);
22  }

◆ test_construction_icon_type_wrong()

BulkyButtonTest::test_construction_icon_type_wrong ( )

Definition at line 32 of file BulkyButtonTest.php.

References Vendor\Package\$f.

33  {
34  $this->expectException(\TypeError::class);
35 
36  $f = $this->button_factory;
37  $f->bulky(new StdClass(), "", "http://www.ilias.de");
38  }

◆ test_engageable_disengaged()

BulkyButtonTest::test_engageable_disengaged ( )

Definition at line 73 of file BulkyButtonTest.php.

References Vendor\Package\$b.

74  {
75  $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de");
76  $this->assertFalse($b->isEngaged());
77  $this->assertFalse($b->isEngageable());
78 
79  $b = $b->withEngagedState(false);
80  $this->assertInstanceOf(
81  "ILIAS\\UI\\Component\\Button\\Bulky",
82  $b
83  );
84  $this->assertFalse($b->isEngaged());
85  $this->assertTrue($b->isEngageable());
86  }

◆ test_engaged()

BulkyButtonTest::test_engaged ( )

Definition at line 58 of file BulkyButtonTest.php.

References Vendor\Package\$b.

59  {
60  $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de");
61  $this->assertFalse($b->isEngaged());
62  $this->assertFalse($b->isEngageable());
63 
64  $b = $b->withEngagedState(true);
65  $this->assertInstanceOf(
66  "ILIAS\\UI\\Component\\Button\\Bulky",
67  $b
68  );
69  $this->assertTrue($b->isEngaged());
70  $this->assertTrue($b->isEngageable());
71  }

◆ test_glyph_or_icon_for_glyph()

BulkyButtonTest::test_glyph_or_icon_for_glyph ( )

Definition at line 40 of file BulkyButtonTest.php.

References Vendor\Package\$b.

41  {
42  $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de");
43  $this->assertEquals(
44  $this->glyph,
45  $b->getIconOrGlyph()
46  );
47  }

◆ test_glyph_or_icon_for_icon()

BulkyButtonTest::test_glyph_or_icon_for_icon ( )

Definition at line 49 of file BulkyButtonTest.php.

References Vendor\Package\$b.

50  {
51  $b = $this->button_factory->bulky($this->icon, "label", "http://www.ilias.de");
52  $this->assertEquals(
53  $this->icon,
54  $b->getIconOrGlyph()
55  );
56  }

◆ test_implements_factory_interface()

BulkyButtonTest::test_implements_factory_interface ( )

Definition at line 24 of file BulkyButtonTest.php.

25  {
26  $this->assertInstanceOf(
27  "ILIAS\\UI\\Component\\Button\\Bulky",
28  $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
29  );
30  }

◆ test_render_button_with_aria_role_menuitem_is_engageable()

BulkyButtonTest::test_render_button_with_aria_role_menuitem_is_engageable ( )

Definition at line 201 of file BulkyButtonTest.php.

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

202  {
203  $r = $this->getDefaultRenderer();
204  $b = $this->button_factory->bulky($this->icon, "label", "http://www.ilias.de")
205  ->withEngagedState(false)
206  ->withAriaRole(I\Component\Button\Bulky::MENUITEM);
207 
208  $expected = ''
209  . '<button class="btn btn-bulky" data-action="http://www.ilias.de" id="id_1" role="menuitem" aria-haspopup="true">'
210  . ' <img class="icon someExample small" src="./templates/default/images/icon_default.svg" alt="Example"/>'
211  . ' <span class="bulky-label">label</span>'
212  . '</button>';
213 
214  $this->assertHTMLEquals(
215  $expected,
216  $r->render($b)
217  );
218  }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ 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 183 of file BulkyButtonTest.php.

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

184  {
185  $r = $this->getDefaultRenderer();
186  $b = $this->button_factory->bulky($this->icon, "label", "http://www.ilias.de")
187  ->withAriaRole(I\Component\Button\Bulky::MENUITEM);
188 
189  $expected = ''
190  . '<button class="btn btn-bulky" data-action="http://www.ilias.de" id="id_1" role="menuitem">'
191  . ' <img class="icon someExample small" src="./templates/default/images/icon_default.svg" alt="Example"/>'
192  . ' <span class="bulky-label">label</span>'
193  . '</button>';
194 
195  $this->assertHTMLEquals(
196  $expected,
197  $r->render($b)
198  );
199  }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_with_glyph_in_context()

BulkyButtonTest::test_render_with_glyph_in_context ( )

Definition at line 110 of file BulkyButtonTest.php.

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

111  {
112  $r = $this->getDefaultRenderer();
113  $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de");
114 
115  $this->assertHTMLEquals(
116  $this->getHtmlWithGlyph(),
117  $r->render($b)
118  );
119  }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getHtmlWithGlyph(bool $engeagable=false, bool $engeaged=false)
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ 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 133 of file BulkyButtonTest.php.

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

134  {
135  $r = $this->getDefaultRenderer();
136  $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
137  ->withEngagedState(true);
138  $this->assertHTMLEquals(
139  $this->getHtmlWithGlyph(true),
140  $r->render($b)
141  );
142  }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getHtmlWithGlyph(bool $engeagable=false, bool $engeaged=false)
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ 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 121 of file BulkyButtonTest.php.

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

122  {
123  $r = $this->getDefaultRenderer();
124  $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
125  ->withEngagedState(true);
126 
127  $this->assertHTMLEquals(
128  $this->getHtmlWithGlyph(true, true),
129  $r->render($b)
130  );
131  }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getHtmlWithGlyph(bool $engeagable=false, bool $engeaged=false)
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_with_icon()

BulkyButtonTest::test_render_with_icon ( )

Definition at line 166 of file BulkyButtonTest.php.

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

167  {
168  $r = $this->getDefaultRenderer();
169  $b = $this->button_factory->bulky($this->icon, "label", "http://www.ilias.de");
170 
171  $expected = ''
172  . '<button class="btn btn-bulky" data-action="http://www.ilias.de" id="id_1">'
173  . ' <img class="icon someExample small" src="./templates/default/images/icon_default.svg" alt="Example"/>'
174  . ' <span class="bulky-label">label</span>'
175  . '</button>';
176 
177  $this->assertHTMLEquals(
178  $expected,
179  $r->render($b)
180  );
181  }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_with_aria_role()

BulkyButtonTest::test_with_aria_role ( )

Definition at line 88 of file BulkyButtonTest.php.

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

89  {
90  try {
91  $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
92  ->withAriaRole(I\Component\Button\Bulky::MENUITEM);
93  $this->assertEquals("menuitem", $b->getAriaRole());
94  } catch (\InvalidArgumentException $e) {
95  $this->assertFalse("This should not happen");
96  }
97  }

◆ test_with_aria_role_incorrect()

BulkyButtonTest::test_with_aria_role_incorrect ( )

Definition at line 99 of file BulkyButtonTest.php.

References Vendor\Package\$e.

100  {
101  try {
102  $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
103  ->withAriaRole("loremipsum");
104  $this->assertFalse("This should not happen");
105  } catch (\InvalidArgumentException $e) {
106  $this->assertTrue(true);
107  }
108  }

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