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

Test on button implementation. More...

+ Inheritance diagram for PanelTest:
+ Collaboration diagram for PanelTest:

Public Member Functions

 getUIFactory ()
 
 getPanelFactory ()
 
 test_implements_factory_interface ()
 
 test_standard_get_title ()
 
 test_standard_get_content ()
 
 test_standard_with_actions ()
 
 test_sub_with_actions ()
 
 test_sub_with_card ()
 
 test_report_get_title ()
 
 test_report_get_content ()
 
 test_render_standard ()
 
 test_render_sub ()
 
 test_render_report ()
 
 test_with_view_controls ()
 
 test_render_with_sortation ()
 
 test_render_with_pagination ()
 
- 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)
 

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 27 of file PanelTest.php.

Member Function Documentation

◆ getPanelFactory()

PanelTest::getPanelFactory ( )
Returns
\ILIAS\UI\Implementation\Component\Panel\Factory

Definition at line 63 of file PanelTest.php.

64 {
65 return new I\Component\Panel\Factory(
66 $this->createMock(C\Panel\Listing\Factory::class)
67 );
68 }

Referenced by test_implements_factory_interface(), test_render_report(), test_render_standard(), test_render_sub(), test_render_with_pagination(), test_render_with_sortation(), test_report_get_content(), test_report_get_title(), test_standard_get_content(), test_standard_get_title(), test_standard_with_actions(), test_sub_with_actions(), test_sub_with_card(), and test_with_view_controls().

+ Here is the caller graph for this function:

◆ getUIFactory()

PanelTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 29 of file PanelTest.php.

30 {
31 $factory = new class extends NoUIFactory {
32 public function panelSecondary()
33 {
34 return new I\Component\Panel\Secondary\Factory();
35 }
36 public function dropdown()
37 {
38 return new I\Component\Dropdown\Factory();
39 }
40 public function viewControl()
41 {
42 return new I\Component\ViewControl\Factory(new SignalGenerator());
43 }
44 public function button()
45 {
46 return new I\Component\Button\Factory();
47 }
48 public function symbol() : C\Symbol\Factory
49 {
50 return new I\Component\Symbol\Factory(
51 new I\Component\Symbol\Icon\Factory(),
52 new I\Component\Symbol\Glyph\Factory(),
53 new I\Component\Symbol\Avatar\Factory()
54 );
55 }
56 };
57 return $factory;
58 }
$factory
Definition: metadata.php:58

References $factory.

Referenced by test_render_with_pagination(), test_render_with_sortation(), and test_with_view_controls().

+ Here is the caller graph for this function:

◆ test_implements_factory_interface()

PanelTest::test_implements_factory_interface ( )

Definition at line 70 of file PanelTest.php.

71 {
72 $f = $this->getPanelFactory();
73
74 $this->assertInstanceOf("ILIAS\\UI\\Component\\Panel\\Factory", $f);
75 $this->assertInstanceOf(
76 "ILIAS\\UI\\Component\\Panel\\Standard",
77 $f->standard("Title", array(new ComponentDummy()))
78 );
79 $this->assertInstanceOf(
80 "ILIAS\\UI\\Component\\Panel\\Sub",
81 $f->sub("Title", array(new ComponentDummy()))
82 );
83 $this->assertInstanceOf(
84 "ILIAS\\UI\\Component\\Panel\\Report",
85 $f->report("Title", $f->sub("Title", array(new ComponentDummy())))
86 );
87 }
getPanelFactory()
Definition: PanelTest.php:63

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

+ Here is the call graph for this function:

◆ test_render_report()

PanelTest::test_render_report ( )

Definition at line 242 of file PanelTest.php.

243 {
244 $fp = $this->getPanelFactory();
245 $r = $this->getDefaultRenderer();
246 $sub = $fp->sub("Title", array());
247 $card = new I\Component\Card\Card("Card Title");
248 $sub = $sub->withCard($card);
249 $report = $fp->report("Title", $sub);
250
251 $html = $this->brutallyTrimHTML($r->render($report));
252
253 $expected_html = <<<EOT
254<div class="panel panel-primary il-panel-report panel-flex">
255 <div class="panel-heading ilHeader">
256 <h3>Title</h3>
257 </div>
258 <div class="panel-body">
259 <div class="panel panel-sub panel-flex">
260 <div class="panel-heading ilBlockHeader">
261 <h4>Title</h4>
262 </div>
263 <div class="panel-body"><div class="row">
264 <div class="col-sm-8"></div>
265 <div class="col-sm-4">
266 <div class="il-card thumbnail">
267 <div class="card-no-highlight"></div>
268 <div class="caption card-title">Card Title</div>
269 </div>
270 </div>
271 </div>
272 </div>
273 </div>
274 </div>
275</div>
276EOT;
277
278 $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
279 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
Title class.
Definition: Title.php:37

References ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and getPanelFactory().

+ Here is the call graph for this function:

◆ test_render_standard()

PanelTest::test_render_standard ( )

Definition at line 168 of file PanelTest.php.

169 {
170 $f = $this->getPanelFactory();
171 $r = $this->getDefaultRenderer();
172
173 $actions = new I\Component\Dropdown\Standard(array(
174 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
175 new I\Component\Button\Shy("GitHub", "https://www.github.com")
176 ));
177
178 $p = $f->standard("Title", array())->withActions($actions);
179
180 $html = $r->render($p);
181
182 $expected_html = <<<EOT
183<div class="panel panel-primary panel-flex">
184 <div class="panel-heading ilHeader">
185 <h2>Title</h2>
186 <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>
187 <ul class="dropdown-menu">
188 <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1">ILIAS</button></li>
189 <li><button class="btn btn-link" data-action="https://www.github.com" id="id_2">GitHub</button></li>
190 </ul>
191 </div>
192 </div>
193 <div class="panel-body"></div>
194</div>
195EOT;
196 $this->assertHTMLEquals($expected_html, $html);
197 }
Class ChatMainBarProvider \MainMenu\Provider.

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

+ Here is the call graph for this function:

◆ test_render_sub()

PanelTest::test_render_sub ( )

Definition at line 199 of file PanelTest.php.

200 {
201 $fp = $this->getPanelFactory();
202 $r = $this->getDefaultRenderer();
203
204 $actions = new I\Component\Dropdown\Standard(array(
205 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
206 new I\Component\Button\Shy("GitHub", "https://www.github.com")
207 ));
208
209 $p = $fp->sub("Title", array())->withActions($actions);
210 $card = new I\Component\Card\Card("Card Title");
211 $p = $p->withCard($card);
212 $html = $this->brutallyTrimHTML($r->render($p));
213
214 $expected_html = <<<EOT
215<div class="panel panel-sub panel-flex">
216 <div class="panel-heading ilBlockHeader">
217 <h4>Title</h4>
218 <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>
219 <ul class="dropdown-menu">
220 <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1">ILIAS</button></li>
221 <li><button class="btn btn-link" data-action="https://www.github.com" id="id_2">GitHub</button></li>
222 </ul>
223 </div>
224 </div>
225 <div class="panel-body">
226 <div class="row">
227 <div class="col-sm-8"></div>
228 <div class="col-sm-4">
229 <div class="il-card thumbnail">
230 <div class="card-no-highlight"></div>
231 <div class="caption card-title">Card Title</div>
232 </div>
233 </div>
234 </div>
235 </div>
236</div>
237EOT;
238
239 $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
240 }

References ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and getPanelFactory().

+ Here is the call graph for this function:

◆ test_render_with_pagination()

PanelTest::test_render_with_pagination ( )

Definition at line 335 of file PanelTest.php.

336 {
337 $pagination = $this->getUIFactory()->viewControl()->pagination()
338 ->withTargetURL('http://ilias.de', 'page')
339 ->withTotalEntries(10)
340 ->withPageSize(2)
341 ->withCurrentPage(1);
342
343 $f = $this->getPanelFactory();
344 $r = $this->getDefaultRenderer();
345
346
347 $p = $f->standard("Title", [])
348 ->withViewControls([$pagination]);
349
350 $html = $r->render($p);
351
352 $expected_html = <<<EOT
353<div class="panel panel-primary panel-flex">
354 <div class="panel-heading ilHeader">
355 <h2>Title</h2>
356 <div class="il-viewcontrol-pagination">
357<span class="browse previous"><a class="glyph" href="http://ilias.de?page=0" aria-label="back">
358<span class="glyphicon
359 glyphicon-chevron-left
360" aria-hidden="true"></span>
361</a>
362</span>
363 <button class="btn btn-link" data-action="http://ilias.de?page=0" id="id_1">1</button>
364 <button class="btn btn-link engaged" aria-pressed="true" data-action="http://ilias.de?page=1" id="id_2">2</button>
365 <button class="btn btn-link" data-action="http://ilias.de?page=2" id="id_3">3</button>
366 <button class="btn btn-link" data-action="http://ilias.de?page=3" id="id_4">4</button>
367 <button class="btn btn-link" data-action="http://ilias.de?page=4" id="id_5">5</button>
368<span class="browse next"><a class="glyph" href="http://ilias.de?page=2" aria-label="next">
369<span class="glyphicon
370 glyphicon-chevron-right
371" aria-hidden="true"></span>
372</a>
373</span>
374</div>
375
376 </div>
377 <div class="panel-body"></div>
378</div>
379EOT;
380 $this->assertHTMLEquals($expected_html, $html);
381 }
getUIFactory()
Definition: PanelTest.php:29

References Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), getPanelFactory(), and getUIFactory().

+ Here is the call graph for this function:

◆ test_render_with_sortation()

PanelTest::test_render_with_sortation ( )

Definition at line 296 of file PanelTest.php.

297 {
298 $sort_options = [
299 'a' => 'A',
300 'b' => 'B'
301 ];
302 $sortation = $this->getUIFactory()->viewControl()->sortation($sort_options);
303
304 $f = $this->getPanelFactory();
305 $r = $this->getDefaultRenderer();
306
307
308 $p = $f->standard("Title", [])
309 ->withViewControls([$sortation]);
310 ;
311
312 $html = $r->render($p);
313
314 $expected_html = <<<EOT
315<div class="panel panel-primary panel-flex">
316 <div class="panel-heading ilHeader">
317 <h2>Title</h2>
318 <div class="il-viewcontrol-sortation" id="id_1">
319<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>
320<ul class="dropdown-menu">
321 <li><button class="btn btn-link" data-action="?sortation=a" id="id_2">A</button>
322</li>
323 <li><button class="btn btn-link" data-action="?sortation=b" id="id_3">B</button>
324</li>
325</ul>
326</div>
327</div>
328 </div>
329 <div class="panel-body"></div>
330</div>
331EOT;
332 $this->assertHTMLEquals($expected_html, $html);
333 }

References Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), getPanelFactory(), and getUIFactory().

+ Here is the call graph for this function:

◆ test_report_get_content()

PanelTest::test_report_get_content ( )

Definition at line 160 of file PanelTest.php.

161 {
162 $f = $this->getPanelFactory();
163 $sub = $f->sub("Title", array(new ComponentDummy()));
164 $p = $f->report("Title", $sub);
165
166 $this->assertEquals($p->getContent(), array($sub));
167 }

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

+ Here is the call graph for this function:

◆ test_report_get_title()

PanelTest::test_report_get_title ( )

Definition at line 151 of file PanelTest.php.

152 {
153 $f = $this->getPanelFactory();
154 $sub = $f->sub("Title", array(new ComponentDummy()));
155 $p = $f->report("Title", array($sub));
156
157 $this->assertEquals($p->getTitle(), "Title");
158 }

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

+ Here is the call graph for this function:

◆ test_standard_get_content()

PanelTest::test_standard_get_content ( )

Definition at line 97 of file PanelTest.php.

98 {
99 $f = $this->getPanelFactory();
100 $c = new ComponentDummy();
101 $p = $f->standard("Title", array($c));
102
103 $this->assertEquals($p->getContent(), array($c));
104 }
$c
Definition: cli.php:37

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

+ Here is the call graph for this function:

◆ test_standard_get_title()

PanelTest::test_standard_get_title ( )

Definition at line 89 of file PanelTest.php.

90 {
91 $f = $this->getPanelFactory();
92 $p = $f->standard("Title", array(new ComponentDummy()));
93
94 $this->assertEquals($p->getTitle(), "Title");
95 }

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

+ Here is the call graph for this function:

◆ test_standard_with_actions()

PanelTest::test_standard_with_actions ( )

Definition at line 106 of file PanelTest.php.

107 {
108 $fp = $this->getPanelFactory();
109
110 $p = $fp->standard("Title", array(new ComponentDummy()));
111
112 $actions = new I\Component\Dropdown\Standard(array(
113 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
114 new I\Component\Button\Shy("GitHub", "https://www.github.com")
115 ));
116
117 $p = $p->withActions($actions);
118
119 $this->assertEquals($p->getActions(), $actions);
120 }

References getPanelFactory().

+ Here is the call graph for this function:

◆ test_sub_with_actions()

PanelTest::test_sub_with_actions ( )

Definition at line 122 of file PanelTest.php.

123 {
124 $fp = $this->getPanelFactory();
125
126 $p = $fp->sub("Title", array(new ComponentDummy()));
127
128 $actions = new I\Component\Dropdown\Standard(array(
129 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
130 new I\Component\Button\Shy("GitHub", "https://www.github.com")
131 ));
132
133 $p = $p->withActions($actions);
134
135 $this->assertEquals($p->getActions(), $actions);
136 }

References getPanelFactory().

+ Here is the call graph for this function:

◆ test_sub_with_card()

PanelTest::test_sub_with_card ( )

Definition at line 138 of file PanelTest.php.

139 {
140 $fp = $this->getPanelFactory();
141
142 $p = $fp->sub("Title", array(new ComponentDummy()));
143
144 $card = new I\Component\Card\Card("Card Title");
145
146 $p = $p->withCard($card);
147
148 $this->assertEquals($p->getCard(), $card);
149 }

References getPanelFactory().

+ Here is the call graph for this function:

◆ test_with_view_controls()

PanelTest::test_with_view_controls ( )

Definition at line 281 of file PanelTest.php.

282 {
283 $sort_options = [
284 'a' => 'A',
285 'b' => 'B'
286 ];
287 $sortation = $this->getUIFactory()->viewControl()->sortation($sort_options);
288 $f = $this->getPanelFactory();
289 $p = $f->standard("Title", [])
290 ->withViewControls([$sortation]);
291 ;
292
293 $this->assertEquals($p->getViewControls(), [$sortation]);
294 }

References Vendor\Package\$f, getPanelFactory(), and getUIFactory().

+ Here is the call graph for this function:

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