ILIAS  release_8 Revision v8.24
FilterTest Class Reference

Test on filter implementation. More...

+ Inheritance diagram for FilterTest:
+ Collaboration diagram for FilterTest:

Public Member Functions

 getUIFactory ()
 
 buildDataFactory ()
 
 test_getInputs ()
 
 test_extractParamData ()
 
 test_withRequest ()
 
 test_getData ()
 
 test_with_activated ()
 
 test_with_deactivated ()
 
 test_with_expanded ()
 
 test_with_collapsed ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 buildFactory ()
 
 buildInputFactory ()
 
 buildButtonFactory ()
 
 buildGlyphFactory ()
 
 buildPopoverFactory ()
 
 buildLegacyFactory ()
 
 buildListingFactory ()
 
 inputMock ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Detailed Description

Test on filter implementation.

Definition at line 113 of file FilterTest.php.

Member Function Documentation

◆ buildButtonFactory()

FilterTest::buildButtonFactory ( )
protected

Definition at line 136 of file FilterTest.php.

136 : I\Button\Factory
137 {
139 }
Builds a Color from either hex- or rgb values.
Definition: Factory.php:17

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ buildDataFactory()

FilterTest::buildDataFactory ( )

Definition at line 172 of file FilterTest.php.

172 : Data\Factory
173 {
174 return new Data\Factory();
175 }

Referenced by test_getData(), and test_withRequest().

+ Here is the caller graph for this function:

◆ buildFactory()

FilterTest::buildFactory ( )
protected

Definition at line 115 of file FilterTest.php.

115 : Input\Container\Filter\Factory
116 {
118 new SignalGenerator(),
119 $this->buildInputFactory()
120 );
121 }
buildInputFactory()
Definition: FilterTest.php:123
This is what a factory for input fields looks like.
Definition: Factory.php:29

References buildInputFactory().

Referenced by test_getInputs(), test_with_activated(), test_with_collapsed(), test_with_deactivated(), and test_with_expanded().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildGlyphFactory()

FilterTest::buildGlyphFactory ( )
protected

Definition at line 141 of file FilterTest.php.

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ buildInputFactory()

FilterTest::buildInputFactory ( )
protected

Definition at line 123 of file FilterTest.php.

123 : Input\Field\Factory
124 {
125 $df = new Data\Factory();
126 $language = $this->createMock(ilLanguage::class);
128 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
129 new SignalGenerator(),
130 $df,
131 new ILIAS\Refinery\Factory($df, $language),
132 $language
133 );
134 }
Factory for Date Formats.
Definition: Factory.php:27
Builds data types.
Definition: Factory.php:21
This describes commonalities between all inputs.
Definition: Input.php:49
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.

Referenced by buildFactory(), test_extractParamData(), test_getData(), test_getInputs(), test_with_activated(), test_with_collapsed(), test_with_deactivated(), test_with_expanded(), and test_withRequest().

+ Here is the caller graph for this function:

◆ buildLegacyFactory()

FilterTest::buildLegacyFactory ( )
protected

Definition at line 151 of file FilterTest.php.

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ buildListingFactory()

FilterTest::buildListingFactory ( )
protected

Definition at line 156 of file FilterTest.php.

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ buildPopoverFactory()

FilterTest::buildPopoverFactory ( )
protected

Definition at line 146 of file FilterTest.php.

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ getUIFactory()

FilterTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 161 of file FilterTest.php.

162 {
163 return new WithNoUIFactories(
164 $this->buildButtonFactory(),
165 $this->buildGlyphFactory(),
166 $this->buildPopoverFactory(),
167 $this->buildLegacyFactory(),
168 $this->buildListingFactory()
169 );
170 }
buildButtonFactory()
Definition: FilterTest.php:136
buildLegacyFactory()
Definition: FilterTest.php:151
buildListingFactory()
Definition: FilterTest.php:156
buildGlyphFactory()
Definition: FilterTest.php:141
buildPopoverFactory()
Definition: FilterTest.php:146

References buildButtonFactory(), buildGlyphFactory(), buildLegacyFactory(), buildListingFactory(), and buildPopoverFactory().

+ Here is the call graph for this function:

◆ inputMock()

FilterTest::inputMock ( )
protected
Returns
Input\Field\FormInputInternal|mixed|MockObject

Definition at line 447 of file FilterTest.php.

448 {
449 static $no = 2000;
450 return $this
451 ->getMockBuilder(Input\Field\FormInputInternal::class)
452 ->onlyMethods([
453 "getName",
454 "withDedicatedName",
455 "withNameFrom",
456 "withInput",
457 "getContent",
458 "getLabel",
459 "withLabel",
460 "getByline",
461 "withByline",
462 "isRequired",
463 "withRequired",
464 "isDisabled",
465 "withDisabled",
466 "getValue",
467 "withValue",
468 "getError",
469 "withError",
470 "withAdditionalTransformation",
471 "getUpdateOnLoadCode",
472 "getCanonicalName",
473 "withOnLoadCode",
474 "withAdditionalOnLoadCode",
475 "getOnLoadCode",
476 "withOnUpdate",
477 "appendOnUpdate",
478 "withResetTriggeredSignals",
479 "getTriggeredSignals"
480 ])
481 ->setMockClassName("Mock_InputNo" . ($no++))
482 ->getMock();
483 }

Referenced by test_getData(), and test_withRequest().

+ Here is the caller graph for this function:

◆ test_extractParamData()

FilterTest::test_extractParamData ( )

Definition at line 218 of file FilterTest.php.

218 : void
219 {
220 $filter = new ConcreteFilter(
221 new SignalGenerator(),
222 $this->buildInputFactory(),
223 "#",
224 "#",
225 "#",
226 "#",
227 "#",
228 "#",
229 [],
230 [],
231 false,
232 false
233 );
234 $request = $this->createMock(ServerRequestInterface::class);
235 $request
236 ->expects($this->once())
237 ->method("getQueryParams")
238 ->willReturn([]);
239 $input_data = $filter->_extractParamData($request);
240 $this->assertInstanceOf(InputData::class, $input_data);
241 }

References buildInputFactory().

+ Here is the call graph for this function:

◆ test_getData()

FilterTest::test_getData ( )

Definition at line 296 of file FilterTest.php.

296 : void
297 {
298 $df = $this->buildDataFactory();
299 $request = $this->createMock(ServerRequestInterface::class);
300 $request
301 ->expects($this->once())
302 ->method("getQueryParams")
303 ->willReturn([]);
304
305 $input_1 = $this->inputMock();
306 $input_1
307 ->expects($this->once())
308 ->method("getContent")
309 ->willReturn($df->ok(1));
310 $input_1
311 ->expects($this->once())
312 ->method("withInput")
313 ->willReturn($input_1);
314
315 $input_2 = $this->inputMock();
316 $input_2
317 ->expects($this->once())
318 ->method("getContent")
319 ->willReturn($df->ok(2));
320 $input_2
321 ->expects($this->once())
322 ->method("withInput")
323 ->willReturn($input_2);
324
325 $filter = new ConcreteFilter(
326 new SignalGenerator(),
327 $this->buildInputFactory(),
328 "#",
329 "#",
330 "#",
331 "#",
332 "#",
333 "#",
334 [],
335 [],
336 false,
337 false
338 );
339 $filter->setInputs([$input_1, $input_2]);
340 $filter = $filter->withRequest($request);
341 $this->assertEquals([1, 2], $filter->getData());
342 }
buildDataFactory()
Definition: FilterTest.php:172

References buildDataFactory(), buildInputFactory(), and inputMock().

+ Here is the call graph for this function:

◆ test_getInputs()

FilterTest::test_getInputs ( )

Definition at line 177 of file FilterTest.php.

177 : void
178 {
179 $f = $this->buildFactory();
180 $if = $this->buildInputFactory();
181 $name_source = new FixedNameSourceFilter();
182
183 $inputs = [$if->text(""), $if->select("", [])];
184 $inputs_rendered = [true, true];
185 $filter = $f->standard(
186 "#",
187 "#",
188 "#",
189 "#",
190 "#",
191 "#",
192 $inputs,
193 $inputs_rendered,
194 false,
195 false
196 );
197
198 $seen_names = [];
199 $inputs = $filter->getInputs();
200
201 foreach ($inputs as $input) {
202 $name = $input->getName();
203 $name_source->name = $name;
204
205 // name is a string
206 $this->assertIsString($name);
207
208 // only name is attached
209 $input = array_shift($inputs);
210 $this->assertEquals($input->withNameFrom($name_source), $input);
211
212 // every name can only be contained once.
213 $this->assertNotContains($name, $seen_names);
214 $seen_names[] = $name;
215 }
216 }
if($format !==null) $name
Definition: metadata.php:247

References Vendor\Package\$f, ILIAS\UI\Implementation\Component\Input\$inputs, $name, buildFactory(), and buildInputFactory().

+ Here is the call graph for this function:

◆ test_with_activated()

FilterTest::test_with_activated ( )

Definition at line 344 of file FilterTest.php.

344 : void
345 {
346 $f = $this->buildFactory();
347 $if = $this->buildInputFactory();
348 $inputs = [$if->text(""), $if->text("")];
349 $inputs_rendered = [true, true];
350
351 $filter = $f->standard(
352 "#",
353 "#",
354 "#",
355 "#",
356 "#",
357 "#",
358 $inputs,
359 $inputs_rendered,
360 false,
361 false
362 );
363 $filter1 = $filter->withActivated();
364
365 $this->assertFalse($filter->isActivated());
366 $this->assertTrue($filter1->isActivated());
367 }

References Vendor\Package\$f, ILIAS\UI\Implementation\Component\Input\$inputs, buildFactory(), and buildInputFactory().

+ Here is the call graph for this function:

◆ test_with_collapsed()

FilterTest::test_with_collapsed ( )

Definition at line 419 of file FilterTest.php.

419 : void
420 {
421 $f = $this->buildFactory();
422 $if = $this->buildInputFactory();
423 $inputs = [$if->text(""), $if->text("")];
424 $inputs_rendered = [true, true];
425
426 $filter = $f->standard(
427 "#",
428 "#",
429 "#",
430 "#",
431 "#",
432 "#",
433 $inputs,
434 $inputs_rendered,
435 false,
436 true
437 );
438 $filter1 = $filter->withCollapsed();
439
440 $this->assertTrue($filter->isExpanded());
441 $this->assertFalse($filter1->isExpanded());
442 }

References Vendor\Package\$f, ILIAS\UI\Implementation\Component\Input\$inputs, buildFactory(), and buildInputFactory().

+ Here is the call graph for this function:

◆ test_with_deactivated()

FilterTest::test_with_deactivated ( )

Definition at line 369 of file FilterTest.php.

369 : void
370 {
371 $f = $this->buildFactory();
372 $if = $this->buildInputFactory();
373 $inputs = [$if->text(""), $if->text("")];
374 $inputs_rendered = [true, true];
375
376 $filter = $f->standard(
377 "#",
378 "#",
379 "#",
380 "#",
381 "#",
382 "#",
383 $inputs,
384 $inputs_rendered,
385 true,
386 false
387 );
388 $filter1 = $filter->withDeactivated();
389
390 $this->assertTrue($filter->isActivated());
391 $this->assertFalse($filter1->isActivated());
392 }

References Vendor\Package\$f, ILIAS\UI\Implementation\Component\Input\$inputs, buildFactory(), and buildInputFactory().

+ Here is the call graph for this function:

◆ test_with_expanded()

FilterTest::test_with_expanded ( )

Definition at line 394 of file FilterTest.php.

394 : void
395 {
396 $f = $this->buildFactory();
397 $if = $this->buildInputFactory();
398 $inputs = [$if->text(""), $if->text("")];
399 $inputs_rendered = [true, true];
400
401 $filter = $f->standard(
402 "#",
403 "#",
404 "#",
405 "#",
406 "#",
407 "#",
408 $inputs,
409 $inputs_rendered,
410 false,
411 false
412 );
413 $filter1 = $filter->withExpanded();
414
415 $this->assertFalse($filter->isExpanded());
416 $this->assertTrue($filter1->isExpanded());
417 }

References Vendor\Package\$f, ILIAS\UI\Implementation\Component\Input\$inputs, buildFactory(), and buildInputFactory().

+ Here is the call graph for this function:

◆ test_withRequest()

FilterTest::test_withRequest ( )

Definition at line 243 of file FilterTest.php.

243 : void
244 {
245 $request = $this->createMock(ServerRequestInterface::class);
246 $input_data = $this->createMock(InputData::class);
247
248 $df = $this->buildDataFactory();
249
250 $input_1 = $this->inputMock();
251 $input_1
252 ->expects($this->once())
253 ->method("withInput")
254 ->with($input_data)
255 ->willReturn($input_1);
256 $input_1
257 ->expects($this->once())
258 ->method("getContent")
259 ->willReturn($df->ok(0));
260
261 $input_2 = $this->inputMock();
262 $input_2
263 ->expects($this->once())
264 ->method("withInput")
265 ->with($input_data)
266 ->willReturn($input_2);
267 $input_2
268 ->expects($this->once())
269 ->method("getContent")
270 ->willReturn($df->ok(0));
271
272 $filter = new ConcreteFilter(
273 new SignalGenerator(),
274 $this->buildInputFactory(),
275 "#",
276 "#",
277 "#",
278 "#",
279 "#",
280 "#",
281 [],
282 [],
283 false,
284 false
285 );
286 $filter->setInputs([$input_1, $input_2]);
287 $filter->input_data = $input_data;
288
289 $filter2 = $filter->withRequest($request);
290
291 $this->assertNotSame($filter2, $filter);
292 $this->assertInstanceOf(Filter::class, $filter2);
293 $this->assertEquals([$input_1, $input_2], $filter2->getInputs());
294 }

References buildDataFactory(), buildInputFactory(), and inputMock().

+ Here is the call graph for this function:

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