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

Test on card implementation. More...

+ Inheritance diagram for DropdownTest:
+ Collaboration diagram for DropdownTest:

Public Member Functions

 test_implements_factory_interface ()
 
 test_with_label ()
 
 test_with_items ()
 
 test_render_empty ()
 
 test_render_items ()
 
 test_render_items_with_label ()
 
 test_render_with_link_new_viewport ()
 
 test_render_items_with_aria_label ()
 
- 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

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

Detailed Description

Test on card implementation.

Definition at line 14 of file DropdownTest.php.

Member Function Documentation

◆ getFactory()

DropdownTest::getFactory ( )
protected

Definition at line 16 of file DropdownTest.php.

17 {
18 return new I\Component\Dropdown\Factory();
19 }

Referenced by test_implements_factory_interface(), test_render_empty(), test_render_items(), test_render_items_with_aria_label(), test_render_items_with_label(), test_render_with_link_new_viewport(), test_with_items(), and test_with_label().

+ Here is the caller graph for this function:

◆ test_implements_factory_interface()

DropdownTest::test_implements_factory_interface ( )

Definition at line 21 of file DropdownTest.php.

22 {
23 $f = $this->getFactory();
24
25 $this->assertInstanceOf("ILIAS\\UI\\Component\\Dropdown\\Standard", $f->standard(array()));
26 }

References Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ test_render_empty()

DropdownTest::test_render_empty ( )

Definition at line 55 of file DropdownTest.php.

56 {
57 $f = $this->getFactory();
58 $r = $this->getDefaultRenderer();
59
60 $c = $f->standard(array());
61
62 $html = $r->render($c);
63 $expected = "";
64
65 $this->assertEquals($expected, $html);
66 }
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
$c
Definition: cli.php:37

References $c, Vendor\Package\$f, ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

+ Here is the call graph for this function:

◆ test_render_items()

DropdownTest::test_render_items ( )

Definition at line 68 of file DropdownTest.php.

69 {
70 $f = $this->getFactory();
71 $r = $this->getDefaultRenderer();
72
73 $c = $f->standard(array(
74 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
75 new I\Component\Divider\Horizontal(),
76 new I\Component\Button\Shy("GitHub", "https://www.github.com")
77 ));
78
79 $html = $r->render($c);
80
81 $expected = <<<EOT
82 <div class="dropdown">
83 <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-label="actions" aria-haspopup="true" aria-expanded="false">
84 <span class="caret"></span>
85 </button>
86 <ul class="dropdown-menu">
87 <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1">ILIAS</button></li>
88 <li><hr /></li>
89 <li><button class="btn btn-link" data-action="https://www.github.com" id="id_2">GitHub</button></li>
90 </ul>
91 </div>
92EOT;
93
94 $this->assertHTMLEquals($expected, $html);
95 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
Class ChatMainBarProvider \MainMenu\Provider.

References $c, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

+ Here is the call graph for this function:

◆ test_render_items_with_aria_label()

DropdownTest::test_render_items_with_aria_label ( )

Definition at line 147 of file DropdownTest.php.

148 {
149 $f = $this->getFactory();
150 $r = $this->getDefaultRenderer();
151
152 $c = $f->standard(array(
153 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
154 new I\Component\Divider\Horizontal(),
155 new I\Component\Button\Shy("GitHub", "https://www.github.com")
156 ))->withLabel("label")->withAriaLabel("my_aria_label");
157
158 $html = $r->render($c);
159
160 $expected = <<<EOT
161 <div class="dropdown"><button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-label="my_aria_label" aria-haspopup="true" aria-expanded="false">label <span class="caret"></span></button>
162 <ul class="dropdown-menu">
163 <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1">ILIAS</button></li>
164 <li><hr /></li>
165 <li><button class="btn btn-link" data-action="https://www.github.com" id="id_2">GitHub</button></li>
166 </ul>
167 </div>
168EOT;
169
170 $this->assertHTMLEquals($expected, $html);
171 }

References $c, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

+ Here is the call graph for this function:

◆ test_render_items_with_label()

DropdownTest::test_render_items_with_label ( )

Definition at line 97 of file DropdownTest.php.

98 {
99 $f = $this->getFactory();
100 $r = $this->getDefaultRenderer();
101
102 $c = $f->standard(array(
103 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
104 new I\Component\Divider\Horizontal(),
105 new I\Component\Button\Shy("GitHub", "https://www.github.com")
106 ))->withLabel("label");
107
108 $html = $r->render($c);
109
110 $expected = <<<EOT
111 <div class="dropdown"><button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">label <span class="caret"></span></button>
112 <ul class="dropdown-menu">
113 <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1">ILIAS</button></li>
114 <li><hr /></li>
115 <li><button class="btn btn-link" data-action="https://www.github.com" id="id_2">GitHub</button></li>
116 </ul>
117 </div>
118EOT;
119
120 $this->assertHTMLEquals($expected, $html);
121 }

References $c, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

+ Here is the call graph for this function:

◆ test_render_with_link_new_viewport()

DropdownTest::test_render_with_link_new_viewport ( )

Definition at line 123 of file DropdownTest.php.

124 {
125 $f = $this->getFactory();
126 $r = $this->getDefaultRenderer();
127
128 $link = new I\Component\Link\Standard("Link to ILIAS", "http://www.ilias.de");
129
130 $c = $f->standard(array(
131 $link->withOpenInNewViewport(true)
132 ));
133
134 $html = $r->render($c);
135
136 $expected = <<<EOT
137 <div class="dropdown"><button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-label="actions" aria-haspopup="true" aria-expanded="false"><span class="caret"></span></button>
138 <ul class="dropdown-menu">
139 <li><a href="http://www.ilias.de" target="_blank" rel="noopener">Link to ILIAS</a></li>
140 </ul>
141 </div>
142EOT;
143
144 $this->assertHTMLEquals($expected, $html);
145 }

References $c, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

+ Here is the call graph for this function:

◆ test_with_items()

DropdownTest::test_with_items ( )

Definition at line 37 of file DropdownTest.php.

38 {
39 $f = $this->getFactory();
40 $link = new I\Component\Link\Standard("Link to Github", "http://www.github.com");
41 $c = $f->standard(array(
42 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
43 new I\Component\Button\Shy("GitHub", "https://www.github.com"),
44 new I\Component\Divider\Horizontal(),
45 $link->withOpenInNewViewport(true)
46 ));
47 $items = $c->getItems();
48
49 $this->assertTrue(is_array($items));
50 $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Shy", $items[0]);
51 $this->assertInstanceOf("ILIAS\\UI\\Component\\Divider\\Horizontal", $items[2]);
52 $this->assertInstanceOf("ILIAS\\UI\\Component\\Link\\Standard", $items[3]);
53 }

References $c, Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ test_with_label()

DropdownTest::test_with_label ( )

Definition at line 28 of file DropdownTest.php.

29 {
30 $f = $this->getFactory();
31
32 $c = $f->standard(array())->withLabel("label");
33
34 $this->assertEquals($c->getLabel(), "label");
35 }

References $c, Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

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