ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
FilterInputTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once(__DIR__ . "/../../../../../../../../vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ . "/../../../../Base.php");
23 require_once(__DIR__ . "/FilterTest.php");
24 
25 use 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(
35  I\Symbol\Factory $symbol_factory,
36  I\Popover\Factory $popover_factory,
37  I\Legacy\Factory $legacy_factory,
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  {
46  return $this->symbol_factory;
47  }
48 
49  public function popover(): I\Popover\Factory
50  {
52  }
53 
54  public function legacy(): I\Legacy\Factory
55  {
56  return $this->legacy_factory;
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\UploadLimitResolver::class),
80  new I\SignalGenerator(),
81  $df,
82  new ILIAS\Refinery\Factory($df, $language),
83  $language
84  );
85  }
86 
87  protected function buildSymbolFactory(): I\Symbol\Factory
88  {
89  return new I\Symbol\Factory(
90  new I\Symbol\Icon\Factory(),
91  new I\Symbol\Glyph\Factory(),
92  new I\Symbol\Avatar\Factory()
93  );
94  }
95 
96  protected function buildPopoverFactory(): I\Popover\Factory
97  {
98  return new I\Popover\Factory(new I\SignalGenerator());
99  }
100 
101  protected function buildLegacyFactory(): I\Legacy\Factory
102  {
103  $mock = $this->createMock(I\Legacy\Factory::class);
104  $mock->method('content')->willReturn(
105  new I\Legacy\Content('', new I\SignalGenerator())
106  );
107  return $mock;
108  }
109 
111  {
113  $this->buildSymbolFactory(),
114  $this->buildPopoverFactory(),
115  $this->buildLegacyFactory(),
116  );
117  }
118 
119  public function testRenderTextWithFilterContext(): void
120  {
121  $f = $this->buildFactory();
122  $if = $this->buildInputFactory();
123  $text = $if->text('label', 'byline'); // byline will not be rendered in this context
124  $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
125  $fr = $this->getDefaultRenderer(null, [], [$filter]);
126  $html = $this->brutallyTrimHTML($fr->render($text));
127 
128  $expected = $this->brutallyTrimHTML('
129  <div class="col-md-6 col-lg-4 il-popover-container">
130  <div class="input-group">
131  <label for="id_1" class="input-group-addon leftaddon">label</label>
132  <input id="id_1" type="text" class="c-field-text" />
133  <span class="input-group-addon rightaddon">
134  <a class="glyph" href="" aria-label="remove" id="id_2">
135  <span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>
136  </a>
137  </span>
138  </div>
139  </div>
140  ');
141  $this->assertHTMLEquals($expected, $html);
142  }
143 
144  public function testRenderNumericWithFilterContext(): void
145  {
146  $f = $this->buildFactory();
147  $if = $this->buildInputFactory();
148  $numeric = $if->numeric('label', 'byline'); // byline will not be rendered in this context
149  $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
150  $fr = $this->getDefaultRenderer(null, [], [$filter]);
151  $html = $this->brutallyTrimHTML($fr->render($numeric));
152 
153  $expected = $this->brutallyTrimHTML('
154  <div class="col-md-6 col-lg-4 il-popover-container">
155  <div class="input-group">
156  <label for="id_1" class="input-group-addon leftaddon">label</label>
157  <input id="id_1" type="number" class="c-field-number" />
158  <span class="input-group-addon rightaddon">
159  <a class="glyph" href="" aria-label="remove" id="id_2">
160  <span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>
161  </a>
162  </span>
163  </div>
164  </div>
165  ');
166  $this->assertHTMLEquals($expected, $html);
167  }
168 
169  public function testRenderSelectWithFilterContext(): void
170  {
171  $f = $this->buildFactory();
172  $if = $this->buildInputFactory();
173  $options = ["one" => "One", "two" => "Two", "three" => "Three"];
174  $select = $if->select('label', $options, 'byline'); // byline will not be rendered in this context
175  $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
176  $fr = $this->getDefaultRenderer(null, [], [$filter]);
177  $html = $this->brutallyTrimHTML($fr->render($select));
178 
179  $expected = $this->brutallyTrimHTML('
180  <div class="col-md-6 col-lg-4 il-popover-container">
181  <div class="input-group">
182  <label for="id_1" class="input-group-addon leftaddon">label</label>
183  <select id="id_1">
184  <option selected="selected" value="">-</option>
185  <option value="one">One</option>
186  <option value="two">Two</option>
187  <option value="three">Three</option>
188  </select>
189  <span class="input-group-addon rightaddon">
190  <a class="glyph" href="" aria-label="remove" id="id_2"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span></a>
191  </span>
192  </div>
193  </div>
194  ');
195  $this->assertHTMLEquals($expected, $html);
196  }
197 
199  {
200  $f = $this->buildFactory();
201  $if = $this->buildInputFactory();
202  $options = ["one" => "One", "two" => "Two", "three" => "Three"];
203  $multi = $if->multiSelect('label', $options, 'byline'); // byline will not be rendered in this context
204  $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
205  $fr = $this->getDefaultRenderer(null, [], [$filter]);
206  $html = $this->brutallyTrimHTML($fr->render($multi));
207 
208  $expected = $this->brutallyTrimHTML('
209  <div class="col-md-6 col-lg-4 il-popover-container">
210  <div class="input-group">
211  <label class="input-group-addon leftaddon">label</label>
212  <span role="button" tabindex="0" class="form-control il-filter-field" id="id_3" data-placement="bottom"></span>
213  <div class="il-standard-popover-content" style="display:none;" id="id_1"></div>
214  <span class="input-group-addon rightaddon">
215  <a class="glyph" href="" aria-label="remove" id="id_4">
216  <span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>
217  </a>
218  </span>
219  </div>
220  {POPOVER}
221  </div>
222  ');
223  $this->assertHTMLEquals($expected, $html);
224  }
225 
226  public function testRenderDateTimeWithFilterContext(): void
227  {
228  $f = $this->buildFactory();
229  $if = $this->buildInputFactory();
230  $datetime = $if->dateTime('label', 'byline'); // byline will not be rendered in this context
231  $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
232  $fr = $this->getDefaultRenderer(null, [], [$filter]);
233  $html = $this->brutallyTrimHTML($fr->render($datetime));
234 
235  $expected = $this->brutallyTrimHTML('
236  <div class="col-md-6 col-lg-4 il-popover-container">
237  <div class="input-group">
238  <label for="id_1" class="input-group-addon leftaddon">label</label>
239  <div class="c-input-group">
240  <input id="id_1" type="date" class="c-field-datetime" />
241  </div>
242  <span class="input-group-addon rightaddon">
243  <a class="glyph" href="" aria-label="remove" id="id_2">
244  <span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>
245  </a>
246  </span>
247  </div>
248  </div>
249  ');
250  $this->assertHTMLEquals($expected, $html);
251  }
252 
254  {
255  $f = $this->buildFactory();
256  $if = $this->buildInputFactory();
257  $duration = $if->duration('label', 'byline');
258  $datetime = $if->dateTime('label', 'byline'); // byline will not be rendered in this context
259  $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
260  $dr = $this->getDefaultRenderer(null, [], [$filter, $duration, $datetime]);
261  $html = $this->brutallyTrimHTML($dr->render($datetime));
262 
263  $expected = $this->brutallyTrimHTML('
264  <fieldset class="c-input" data-il-ui-component="" data-il-ui-input-name="">
265  <label for="id_1">label</label>
266  <div class="c-input__field">
267  <div class="c-input-group">
268  <input id="id_1" type="date" class="c-field-datetime" />
269  </div>
270  </div>
271  </fieldset>
272  ');
273  $this->assertEquals($expected, $html);
274  $this->assertHTMLEquals($expected, $html);
275  }
276 
277  public function testRenderDurationWithFilterContext(): void
278  {
279  $f = $this->buildFactory();
280  $if = $this->buildInputFactory();
281  $datetime = $if->duration('label', 'byline'); // byline will not be rendered in this context
282  $filter = $f->standard("#", "#", "#", "#", "#", "#", [], [], false, false);
283  $fr = $this->getDefaultRenderer(null, [], [$filter]);
284  $html = $this->brutallyTrimHTML($fr->render($datetime));
285  $label_start = 'duration_default_label_start';
286  $label_end = 'duration_default_label_end';
287 
288 
289  $expected = $this->brutallyTrimHTML('
290  <div class="col-md-6 col-lg-4 il-popover-container">
291  <div class="input-group">
292  <label class="input-group-addon leftaddon">label</label>
293  <span role="button" tabindex="0" class="form-control il-filter-field" id="id_7" data-placement="bottom"></span>
294  <div class="il-standard-popover-content" style="display:none;" id="id_5"></div>
295  <span class="input-group-addon rightaddon">
296  <a class="glyph" href="" aria-label="remove" id="id_8">
297  <span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>
298  </a>
299  </span>
300  </div>
301  {POPOVER}
302  </div>
303  ');
304  $this->assertHTMLEquals($expected, $html);
305  }
306 }
I Popover Factory $popover_factory
popover()
description: purpose: > Popovers can be used when space is scarce i.e.
legacy()
description: purpose: > legacy components are used as provisional elements in the UI framework while...
__construct(I\Symbol\Factory $symbol_factory, I\Popover\Factory $popover_factory, I\Legacy\Factory $legacy_factory,)
Interface Observer Contains several chained tasks and infos about them.
$datetime
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
symbol()
description: purpose: > Symbols are graphical representations of concepts or contexts quickly compre...
$duration
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
testRenderMultiSelectWithFilterContext()
Test on rendering filter inputs.
testRenderDateTimeWithDurationAndFilterContext()
Builds data types.
Definition: Factory.php:35