ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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_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_icon ()
 
 test_render_button_with_aria_role ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Additional Inherited Members

- 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

◆ 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_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 
63  $b = $b->withEngagedState(true);
64  $this->assertInstanceOf(
65  "ILIAS\\UI\\Component\\Button\\Bulky",
66  $b
67  );
68  $this->assertTrue($b->isEngaged());
69  }

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

BulkyButtonTest::test_render_button_with_aria_role ( )

Definition at line 148 of file BulkyButtonTest.php.

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

149  {
150  $r = $this->getDefaultRenderer();
151  $b = $this->button_factory->bulky($this->icon, "label", "http://www.ilias.de")
152  ->withAriaRole(I\Component\Button\Bulky::MENUITEM);
153 
154  $expected = ''
155  . '<button class="btn btn-bulky" data-action="http://www.ilias.de" id="id_1" role="menuitem" aria-haspopup="true">'
156  . ' <div class="icon someExample small" aria-label="Example"></div>'
157  . ' <span class="bulky-label">label</span>'
158  . '</button>';
159 
160  $this->assertHTMLEquals(
161  $expected,
162  $r->render($b)
163  );
164  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_render_with_glyph_in_context()

BulkyButtonTest::test_render_with_glyph_in_context ( )

Definition at line 93 of file BulkyButtonTest.php.

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

94  {
95  $r = $this->getDefaultRenderer();
96  $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de");
97 
98  $expected = ''
99  . '<button class="btn btn-bulky" data-action="http://www.ilias.de" id="id_1">'
100  . ' <span class="glyph" aria-label="briefcase">'
101  . ' <span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span>'
102  . ' </span>'
103  . ' <span class="bulky-label">label</span>'
104  . '</button>';
105 
106  $this->assertHTMLEquals(
107  $expected,
108  $r->render($b)
109  );
110  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ 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 112 of file BulkyButtonTest.php.

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

113  {
114  $r = $this->getDefaultRenderer();
115  $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
116  ->withEngagedState(true);
117  $expected = ''
118  . '<button class="btn btn-bulky engaged" data-action="http://www.ilias.de" id="id_1" aria-pressed="true">'
119  . ' <span class="glyph" aria-label="briefcase">'
120  . ' <span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span>'
121  . ' </span>'
122  . ' <span class="bulky-label">label</span>'
123  . '</button>';
124 
125  $this->assertHTMLEquals(
126  $expected,
127  $r->render($b)
128  );
129  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_render_with_icon()

BulkyButtonTest::test_render_with_icon ( )

Definition at line 131 of file BulkyButtonTest.php.

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

132  {
133  $r = $this->getDefaultRenderer();
134  $b = $this->button_factory->bulky($this->icon, "label", "http://www.ilias.de");
135 
136  $expected = ''
137  . '<button class="btn btn-bulky" data-action="http://www.ilias.de" id="id_1">'
138  . ' <div class="icon someExample small" aria-label="Example"></div>'
139  . ' <span class="bulky-label">label</span>'
140  . '</button>';
141 
142  $this->assertHTMLEquals(
143  $expected,
144  $r->render($b)
145  );
146  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_with_aria_role()

BulkyButtonTest::test_with_aria_role ( )

Definition at line 71 of file BulkyButtonTest.php.

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

72  {
73  try {
74  $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
75  ->withAriaRole(I\Component\Button\Bulky::MENUITEM);
76  $this->assertEquals("menuitem", $b->getAriaRole());
77  } catch (\InvalidArgumentException $e) {
78  $this->assertFalse("This should not happen");
79  }
80  }

◆ test_with_aria_role_incorrect()

BulkyButtonTest::test_with_aria_role_incorrect ( )

Definition at line 82 of file BulkyButtonTest.php.

References Vendor\Package\$e.

83  {
84  try {
85  $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
86  ->withAriaRole("loremipsum");
87  $this->assertFalse("This should not happen");
88  } catch (\InvalidArgumentException $e) {
89  $this->assertTrue(true);
90  }
91  }

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