ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 cleanHTML (string $html)
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Detailed Description

Test secondary listing panels.

Definition at line 31 of file PanelSecondaryListingTest.php.

Member Function Documentation

◆ cleanHTML()

PanelSecondaryListingTest::cleanHTML ( string  $html)
protected

Definition at line 67 of file PanelSecondaryListingTest.php.

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

67  : string
68  {
69  $html = str_replace(["\n", "\t"], "", $html);
70 
71  return trim($html);
72  }
+ Here is the caller graph for this function:

◆ getUIFactory()

PanelSecondaryListingTest::getUIFactory ( )

Definition at line 33 of file PanelSecondaryListingTest.php.

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

33  : NoUIFactory
34  {
35  return new class () extends NoUIFactory {
36  public function panelSecondary(): I\Component\Panel\Secondary\Factory
37  {
38  return new I\Component\Panel\Secondary\Factory();
39  }
40 
41  public function dropdown(): C\Dropdown\Factory
42  {
43  return new I\Component\Dropdown\Factory();
44  }
45 
46  public function viewControl(): C\ViewControl\Factory
47  {
48  return new I\Component\ViewControl\Factory(new SignalGenerator());
49  }
50 
51  public function button(): C\Button\Factory
52  {
53  return new I\Component\Button\Factory();
54  }
55 
56  public function symbol(): C\Symbol\Factory
57  {
58  return new I\Component\Symbol\Factory(
59  new I\Component\Symbol\Icon\Factory(),
60  new I\Component\Symbol\Glyph\Factory(),
61  new I\Component\Symbol\Avatar\Factory()
62  );
63  }
64  };
65  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
+ Here is the caller graph for this function:

◆ test_get_item_groups()

PanelSecondaryListingTest::test_get_item_groups ( )

Definition at line 107 of file PanelSecondaryListingTest.php.

References $c, getUIFactory(), and ILIAS\UI\Implementation\Component\Input\Group.

107  : void
108  {
109  $groups = array(
110  new I\Component\Item\Group("Subtitle 1", array(
111  new I\Component\Item\Standard("title1"),
112  new I\Component\Item\Standard("title2")
113  )),
114  new I\Component\Item\Group("Subtitle 2", array(
115  new I\Component\Item\Standard("title3")
116  ))
117  );
118 
119  $c = $this->getUIFactory()->panelSecondary()->listing("title", $groups);
120 
121  $this->assertEquals($c->getItemGroups(), $groups);
122  }
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ test_get_title()

PanelSecondaryListingTest::test_get_title ( )

Definition at line 90 of file PanelSecondaryListingTest.php.

References $c, getUIFactory(), and ILIAS\UI\Implementation\Component\Input\Group.

90  : void
91  {
92  $groups = array(
93  new I\Component\Item\Group("Subtitle 1", array(
94  new I\Component\Item\Standard("title1"),
95  new I\Component\Item\Standard("title2")
96  )),
97  new I\Component\Item\Group("Subtitle 2", array(
98  new I\Component\Item\Standard("title3")
99  ))
100  );
101 
102  $c = $this->getUIFactory()->panelSecondary()->listing("title", $groups);
103 
104  $this->assertEquals("title", $c->getTitle());
105  }
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ test_implements_factory_interface()

PanelSecondaryListingTest::test_implements_factory_interface ( )

Definition at line 74 of file PanelSecondaryListingTest.php.

References getUIFactory(), and ILIAS\UI\Implementation\Component\Input\Group.

74  : void
75  {
76  $secondary_panel = $this->getUIFactory()->panelSecondary()->listing("List Title", array(
77 
78  new I\Component\Item\Group("Subtitle 1", array(
79  new I\Component\Item\Standard("title1"),
80  new I\Component\Item\Standard("title2")
81  )),
82  new I\Component\Item\Group("Subtitle 2", array(
83  new I\Component\Item\Standard("title3")
84  ))
85  ));
86 
87  $this->assertInstanceOf("ILIAS\\UI\\Component\\Panel\\Secondary\\Listing", $secondary_panel);
88  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ test_render_with_actions()

PanelSecondaryListingTest::test_render_with_actions ( )

Definition at line 141 of file PanelSecondaryListingTest.php.

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

141  : void
142  {
143  $actions = $this->getUIFactory()->dropdown()->standard(array(
144  $this->getUIFactory()->button()->shy("ILIAS", "https://www.ilias.de"),
145  $this->getUIFactory()->button()->shy("Github", "https://www.github.com")
146  ));
147 
148  $sec = $this->getUIFactory()->panelSecondary()->listing("Title", array())->withActions($actions);
149 
150  $html = $this->getDefaultRenderer()->render($sec);
151 
152  $expected_html = <<<EOT
153 <div class="panel panel-secondary panel-flex">
154  <div class="panel-heading ilHeader">
155  <h2>Title</h2>
156  <div class="dropdown"><button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" id="id_3" aria-label="actions" aria-haspopup="true" aria-expanded="false" aria-controls="id_3_menu"> <span class="caret"></span></button>
157  <ul id="id_3_menu" class="dropdown-menu">
158  <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1">ILIAS</button></li>
159  <li><button class="btn btn-link" data-action="https://www.github.com" id="id_2">Github</button></li>
160  </ul>
161  </div>
162  </div>
163  <div class="panel-body">
164  </div>
165 </div>
166 EOT;
167  $this->assertHTMLEquals(
168  $this->cleanHTML($expected_html),
169  $this->cleanHTML($html)
170  );
171  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
Class ChatMainBarProvider .
Title class.
Definition: Title.php:26
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
+ Here is the call graph for this function:

◆ test_render_with_footer()

PanelSecondaryListingTest::test_render_with_footer ( )

Definition at line 293 of file PanelSecondaryListingTest.php.

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

293  : void
294  {
295  $footer_shy_button = $this->getUIFactory()->button()->shy("Action", "");
296  $secondary_panel = $this->getUIFactory()->panelSecondary()->listing("", array())->withFooter($footer_shy_button);
297 
298  $html = $this->getDefaultRenderer()->render($secondary_panel);
299 
300  $expected_html = <<<EOT
301 <div class="panel panel-secondary panel-flex">\n
302 <div class="panel-body"></div>\n
303 <div class="panel-footer ilBlockInfo"><button class="btn btn-link" data-action="">Action</button></div>\n
304 </div>\n
305 
306 EOT;
307  $this->assertHTMLEquals(
308  $this->cleanHTML($expected_html),
309  $this->cleanHTML($html)
310  );
311  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
+ 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 313 of file PanelSecondaryListingTest.php.

References ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), getUIFactory(), and ILIAS\UI\Implementation\Component\Input\Group.

313  : void
314  {
315  $group = new I\Component\Item\Group(
316  "Subtitle 1",
317  array(
318  new I\Component\Item\Standard("title1"),
319  new I\Component\Item\Standard("title2"))
320  );
321 
322  $secondary_panel = $this->getUIFactory()->panelSecondary()->listing("", array($group));
323 
324  $html = $this->getDefaultRenderer()->render($secondary_panel);
325 
326  $expected_html = <<<EOT
327 <div class="panel panel-secondary panel-flex">
328  <div class="panel-body">
329  <div class="il-item-group">
330  <h3>Subtitle 1</h3>
331  <div class="il-item-group-items">
332  <ul>
333  <li class="il-std-item-container">
334  <div class="il-item il-std-item ">
335  <div class="il-item-title">title1</div>
336  </div>
337  </li>
338  <li class="il-std-item-container">
339  <div class="il-item il-std-item ">
340  <div class="il-item-title">title2</div>
341  </div>
342  </li>
343  </ul>
344  </div>
345  </div>
346  </div>
347 </div>
348 EOT;
349  $this->assertHTMLEquals(
350  $this->brutallyTrimHTML($expected_html),
351  $this->brutallyTrimHTML($html)
352  );
353  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
+ 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 355 of file PanelSecondaryListingTest.php.

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

355  : void
356  {
357  $secondary_panel = $this->getUIFactory()->panelSecondary()->listing("", array());
358 
359  $html = $this->getDefaultRenderer()->render($secondary_panel);
360 
361  $this->assertEquals("", $html);
362  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
+ Here is the call graph for this function:

◆ test_render_with_pagination()

PanelSecondaryListingTest::test_render_with_pagination ( )

Definition at line 211 of file PanelSecondaryListingTest.php.

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

211  : void
212  {
213  $pagination = $this->getUIFactory()->viewControl()->pagination()
214  ->withTargetURL('http://ilias.de', 'page')
215  ->withTotalEntries(10)
216  ->withPageSize(2)
217  ->withCurrentPage(1);
218 
219  $sec = $this->getUIFactory()->panelSecondary()->listing("Title", array())
220  ->withViewControls([$pagination]);
221 
222  $html = $this->getDefaultRenderer()->render($sec);
223 
224  $expected_html = <<<EOT
225 <div class="panel panel-secondary panel-flex">
226  <div class="panel-heading ilHeader">
227  <h2>Title</h2>
228  <div class="il-viewcontrol-pagination">
229  <span class="browse previous">
230  <a tabindex="0" class="glyph" href="http://ilias.de?page=0" aria-label="back">
231  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
232  </a>
233  </span>
234  <button class="btn btn-link" data-action="http://ilias.de?page=0" id="id_1">1</button>
235  <button class="btn btn-link engaged" aria-pressed="true" data-action="http://ilias.de?page=1" id="id_2">2</button>
236  <button class="btn btn-link" data-action="http://ilias.de?page=2" id="id_3">3</button>
237  <button class="btn btn-link" data-action="http://ilias.de?page=3" id="id_4">4</button>
238  <button class="btn btn-link" data-action="http://ilias.de?page=4" id="id_5">5</button>
239  <span class="browse next">
240  <a tabindex="0" class="glyph" href="http://ilias.de?page=2" aria-label="next">
241  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
242  </a>
243  </span>
244  </div>
245  </div>
246  <div class="panel-body">
247  </div>
248 </div>
249 EOT;
250  $this->assertHTMLEquals(
251  $this->cleanHTML($expected_html),
252  $this->cleanHTML($html)
253  );
254  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
Title class.
Definition: Title.php:26
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
+ Here is the call graph for this function:

◆ test_render_with_section()

PanelSecondaryListingTest::test_render_with_section ( )

Definition at line 256 of file PanelSecondaryListingTest.php.

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

256  : void
257  {
258  $back = $this->getUIFactory()->button()->standard("previous", "http://www.ilias.de");
259  $next = $this->getUIFactory()->button()->standard("next", "http://www.github.com");
260  $current = $this->getUIFactory()->button()->standard("current", "");
261  $section = $this->getUIFactory()->viewControl()->section($back, $current, $next);
262 
263  $secondary_panel = $this->getUIFactory()->panelSecondary()->listing("Title", array())
264  ->withViewControls([$section]);
265 
266  $html = $this->getDefaultRenderer()->render($secondary_panel);
267 
268  $expected_html = <<<EOT
269 <div class="panel panel-secondary panel-flex">
270  <div class="panel-heading ilHeader">
271  <h2>Title</h2>
272  <div class="il-viewcontrol-section">
273  <a class="btn btn-default " href="http://www.ilias.de" aria-label="previous" data-action="http://www.ilias.de" id="id_1">
274  <span class="glyphicon glyphicon-chevron-left"></span>
275  </a>
276  <button class="btn btn-default" data-action="">
277  current
278  </button>
279  <a class="btn btn-default " href="http://www.github.com" aria-label="next" data-action="http://www.github.com" id="id_2">
280  <span class="glyphicon glyphicon-chevron-right"></span>
281  </a>
282  </div>
283  </div>
284  <div class="panel-body">
285  </div>
286 </div>
287 EOT;
288  $this->assertHTMLEquals(
289  $this->cleanHTML($expected_html),
290  $this->cleanHTML($html)
291  );
292  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
Title class.
Definition: Title.php:26
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
+ Here is the call graph for this function:

◆ test_render_with_sortation()

PanelSecondaryListingTest::test_render_with_sortation ( )

Definition at line 173 of file PanelSecondaryListingTest.php.

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

173  : void
174  {
175  $sort_options = array(
176  'a' => 'A',
177  'b' => 'B'
178  );
179  $sortation = $this->getUIFactory()->viewControl()->sortation($sort_options);
180  $sec = $this->getUIFactory()->panelSecondary()->listing("Title", array())
181  ->withViewControls([$sortation]);
182 
183  $html = $this->getDefaultRenderer()->render($sec);
184 
185  $expected_html = <<<EOT
186 <div class="panel panel-secondary panel-flex">
187  <div class="panel-heading ilHeader">
188  <h2>Title</h2>
189  <div class="il-viewcontrol-sortation" id="id_1">
190  <div class="dropdown">
191  <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" id="id_4" aria-label="actions" aria-haspopup="true" aria-expanded="false" aria-controls="id_4_menu">
192  <span class="caret"></span>
193  </button>
194  <ul id="id_4_menu" class="dropdown-menu">
195  <li><button class="btn btn-link" data-action="?sortation=a" id="id_2">A</button></li>
196  <li><button class="btn btn-link" data-action="?sortation=b" id="id_3">B</button></li>
197  </ul>
198  </div>
199  </div>
200  </div>
201  <div class="panel-body">
202  </div>
203 </div>
204 EOT;
205  $this->assertHTMLEquals(
206  $this->cleanHTML($expected_html),
207  $this->cleanHTML($html)
208  );
209  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Avatar.php:21
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
Title class.
Definition: Title.php:26
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
+ Here is the call graph for this function:

◆ test_with_actions()

PanelSecondaryListingTest::test_with_actions ( )

Definition at line 124 of file PanelSecondaryListingTest.php.

References $c, and getUIFactory().

124  : void
125  {
126  $actions = new I\Component\Dropdown\Standard(array(
127  new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
128  new I\Component\Button\Shy("GitHub", "https://www.github.com")
129  ));
130 
131  $groups = array();
132 
133  $c = $this->getUIFactory()->panelSecondary()->listing("title", $groups)
134  ->withActions($actions);
135 
136  $this->assertEquals($c->getActions(), $actions);
137  }
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
+ Here is the call graph for this function:

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