ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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\Button\Factory $button_factory;
31 protected I\Symbol\Factory $symbol_factory;
32 protected I\Popover\Factory $popover_factory;
33 protected I\Legacy\Factory $legacy_factory;
34
35 public function __construct(
40 ) {
41 $this->button_factory = $button_factory;
42 $this->symbol_factory = $symbol_factory;
43 $this->popover_factory = $popover_factory;
44 $this->legacy_factory = $legacy_factory;
45 }
46
47 public function button(): I\Button\Factory
48 {
50 }
51
52 public function symbol(): I\Symbol\Factory
53 {
55 }
56
57 public function popover(): I\Popover\Factory
58 {
60 }
61
62 public function legacy(): I\Legacy\Factory
63 {
65 }
66}
67
73{
74 protected function buildFactory(): I\Input\Container\Filter\Factory
75 {
76 return new I\Input\Container\Filter\Factory(
77 new I\SignalGenerator(),
78 $this->buildInputFactory()
79 );
80 }
81
82 protected function buildInputFactory(): I\Input\Field\Factory
83 {
84 $df = new Data\Factory();
85 $language = $this->createMock(ILIAS\Language\Language::class);
86 return new I\Input\Field\Factory(
87 $this->createMock(\ILIAS\UI\Implementation\Component\Input\Field\Node\Factory::class),
88 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
89 new I\SignalGenerator(),
90 $df,
91 new ILIAS\Refinery\Factory($df, $language),
92 $language
93 );
94 }
95
96 protected function buildSymbolFactory(): I\Symbol\Factory
97 {
98 return new I\Symbol\Factory(
99 new I\Symbol\Icon\Factory(),
100 new I\Symbol\Glyph\Factory(),
101 new I\Symbol\Avatar\Factory()
102 );
103 }
104
105 protected function buildButtonFactory(): I\Button\Factory
106 {
107 return new I\Button\Factory();
108 }
109
110 protected function buildPopoverFactory(): I\Popover\Factory
111 {
112 return new I\Popover\Factory(new I\SignalGenerator());
113 }
114
115 protected function buildLegacyFactory(): I\Legacy\Factory
116 {
117 $mock = $this->createMock(I\Legacy\Factory::class);
118 $mock->method('content')->willReturn(
119 new I\Legacy\Content('', new I\SignalGenerator())
120 );
121 return $mock;
122 }
123
125 {
127 $this->buildButtonFactory(),
128 $this->buildSymbolFactory(),
129 $this->buildPopoverFactory(),
130 $this->buildLegacyFactory(),
131 );
132 }
133
134 public function testRenderTextWithFilterContext(): void
135 {
136 $f = $this->buildFactory();
137 $if = $this->buildInputFactory();
138 $text = $if->text('label', 'byline'); // byline will not be rendered in this context
139 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
140 $fr = $this->getDefaultRenderer(null, [], [$filter]);
141 $html = $this->brutallyTrimHTML($fr->render($text));
142
143 $expected = $this->brutallyTrimHTML('
144 <div class="col-md-6 col-lg-4 il-popover-container">
145 <div data-il-ui-component="text-field-input" data-il-ui-input-name="" class="input-group">
146 <label for="id_1" class="input-group-addon leftaddon">label</label>
147 <input id="id_1" type="text" class="c-field-text" />
148 <span class="input-group-addon rightaddon">
149 <button type="button" class="btn btn-link" aria-label="remove" data-action="" id="id_2"><span class="glyph" aria-hidden="true"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span></span></button>
150 </span>
151 </div>
152 </div>
153 ');
154 $this->assertHTMLEquals($expected, $html);
155 }
156
158 {
159 $f = $this->buildFactory();
160 $if = $this->buildInputFactory();
161 $numeric = $if->numeric('label', 'byline'); // byline will not be rendered in this context
162 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
163 $fr = $this->getDefaultRenderer(null, [], [$filter]);
164 $html = $this->brutallyTrimHTML($fr->render($numeric));
165
166 $expected = $this->brutallyTrimHTML('
167 <div class="col-md-6 col-lg-4 il-popover-container"><div data-il-ui-component="numeric-field-input" data-il-ui-input-name="" class="input-group">
168 <label for="id_1" class="input-group-addon leftaddon">label</label>
169 <input id="id_1" type="number" step="1" class="c-field-number" />
170 <span class="input-group-addon rightaddon">
171 <button type="button" class="btn btn-link" aria-label="remove" data-action="" id="id_2"><span class="glyph" aria-hidden="true"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span></span></button>
172 </span>
173 </div>
174 </div>
175 ');
176 $this->assertHTMLEquals($expected, $html);
177 }
178
179 public function testRenderSelectWithFilterContext(): void
180 {
181 $f = $this->buildFactory();
182 $if = $this->buildInputFactory();
183 $options = ["one" => "One", "two" => "Two", "three" => "Three"];
184 $select = $if->select('label', $options, 'byline'); // byline will not be rendered in this context
185 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
186 $fr = $this->getDefaultRenderer(null, [], [$filter]);
187 $html = $this->brutallyTrimHTML($fr->render($select));
188
189 $expected = $this->brutallyTrimHTML('
190 <div class="col-md-6 col-lg-4 il-popover-container"><div data-il-ui-component="select-field-input" data-il-ui-input-name="" class="input-group">
191 <label for="id_1" class="input-group-addon leftaddon">label</label>
192 <select id="id_1">
193 <option selected="selected" value="">-</option>
194 <option value="one">One</option>
195 <option value="two">Two</option>
196 <option value="three">Three</option>
197 </select>
198 <span class="input-group-addon rightaddon">
199 <button type="button" class="btn btn-link" aria-label="remove" data-action="" id="id_2"><span class="glyph" aria-hidden="true"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span></span></button>
200 </span>
201 </div>
202 </div>
203 ');
204 $this->assertHTMLEquals($expected, $html);
205 }
206
208 {
209 $f = $this->buildFactory();
210 $if = $this->buildInputFactory();
211 $options = ["one" => "One", "two" => "Two", "three" => "Three"];
212 $multi = $if->multiSelect('label', $options, 'byline'); // byline will not be rendered in this context
213 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
214 $fr = $this->getDefaultRenderer(null, [], [$filter]);
215 $html = $this->brutallyTrimHTML($fr->render($multi));
216
217 $expected = $this->brutallyTrimHTML('
218 <div class="col-md-6 col-lg-4 il-popover-container"><div data-il-ui-component="multi-select-field-input" data-il-ui-input-name="" class="input-group">
219 <label class="input-group-addon leftaddon">label</label>
220 <span role="button" tabindex="0" class="form-control il-filter-field" id="id_3" data-placement="bottom"></span>
221 <div class="il-standard-popover-content" style="display:none;" id="id_1"></div>
222 <span class="input-group-addon rightaddon">
223 <button type="button" class="btn btn-link" aria-label="remove" data-action="" id="id_4"><span class="glyph" aria-hidden="true"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span></span></button>
224 </span>
225 </div>
226 </div>
227 ');
228 $this->assertHTMLEquals($expected, $html);
229 }
230
232 {
233 $f = $this->buildFactory();
234 $if = $this->buildInputFactory();
235 $datetime = $if->dateTime('label', 'byline'); // byline will not be rendered in this context
236 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
237 $fr = $this->getDefaultRenderer(null, [], [$filter]);
238 $html = $this->brutallyTrimHTML($fr->render($datetime));
239
240 $expected = $this->brutallyTrimHTML('
241 <div class="col-md-6 col-lg-4 il-popover-container"><div data-il-ui-component="date-time-field-input" data-il-ui-input-name="" class="input-group">
242 <label for="id_1" class="input-group-addon leftaddon">label</label>
243 <div class="c-input-group">
244 <input id="id_1" type="date" class="c-field-datetime" />
245 </div>
246 <span class="input-group-addon rightaddon">
247 <button type="button" class="btn btn-link" aria-label="remove" data-action="" id="id_2"><span class="glyph" aria-hidden="true"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span></span></button>
248 </span>
249 </div>
250 </div>
251 ');
252 $this->assertHTMLEquals($expected, $html);
253 }
254
256 {
257 $f = $this->buildFactory();
258 $if = $this->buildInputFactory();
259 $duration = $if->duration('label', 'byline');
260 $datetime = $if->dateTime('label', 'byline'); // byline will not be rendered in this context
261 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
262 $dr = $this->getDefaultRenderer(null, [], [$filter, $duration, $datetime]);
263 $html = $this->brutallyTrimHTML($dr->render($datetime));
264
265 $expected = $this->brutallyTrimHTML('
266 <fieldset class="c-input" data-il-ui-component="" data-il-ui-input-name="">
267 <label for="id_1">label</label>
268 <div class="c-input__field">
269 <div class="c-input-group">
270 <input id="id_1" type="date" class="c-field-datetime" />
271 </div>
272 </div>
273 </fieldset>
274 ');
275 $this->assertEquals($expected, $html);
276 $this->assertHTMLEquals($expected, $html);
277 }
278
280 {
281 $f = $this->buildFactory();
282 $if = $this->buildInputFactory();
283 $datetime = $if->duration('label', 'byline'); // byline will not be rendered in this context
284 $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
285 $fr = $this->getDefaultRenderer(null, [], [$filter]);
286 $html = $this->brutallyTrimHTML($fr->render($datetime));
287 $label_start = 'duration_default_label_start';
288 $label_end = 'duration_default_label_end';
289
290
291 $expected = $this->brutallyTrimHTML('
292 <div class="col-md-6 col-lg-4 il-popover-container"><div data-il-ui-component="duration-field-input" data-il-ui-input-name="" 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_6" data-placement="bottom"></span>
295 <div class="il-standard-popover-content" style="display:none;" id="id_4"></div>
296 <span class="input-group-addon rightaddon">
297 <button type="button" class="btn btn-link" aria-label="remove" data-action="" id="id_7"><span class="glyph" aria-hidden="true"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span></span></button>
298 </span>
299 </div>
300 </div>
301 ');
302 $this->assertHTMLEquals($expected, $html);
303 }
304}
$datetime
$duration
Test on rendering filter inputs.
testRenderMultiSelectWithHasOptionFilter()
testRenderDateTimeWithDurationAndFilterContext()
__construct(I\Button\Factory $button_factory, 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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$text
Definition: xapiexit.php:21