ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
FilterInputTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once(__DIR__ . "/../../../../../../../../vendor/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../../../Base.php");
23require_once(__DIR__ . "/FilterTest.php");
24
25use ILIAS\Data;
27
29{
30 protected I\Symbol\Factory $symbol_factory;
31 protected I\Popover\Factory $popover_factory;
32 protected I\Legacy\Factory $legacy_factory;
33
34 public function __construct(
38 ) {
39 $this->symbol_factory = $symbol_factory;
40 $this->popover_factory = $popover_factory;
41 $this->legacy_factory = $legacy_factory;
42 }
43
44 public function symbol(): I\Symbol\Factory
45 {
47 }
48
49 public function popover(): I\Popover\Factory
50 {
52 }
53
54 public function legacy(): I\Legacy\Factory
55 {
57 }
58}
59
65{
66 protected function buildFactory(): I\Input\Container\Filter\Factory
67 {
68 return new I\Input\Container\Filter\Factory(
69 new I\SignalGenerator(),
70 $this->buildInputFactory()
71 );
72 }
73
74 protected function buildInputFactory(): I\Input\Field\Factory
75 {
76 $df = new Data\Factory();
77 $language = $this->createMock(ILIAS\Language\Language::class);
78 return new I\Input\Field\Factory(
79 $this->createMock(\ILIAS\UI\Implementation\Component\Input\Field\Node\Factory::class),
80 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
81 new I\SignalGenerator(),
82 $df,
83 new ILIAS\Refinery\Factory($df, $language),
84 $language
85 );
86 }
87
88 protected function buildSymbolFactory(): I\Symbol\Factory
89 {
90 return new I\Symbol\Factory(
91 new I\Symbol\Icon\Factory(),
92 new I\Symbol\Glyph\Factory(),
93 new I\Symbol\Avatar\Factory()
94 );
95 }
96
97 protected function buildPopoverFactory(): I\Popover\Factory
98 {
99 return new I\Popover\Factory(new I\SignalGenerator());
100 }
101
102 protected function buildLegacyFactory(): I\Legacy\Factory
103 {
104 $mock = $this->createMock(I\Legacy\Factory::class);
105 $mock->method('content')->willReturn(
106 new I\Legacy\Content('', new I\SignalGenerator())
107 );
108 return $mock;
109 }
110
112 {
114 $this->buildSymbolFactory(),
115 $this->buildPopoverFactory(),
116 $this->buildLegacyFactory(),
117 );
118 }
119
120 public function testRenderTextWithFilterContext(): void
121 {
122 $f = $this->buildFactory();
123 $if = $this->buildInputFactory();
124 $text = $if->text('label', 'byline'); // byline will not be rendered in this context
125 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
126 $fr = $this->getDefaultRenderer(null, [], [$filter]);
127 $html = $this->brutallyTrimHTML($fr->render($text));
128
129 $expected = $this->brutallyTrimHTML('
130 <div class="col-md-6 col-lg-4 il-popover-container">
131 <div class="input-group">
132 <label for="id_1" class="input-group-addon leftaddon">label</label>
133 <input id="id_1" type="text" class="c-field-text" />
134 <span class="input-group-addon rightaddon">
135 <a class="glyph" href="" aria-label="remove" id="id_2">
136 <span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>
137 </a>
138 </span>
139 </div>
140 </div>
141 ');
142 $this->assertHTMLEquals($expected, $html);
143 }
144
146 {
147 $f = $this->buildFactory();
148 $if = $this->buildInputFactory();
149 $numeric = $if->numeric('label', 'byline'); // byline will not be rendered in this context
150 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
151 $fr = $this->getDefaultRenderer(null, [], [$filter]);
152 $html = $this->brutallyTrimHTML($fr->render($numeric));
153
154 $expected = $this->brutallyTrimHTML('
155 <div class="col-md-6 col-lg-4 il-popover-container">
156 <div class="input-group">
157 <label for="id_1" class="input-group-addon leftaddon">label</label>
158 <input id="id_1" type="number" step="1" class="c-field-number" />
159 <span class="input-group-addon rightaddon">
160 <a class="glyph" href="" aria-label="remove" id="id_2">
161 <span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>
162 </a>
163 </span>
164 </div>
165 </div>
166 ');
167 $this->assertHTMLEquals($expected, $html);
168 }
169
170 public function testRenderSelectWithFilterContext(): void
171 {
172 $f = $this->buildFactory();
173 $if = $this->buildInputFactory();
174 $options = ["one" => "One", "two" => "Two", "three" => "Three"];
175 $select = $if->select('label', $options, 'byline'); // byline will not be rendered in this context
176 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
177 $fr = $this->getDefaultRenderer(null, [], [$filter]);
178 $html = $this->brutallyTrimHTML($fr->render($select));
179
180 $expected = $this->brutallyTrimHTML('
181 <div class="col-md-6 col-lg-4 il-popover-container">
182 <div class="input-group">
183 <label for="id_1" class="input-group-addon leftaddon">label</label>
184 <select id="id_1">
185 <option selected="selected" value="">-</option>
186 <option value="one">One</option>
187 <option value="two">Two</option>
188 <option value="three">Three</option>
189 </select>
190 <span class="input-group-addon rightaddon">
191 <a class="glyph" href="" aria-label="remove" id="id_2"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span></a>
192 </span>
193 </div>
194 </div>
195 ');
196 $this->assertHTMLEquals($expected, $html);
197 }
198
200 {
201 $f = $this->buildFactory();
202 $if = $this->buildInputFactory();
203 $options = ["one" => "One", "two" => "Two", "three" => "Three"];
204 $multi = $if->multiSelect('label', $options, 'byline'); // byline will not be rendered in this context
205 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
206 $fr = $this->getDefaultRenderer(null, [], [$filter]);
207 $html = $this->brutallyTrimHTML($fr->render($multi));
208
209 $expected = $this->brutallyTrimHTML('
210 <div class="col-md-6 col-lg-4 il-popover-container">
211 <div class="input-group">
212 <label class="input-group-addon leftaddon">label</label>
213 <span role="button" tabindex="0" class="form-control il-filter-field" id="id_3" data-placement="bottom"></span>
214 <div class="il-standard-popover-content" style="display:none;" id="id_1"></div>
215 <span class="input-group-addon rightaddon">
216 <a class="glyph" href="" aria-label="remove" id="id_4">
217 <span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>
218 </a>
219 </span>
220 </div>
221 {POPOVER}
222 </div>
223 ');
224 $this->assertHTMLEquals($expected, $html);
225 }
226
228 {
229 $f = $this->buildFactory();
230 $if = $this->buildInputFactory();
231 $datetime = $if->dateTime('label', 'byline'); // byline will not be rendered in this context
232 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
233 $fr = $this->getDefaultRenderer(null, [], [$filter]);
234 $html = $this->brutallyTrimHTML($fr->render($datetime));
235
236 $expected = $this->brutallyTrimHTML('
237 <div class="col-md-6 col-lg-4 il-popover-container">
238 <div class="input-group">
239 <label for="id_1" class="input-group-addon leftaddon">label</label>
240 <div class="c-input-group">
241 <input id="id_1" type="date" class="c-field-datetime" />
242 </div>
243 <span class="input-group-addon rightaddon">
244 <a class="glyph" href="" aria-label="remove" id="id_2">
245 <span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>
246 </a>
247 </span>
248 </div>
249 </div>
250 ');
251 $this->assertHTMLEquals($expected, $html);
252 }
253
255 {
256 $f = $this->buildFactory();
257 $if = $this->buildInputFactory();
258 $duration = $if->duration('label', 'byline');
259 $datetime = $if->dateTime('label', 'byline'); // byline will not be rendered in this context
260 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
261 $dr = $this->getDefaultRenderer(null, [], [$filter, $duration, $datetime]);
262 $html = $this->brutallyTrimHTML($dr->render($datetime));
263
264 $expected = $this->brutallyTrimHTML('
265 <fieldset class="c-input" data-il-ui-component="" data-il-ui-input-name="">
266 <label for="id_1">label</label>
267 <div class="c-input__field">
268 <div class="c-input-group">
269 <input id="id_1" type="date" class="c-field-datetime" />
270 </div>
271 </div>
272 </fieldset>
273 ');
274 $this->assertEquals($expected, $html);
275 $this->assertHTMLEquals($expected, $html);
276 }
277
279 {
280 $f = $this->buildFactory();
281 $if = $this->buildInputFactory();
282 $datetime = $if->duration('label', 'byline'); // byline will not be rendered in this context
283 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
284 $fr = $this->getDefaultRenderer(null, [], [$filter]);
285 $html = $this->brutallyTrimHTML($fr->render($datetime));
286 $label_start = 'duration_default_label_start';
287 $label_end = 'duration_default_label_end';
288
289
290 $expected = $this->brutallyTrimHTML('
291 <div class="col-md-6 col-lg-4 il-popover-container">
292 <div class="input-group">
293 <label class="input-group-addon leftaddon">label</label>
294 <span role="button" tabindex="0" class="form-control il-filter-field" id="id_7" data-placement="bottom"></span>
295 <div class="il-standard-popover-content" style="display:none;" id="id_5"></div>
296 <span class="input-group-addon rightaddon">
297 <a class="glyph" href="" aria-label="remove" id="id_8">
298 <span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>
299 </a>
300 </span>
301 </div>
302 {POPOVER}
303 </div>
304 ');
305 $this->assertHTMLEquals($expected, $html);
306 }
307}
$datetime
$duration
Test on rendering filter inputs.
testRenderDateTimeWithDurationAndFilterContext()
testRenderMultiSelectWithFilterContext()
__construct(I\Symbol\Factory $symbol_factory, I\Popover\Factory $popover_factory, I\Legacy\Factory $legacy_factory,)
I Popover Factory $popover_factory
Builds data types.
Definition: Factory.php:36
Definition: UI.php:24
Provides common functionality for UI tests.
Definition: Base.php:337
This describes a symbol.
Definition: Symbol.php:30
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.