ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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_construction_label_type_wrong ()
 
 test_construction_action_type_wrong ()
 
 test_glyph_or_icon_for_glyph ()
 
 test_glyph_or_icon_for_icon ()
 
 test_engaged ()
 
 test_render_with_glyph_in_context ()
 
 test_render_with_glyph_in_context_and_engaged ()
 
 test_render_with_icon ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Detailed Description

Test on button implementation.

Definition at line 15 of file BulkyButtonTest.php.

Member Function Documentation

◆ setUp()

BulkyButtonTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 17 of file BulkyButtonTest.php.

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

◆ test_construction_action_type_wrong()

BulkyButtonTest::test_construction_action_type_wrong ( )

Definition at line 55 of file BulkyButtonTest.php.

56 {
57 $f = $this->button_factory;
58 $icon = $this->createMock(ILIAS\UI\Component\Icon\Icon::class);
59 try {
60 $f->bulky($icon, "", 1);
61 $this->assertFalse("This should not happen");
62 } catch (\InvalidArgumentException $e) {
63 $this->assertTrue(true);
64 }
65 }
Class BaseForm.
Class Factory.

References $f.

◆ test_construction_icon_type_wrong()

BulkyButtonTest::test_construction_icon_type_wrong ( )

Definition at line 32 of file BulkyButtonTest.php.

33 {
34 $f = $this->button_factory;
35 try {
36 $f->bulky(new StdClass(), "", "http://www.ilias.de");
37 $this->assertFalse("This should not happen");
38 } catch (\InvalidArgumentException $e) {
39 $this->assertTrue(true);
40 }
41 }

References $f.

◆ test_construction_label_type_wrong()

BulkyButtonTest::test_construction_label_type_wrong ( )

Definition at line 43 of file BulkyButtonTest.php.

44 {
45 $f = $this->button_factory;
46 $icon = $this->createMock(ILIAS\UI\Component\Icon\Icon::class);
47 try {
48 $f->bulky($icon, 1, "http://www.ilias.de");
49 $this->assertFalse("This should not happen");
50 } catch (\InvalidArgumentException $e) {
51 $this->assertTrue(true);
52 }
53 }

References $f.

◆ test_engaged()

BulkyButtonTest::test_engaged ( )

Definition at line 85 of file BulkyButtonTest.php.

86 {
87 $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de");
88 $this->assertFalse($b->isEngaged());
89
90 $b = $b->withEngagedState(true);
91 $this->assertInstanceOf(
92 "ILIAS\\UI\\Component\\Button\\Bulky",
93 $b
94 );
95 $this->assertTrue($b->isEngaged());
96 }

◆ test_glyph_or_icon_for_glyph()

BulkyButtonTest::test_glyph_or_icon_for_glyph ( )

Definition at line 67 of file BulkyButtonTest.php.

68 {
69 $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de");
70 $this->assertEquals(
71 $this->glyph,
72 $b->getIconOrGlyph()
73 );
74 }

◆ test_glyph_or_icon_for_icon()

BulkyButtonTest::test_glyph_or_icon_for_icon ( )

Definition at line 76 of file BulkyButtonTest.php.

77 {
78 $b = $this->button_factory->bulky($this->icon, "label", "http://www.ilias.de");
79 $this->assertEquals(
80 $this->icon,
81 $b->getIconOrGlyph()
82 );
83 }

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

BulkyButtonTest::test_render_with_glyph_in_context ( )

Definition at line 98 of file BulkyButtonTest.php.

99 {
100 $r = $this->getDefaultRenderer();
101 $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de");
102
103 $expected = ''
104 . '<button class="btn btn-bulky" data-action="http://www.ilias.de" id="id_1" aria-pressed="undefined">'
105 . ' <span class="glyph" aria-label="briefcase">'
106 . ' <span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span>'
107 . ' </span>'
108 . ' <div><span class="bulky-label">label</span></div>'
109 . '</button>';
110
111 $this->assertHTMLEquals(
112 $expected,
113 $r->render($b)
114 );
115 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
$r
Definition: example_031.php:79

References $r, ILIAS_UI_TestBase\assertHTMLEquals(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ 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 117 of file BulkyButtonTest.php.

118 {
119 $r = $this->getDefaultRenderer();
120 $b = $this->button_factory->bulky($this->glyph, "label", "http://www.ilias.de")
121 ->withEngagedState(true);
122 $expected = ''
123 . '<button class="btn btn-bulky engaged" data-action="http://www.ilias.de" id="id_1" aria-pressed="true">'
124 . ' <span class="glyph" aria-label="briefcase">'
125 . ' <span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span>'
126 . ' </span>'
127 . ' <div><span class="bulky-label">label</span></div>'
128 . '</button>';
129
130 $this->assertHTMLEquals(
131 $expected,
132 $r->render($b)
133 );
134 }

References $r, ILIAS_UI_TestBase\assertHTMLEquals(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ test_render_with_icon()

BulkyButtonTest::test_render_with_icon ( )

Definition at line 136 of file BulkyButtonTest.php.

137 {
138 $r = $this->getDefaultRenderer();
139 $b = $this->button_factory->bulky($this->icon, "label", "http://www.ilias.de");
140
141 $expected = ''
142 . '<button class="btn btn-bulky" data-action="http://www.ilias.de" id="id_1" aria-pressed="undefined">'
143 . ' <div class="icon someExample small" aria-label="Example"></div>'
144 . ' <div><span class="bulky-label">label</span></div>'
145 . '</button>';
146
147 $this->assertHTMLEquals(
148 $expected,
149 $r->render($b)
150 );
151 }

References $r, ILIAS_UI_TestBase\assertHTMLEquals(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

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