ILIAS  release_8 Revision v8.24
PanelListingTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../Base.php");
23
26
31{
32 public function getFactory(): C\Panel\Listing\Factory
33 {
34 return new I\Component\Panel\Listing\Factory();
35 }
36
37 public function test_implements_factory_interface(): void
38 {
39 $f = $this->getFactory();
40
41 $std_list = $f->standard("List Title", array(
42 new I\Component\Item\Group("Subtitle 1", array(
43 new I\Component\Item\Standard("title1"),
44 new I\Component\Item\Standard("title2")
45 )),
46 new I\Component\Item\Group("Subtitle 2", array(
47 new I\Component\Item\Standard("title3")
48 ))
49 ));
50
51 $this->assertInstanceOf("ILIAS\\UI\\Component\\Panel\\Listing\\Standard", $std_list);
52 }
53
54 public function test_get_title_get_groups(): void
55 {
56 $f = $this->getFactory();
57
58 $groups = array(
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 $c = $f->standard("title", $groups);
69
70 $this->assertEquals("title", $c->getTitle());
71 $this->assertEquals($groups, $c->getItemGroups());
72 }
73
74 public function test_with_actions(): void
75 {
76 $f = $this->getFactory();
77
78 $actions = new I\Component\Dropdown\Standard(array(
79 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
80 new I\Component\Button\Shy("GitHub", "https://www.github.com")
81 ));
82
83 $groups = array();
84
85 $c = $f->standard("title", $groups)
86 ->withActions($actions);
87
88 $this->assertEquals($actions, $c->getActions());
89 }
90
91 public function test_render_base(): void
92 {
93 $f = $this->getFactory();
94 $r = $this->getDefaultRenderer();
95
96 $groups = array(
97 new I\Component\Item\Group("Subtitle 1", array(
98 new I\Component\Item\Standard("title1"),
99 new I\Component\Item\Standard("title2")
100 )),
101 new I\Component\Item\Group("Subtitle 2", array(
102 new I\Component\Item\Standard("title3")
103 ))
104 );
105
106 $c = $f->standard("title", $groups);
107
108 $html = $r->render($c);
109
110 $expected = <<<EOT
111<div class="panel il-panel-listing-std-container clearfix">
112 <h2>title</h2>
113 <div class="il-item-group">
114 <h3>Subtitle 1</h3>
115 <div class="il-item-group-items">
116 <ul>
117 <li class="il-std-item-container">
118 <div class="il-item il-std-item ">
119 <div class="il-item-title">title1</div>
120 </div>
121 </li>
122 <li class="il-std-item-container">
123 <div class="il-item il-std-item ">
124 <div class="il-item-title">title2</div>
125 </div>
126 </li>
127 </ul>
128 </div>
129 </div>
130 <div class="il-item-group">
131 <h3>Subtitle 2</h3>
132 <div class="il-item-group-items">
133 <ul>
134 <li class="il-std-item-container">
135 <div class="il-item il-std-item ">
136 <div class="il-item-title">title3</div>
137 </div>
138 </li>
139 </ul>
140 </div>
141 </div>
142</div>
143EOT;
144 $this->assertHTMLEquals(
145 $this->brutallyTrimHTML($expected),
146 $this->brutallyTrimHTML($html)
147 );
148 }
149
150 public function test_render_with_actions(): void
151 {
152 $f = $this->getFactory();
153 $r = $this->getDefaultRenderer();
154
155 $groups = array();
156
157 $actions = new I\Component\Dropdown\Standard(array(
158 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
159 new I\Component\Button\Shy("GitHub", "https://www.github.com")
160 ));
161
162 $c = $f->standard("title", $groups)
163 ->withActions($actions);
164
165 $html = $r->render($c);
166
167 $expected = <<<EOT
168<div class="panel il-panel-listing-std-container clearfix">
169<h2>title</h2><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>
170<ul id="id_3_menu" class="dropdown-menu">
171 <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1">ILIAS</button></li>
172 <li><button class="btn btn-link" data-action="https://www.github.com" id="id_2">GitHub</button></li>
173</ul>
174</div>
175</div>
176EOT;
177 $this->assertHTMLEquals($expected, $html);
178 }
179}
Provides common functionality for UI tests.
Definition: Base.php:299
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
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...
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
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...
Class ChatMainBarProvider \MainMenu\Provider.