ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
FilterTest Class Reference

Test on filter implementation. More...

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

Public Member Functions

 getUIFactory ()
 
 buildDataFactory ()
 
 testGetInputs ()
 
 testExtractParamData ()
 
 testWithRequest ()
 
 testGetData ()
 
 testWithActivated ()
 
 testWithDeactivated ()
 
 testWithExpanded ()
 
 testWithCollapsed ()
 

Protected Member Functions

 buildFactory ()
 
 buildInputFactory ()
 
 buildButtonFactory ()
 
 buildGlyphFactory ()
 
 buildPopoverFactory ()
 
 buildLegacyFactory ()
 
 buildListingFactory ()
 
 inputMock ()
 

Detailed Description

Test on filter implementation.

Definition at line 113 of file FilterTest.php.

Member Function Documentation

◆ buildButtonFactory()

FilterTest::buildButtonFactory ( )
protected

Definition at line 137 of file FilterTest.php.

137 : I\Button\Factory
138 {
140 }
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ buildDataFactory()

FilterTest::buildDataFactory ( )

Definition at line 173 of file FilterTest.php.

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

Referenced by testGetData(), and testWithRequest().

+ 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
Factory for Date Formats.
Definition: Factory.php:27

References buildInputFactory().

Referenced by testGetInputs(), testWithActivated(), testWithCollapsed(), testWithDeactivated(), and testWithExpanded().

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

◆ buildGlyphFactory()

FilterTest::buildGlyphFactory ( )
protected

Definition at line 142 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(ILIAS\Language\Language::class);
128 $this->createMock(\ILIAS\UI\Implementation\Component\Input\Field\Node\Factory::class),
129 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
130 new SignalGenerator(),
131 $df,
132 new ILIAS\Refinery\Factory($df, $language),
133 $language
134 );
135 }
Builds data types.
Definition: Factory.php:36
This describes commonalities between all inputs.
Definition: Input.php:47
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

Referenced by buildFactory(), testExtractParamData(), testGetData(), testGetInputs(), testWithActivated(), testWithCollapsed(), testWithDeactivated(), testWithExpanded(), and testWithRequest().

+ Here is the caller graph for this function:

◆ buildLegacyFactory()

FilterTest::buildLegacyFactory ( )
protected

Definition at line 152 of file FilterTest.php.

152 : I\Legacy\Factory
153 {
155 }

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ buildListingFactory()

FilterTest::buildListingFactory ( )
protected

Definition at line 157 of file FilterTest.php.

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ buildPopoverFactory()

FilterTest::buildPopoverFactory ( )
protected

Definition at line 147 of file FilterTest.php.

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ getUIFactory()

FilterTest::getUIFactory ( )

Definition at line 162 of file FilterTest.php.

163 {
164 return new WithNoUIFactories(
165 $this->buildButtonFactory(),
166 $this->buildGlyphFactory(),
167 $this->buildPopoverFactory(),
168 $this->buildLegacyFactory(),
169 $this->buildListingFactory()
170 );
171 }
buildButtonFactory()
Definition: FilterTest.php:137
buildLegacyFactory()
Definition: FilterTest.php:152
buildListingFactory()
Definition: FilterTest.php:157
buildGlyphFactory()
Definition: FilterTest.php:142
buildPopoverFactory()
Definition: FilterTest.php:147

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 448 of file FilterTest.php.

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

Referenced by testGetData(), and testWithRequest().

+ Here is the caller graph for this function:

◆ testExtractParamData()

FilterTest::testExtractParamData ( )

Definition at line 219 of file FilterTest.php.

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

References buildInputFactory().

+ Here is the call graph for this function:

◆ testGetData()

FilterTest::testGetData ( )

Definition at line 297 of file FilterTest.php.

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

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

+ Here is the call graph for this function:

◆ testGetInputs()

FilterTest::testGetInputs ( )

Definition at line 178 of file FilterTest.php.

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

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

+ Here is the call graph for this function:

◆ testWithActivated()

FilterTest::testWithActivated ( )

Definition at line 345 of file FilterTest.php.

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

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

+ Here is the call graph for this function:

◆ testWithCollapsed()

FilterTest::testWithCollapsed ( )

Definition at line 420 of file FilterTest.php.

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

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

+ Here is the call graph for this function:

◆ testWithDeactivated()

FilterTest::testWithDeactivated ( )

Definition at line 370 of file FilterTest.php.

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

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

+ Here is the call graph for this function:

◆ testWithExpanded()

FilterTest::testWithExpanded ( )

Definition at line 395 of file FilterTest.php.

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

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

+ Here is the call graph for this function:

◆ testWithRequest()

FilterTest::testWithRequest ( )

Definition at line 244 of file FilterTest.php.

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

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

+ Here is the call graph for this function:

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