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

Test secondary listing panels. More...

+ Inheritance diagram for PanelSecondaryListingTest:
+ Collaboration diagram for PanelSecondaryListingTest:

Public Member Functions

 getUIFactory ()
 
 test_implements_factory_interface ()
 
 test_get_title ()
 
 test_get_item_groups ()
 
 test_with_actions ()
 
 test_render_with_actions ()
 
 test_render_with_sortation ()
 
 test_render_with_pagination ()
 
 test_render_with_section ()
 
 test_render_with_footer ()
 
 test_render_with_no_header_but_content ()
 
 test_render_with_no_header_no_content_no_footer ()
 
- 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

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

Detailed Description

Test secondary listing panels.

Definition at line 15 of file PanelSecondaryListingTest.php.

Member Function Documentation

◆ cleanHTML()

PanelSecondaryListingTest::cleanHTML (   $html)
protected

Definition at line 48 of file PanelSecondaryListingTest.php.

49 {
50 $html = str_replace(["\n", "\t"], "", $html);
51
52 return trim($html);
53 }

Referenced by test_render_with_actions(), test_render_with_footer(), test_render_with_no_header_but_content(), test_render_with_pagination(), test_render_with_section(), and test_render_with_sortation().

+ Here is the caller graph for this function:

◆ getUIFactory()

PanelSecondaryListingTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 17 of file PanelSecondaryListingTest.php.

18 {
19 $factory = new class extends NoUIFactory {
20 public function panelSecondary()
21 {
22 return new I\Component\Panel\Secondary\Factory();
23 }
24 public function dropdown()
25 {
26 return new I\Component\Dropdown\Factory();
27 }
28 public function viewControl()
29 {
30 return new I\Component\ViewControl\Factory(new SignalGenerator());
31 }
32 public function button()
33 {
34 return new I\Component\Button\Factory();
35 }
36 public function symbol() : C\Symbol\Factory
37 {
38 return new I\Component\Symbol\Factory(
39 new I\Component\Symbol\Icon\Factory(),
40 new I\Component\Symbol\Glyph\Factory(),
41 new I\Component\Symbol\Avatar\Factory()
42 );
43 }
44 };
45 return $factory;
46 }
$factory
Definition: metadata.php:58

References $factory.

Referenced by test_get_item_groups(), test_get_title(), test_implements_factory_interface(), test_render_with_actions(), test_render_with_footer(), test_render_with_no_header_but_content(), test_render_with_no_header_no_content_no_footer(), test_render_with_pagination(), test_render_with_section(), test_render_with_sortation(), and test_with_actions().

+ Here is the caller graph for this function:

◆ test_get_item_groups()

PanelSecondaryListingTest::test_get_item_groups ( )

Definition at line 88 of file PanelSecondaryListingTest.php.

89 {
90 $groups = array(
91 new I\Component\Item\Group("Subtitle 1", array(
92 new I\Component\Item\Standard("title1"),
93 new I\Component\Item\Standard("title2")
94 )),
95 new I\Component\Item\Group("Subtitle 2", array(
96 new I\Component\Item\Standard("title3")
97 ))
98 );
99
100 $c = $this->getUIFactory()->panelSecondary()->listing("title", $groups);
101
102 $this->assertEquals($c->getItemGroups(), $groups);
103 }
$c
Definition: cli.php:37

References $c, and getUIFactory().

+ Here is the call graph for this function:

◆ test_get_title()

PanelSecondaryListingTest::test_get_title ( )

Definition at line 71 of file PanelSecondaryListingTest.php.

72 {
73 $groups = array(
74 new I\Component\Item\Group("Subtitle 1", array(
75 new I\Component\Item\Standard("title1"),
76 new I\Component\Item\Standard("title2")
77 )),
78 new I\Component\Item\Group("Subtitle 2", array(
79 new I\Component\Item\Standard("title3")
80 ))
81 );
82
83 $c = $this->getUIFactory()->panelSecondary()->listing("title", $groups);
84
85 $this->assertEquals($c->getTitle(), "title");
86 }

References $c, and getUIFactory().

+ Here is the call graph for this function:

◆ test_implements_factory_interface()

PanelSecondaryListingTest::test_implements_factory_interface ( )

Definition at line 55 of file PanelSecondaryListingTest.php.

56 {
57 $secondary_panel = $this->getUIFactory()->panelSecondary()->listing("List Title", array(
58
59 new I\Component\Item\Group("Subtitle 1", array(
60 new I\Component\Item\Standard("title1"),
61 new I\Component\Item\Standard("title2")
62 )),
63 new I\Component\Item\Group("Subtitle 2", array(
64 new I\Component\Item\Standard("title3")
65 ))
66 ));
67
68 $this->assertInstanceOf("ILIAS\\UI\\Component\\Panel\\Secondary\\Listing", $secondary_panel);
69 }

References getUIFactory().

+ Here is the call graph for this function:

◆ test_render_with_actions()

PanelSecondaryListingTest::test_render_with_actions ( )

Definition at line 122 of file PanelSecondaryListingTest.php.

123 {
124 $actions = $this->getUIFactory()->dropdown()->standard(array(
125 $this->getUIFactory()->button()->shy("ILIAS", "https://www.ilias.de"),
126 $this->getUIFactory()->button()->shy("Github", "https://www.github.com")
127 ));
128
129 $sec = $this->getUIFactory()->panelSecondary()->listing("Title", array())->withActions($actions);
130
131 $html = $this->getDefaultRenderer()->render($sec);
132
133 $expected_html = <<<EOT
134<div class="panel panel-secondary panel-flex">
135 <div class="panel-heading ilHeader">
136 <h4>Title</h4>
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><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1">ILIAS</button></li>
140 <li><button class="btn btn-link" data-action="https://www.github.com" id="id_2">Github</button></li>
141 </ul>
142 </div>
143 </div>
144 <div class="panel-body">
145 </div>
146</div>
147EOT;
148 $this->assertHTMLEquals(
149 $this->cleanHTML($expected_html),
150 $this->cleanHTML($html)
151 );
152 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
Title class.
Definition: Title.php:37
Class ChatMainBarProvider \MainMenu\Provider.

References ILIAS_UI_TestBase\assertHTMLEquals(), cleanHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and getUIFactory().

+ Here is the call graph for this function:

◆ test_render_with_footer()

PanelSecondaryListingTest::test_render_with_footer ( )

Definition at line 274 of file PanelSecondaryListingTest.php.

275 {
276 $footer_shy_button = $this->getUIFactory()->button()->shy("Action", "");
277 $secondary_panel = $this->getUIFactory()->panelSecondary()->listing("", array())->withFooter($footer_shy_button);
278
279 $html = $this->getDefaultRenderer()->render($secondary_panel);
280
281 $expected_html = <<<EOT
282<div class="panel panel-secondary panel-flex">\n
283<div class="panel-body"></div>\n
284<div class="panel-footer ilBlockInfo"><button class="btn btn-link" data-action="">Action</button></div>\n
285</div>\n
286
287EOT;
288 $this->assertHTMLEquals(
289 $this->cleanHTML($expected_html),
290 $this->cleanHTML($html)
291 );
292 }

References ILIAS_UI_TestBase\assertHTMLEquals(), cleanHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and getUIFactory().

+ Here is the call graph for this function:

◆ test_render_with_no_header_but_content()

PanelSecondaryListingTest::test_render_with_no_header_but_content ( )

Definition at line 294 of file PanelSecondaryListingTest.php.

295 {
296 $group = new I\Component\Item\Group(
297 "Subtitle 1",
298 array(
299 new I\Component\Item\Standard("title1"),
300 new I\Component\Item\Standard("title2"))
301 );
302
303 $secondary_panel = $this->getUIFactory()->panelSecondary()->listing("", array($group));
304
305 $html = $this->getDefaultRenderer()->render($secondary_panel);
306
307 $expected_html = <<<EOT
308<div class="panel panel-secondary panel-flex">
309<div class="panel-body">
310<div class="il-item-group">\n
311 <h3>Subtitle 1</h3>\n
312<div class="il-item-group-items">\n
313<div class="il-std-item-container">
314<div class="il-item il-std-item ">
315<div class="il-item-title">title1</div>
316</div></div>\n
317<div class="il-std-item-container">
318<div class="il-item il-std-item ">
319<div class="il-item-title">title2</div>
320</div>
321</div>\n
322</div>\n
323</div>
324</div>
325</div>\n
326EOT;
327 $this->assertHTMLEquals(
328 $this->cleanHTML($expected_html),
329 $this->cleanHTML($html)
330 );
331 }

References ILIAS_UI_TestBase\assertHTMLEquals(), cleanHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and getUIFactory().

+ Here is the call graph for this function:

◆ test_render_with_no_header_no_content_no_footer()

PanelSecondaryListingTest::test_render_with_no_header_no_content_no_footer ( )

Definition at line 333 of file PanelSecondaryListingTest.php.

334 {
335 $secondary_panel = $this->getUIFactory()->panelSecondary()->listing("", array());
336
337 $html = $this->getDefaultRenderer()->render($secondary_panel);
338
339 $this->assertEquals("", $html);
340 }

References ILIAS_UI_TestBase\getDefaultRenderer(), and getUIFactory().

+ Here is the call graph for this function:

◆ test_render_with_pagination()

PanelSecondaryListingTest::test_render_with_pagination ( )

Definition at line 192 of file PanelSecondaryListingTest.php.

193 {
194 $pagination = $this->getUIFactory()->viewControl()->pagination()
195 ->withTargetURL('http://ilias.de', 'page')
196 ->withTotalEntries(10)
197 ->withPageSize(2)
198 ->withCurrentPage(1);
199
200 $sec = $this->getUIFactory()->panelSecondary()->listing("Title", array())
201 ->withViewControls([$pagination]);
202
203 $html = $this->getDefaultRenderer()->render($sec);
204
205 $expected_html = <<<EOT
206<div class="panel panel-secondary panel-flex">
207 <div class="panel-heading ilHeader">
208 <h4>Title</h4>
209 <div class="il-viewcontrol-pagination">
210 <span class="browse previous">
211 <a class="glyph" href="http://ilias.de?page=0" aria-label="back">
212 <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
213 </a>
214 </span>
215 <button class="btn btn-link" data-action="http://ilias.de?page=0" id="id_1">1</button>
216 <button class="btn btn-link engaged" aria-pressed="true" data-action="http://ilias.de?page=1" id="id_2">2</button>
217 <button class="btn btn-link" data-action="http://ilias.de?page=2" id="id_3">3</button>
218 <button class="btn btn-link" data-action="http://ilias.de?page=3" id="id_4">4</button>
219 <button class="btn btn-link" data-action="http://ilias.de?page=4" id="id_5">5</button>
220 <span class="browse next">
221 <a class="glyph" href="http://ilias.de?page=2" aria-label="next">
222 <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
223 </a>
224 </span>
225 </div>
226 </div>
227 <div class="panel-body">
228 </div>
229</div>
230EOT;
231 $this->assertHTMLEquals(
232 $this->cleanHTML($expected_html),
233 $this->cleanHTML($html)
234 );
235 }

References ILIAS_UI_TestBase\assertHTMLEquals(), cleanHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and getUIFactory().

+ Here is the call graph for this function:

◆ test_render_with_section()

PanelSecondaryListingTest::test_render_with_section ( )

Definition at line 237 of file PanelSecondaryListingTest.php.

238 {
239 $back = $this->getUIFactory()->button()->standard("previous", "http://www.ilias.de");
240 $next = $this->getUIFactory()->button()->standard("next", "http://www.github.com");
241 $current = $this->getUIFactory()->button()->standard("current", "");
242 $section = $this->getUIFactory()->viewControl()->section($back, $current, $next);
243
244 $secondary_panel = $this->getUIFactory()->panelSecondary()->listing("Title", array())
245 ->withViewControls([$section]);
246
247 $html = $this->getDefaultRenderer()->render($secondary_panel);
248
249 $expected_html = <<<EOT
250<div class="panel panel-secondary panel-flex">
251 <div class="panel-heading ilHeader">
252 <h4>Title</h4>
253 <div class="il-viewcontrol-section">
254 <a class="btn btn-default " href="http://www.ilias.de" aria-label="previous" data-action="http://www.ilias.de" id="id_1">
255 <span class="glyphicon glyphicon-chevron-left"></span>
256 </a>
257 <button class="btn btn-default" data-action="">
258 current
259 </button>
260 <a class="btn btn-default " href="http://www.github.com" aria-label="next" data-action="http://www.github.com" id="id_2">
261 <span class="glyphicon glyphicon-chevron-right"></span>
262 </a>
263 </div>
264 </div>
265 <div class="panel-body">
266 </div>
267</div>
268EOT;
269 $this->assertHTMLEquals(
270 $this->cleanHTML($expected_html),
271 $this->cleanHTML($html)
272 );
273 }
$section
Definition: Utf8Test.php:83

References $section, ILIAS_UI_TestBase\assertHTMLEquals(), cleanHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and getUIFactory().

+ Here is the call graph for this function:

◆ test_render_with_sortation()

PanelSecondaryListingTest::test_render_with_sortation ( )

Definition at line 154 of file PanelSecondaryListingTest.php.

155 {
156 $sort_options = array(
157 'a' => 'A',
158 'b' => 'B'
159 );
160 $sortation = $this->getUIFactory()->viewControl()->sortation($sort_options);
161 $sec = $this->getUIFactory()->panelSecondary()->listing("Title", array())
162 ->withViewControls([$sortation]);
163
164 $html = $this->getDefaultRenderer()->render($sec);
165
166 $expected_html = <<<EOT
167<div class="panel panel-secondary panel-flex">
168 <div class="panel-heading ilHeader">
169 <h4>Title</h4>
170 <div class="il-viewcontrol-sortation" id="id_1">
171 <div class="dropdown">
172 <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-label="actions" aria-haspopup="true" aria-expanded="false">
173 <span class="caret"></span>
174 </button>
175 <ul class="dropdown-menu">
176 <li><button class="btn btn-link" data-action="?sortation=a" id="id_2">A</button></li>
177 <li><button class="btn btn-link" data-action="?sortation=b" id="id_3">B</button></li>
178 </ul>
179 </div>
180 </div>
181 </div>
182 <div class="panel-body">
183 </div>
184</div>
185EOT;
186 $this->assertHTMLEquals(
187 $this->cleanHTML($expected_html),
188 $this->cleanHTML($html)
189 );
190 }

References ILIAS_UI_TestBase\assertHTMLEquals(), cleanHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and getUIFactory().

+ Here is the call graph for this function:

◆ test_with_actions()

PanelSecondaryListingTest::test_with_actions ( )

Definition at line 105 of file PanelSecondaryListingTest.php.

106 {
107 $actions = new I\Component\Dropdown\Standard(array(
108 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
109 new I\Component\Button\Shy("GitHub", "https://www.github.com")
110 ));
111
112 $groups = array();
113
114 $c = $this->getUIFactory()->panelSecondary()->listing("title", $groups)
115 ->withActions($actions);
116
117 $this->assertEquals($c->getActions(), $actions);
118 }

References $c, and getUIFactory().

+ Here is the call graph for this function:

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