ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
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  }

◆ buildDataFactory()

FilterTest::buildDataFactory ( )

Definition at line 173 of file FilterTest.php.

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

◆ 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

◆ buildGlyphFactory()

FilterTest::buildGlyphFactory ( )
protected

Definition at line 142 of file FilterTest.php.

142  : I\Symbol\Factory
143  {
145  }

◆ 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  }
Interface Observer Contains several chained tasks and infos about them.
Builds data types.
Definition: Factory.php:35
This describes commonalities between all inputs.
Definition: Input.php:46

◆ buildLegacyFactory()

FilterTest::buildLegacyFactory ( )
protected

Definition at line 152 of file FilterTest.php.

152  : I\Legacy\Factory
153  {
155  }

◆ buildListingFactory()

FilterTest::buildListingFactory ( )
protected

Definition at line 157 of file FilterTest.php.

157  : I\Listing\Factory
158  {
160  }

◆ buildPopoverFactory()

FilterTest::buildPopoverFactory ( )
protected

◆ getUIFactory()

FilterTest::getUIFactory ( )

Definition at line 162 of file FilterTest.php.

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

◆ inputMock()

FilterTest::inputMock ( )
protected
Returns
Input|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  }
This describes commonalities between all inputs.
Definition: Input.php:46

◆ 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  }
buildInputFactory()
Definition: FilterTest.php:123

◆ 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
buildInputFactory()
Definition: FilterTest.php:123

◆ testGetInputs()

FilterTest::testGetInputs ( )

Definition at line 178 of file FilterTest.php.

References Vendor\Package\$f, ILIAS\UI\Implementation\Component\Input\$inputs, and FixedNameSourceFilter\$name.

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  }
buildInputFactory()
Definition: FilterTest.php:123

◆ testWithActivated()

FilterTest::testWithActivated ( )

Definition at line 345 of file FilterTest.php.

References Vendor\Package\$f, and ILIAS\UI\Implementation\Component\Input\$inputs.

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  }
buildInputFactory()
Definition: FilterTest.php:123

◆ testWithCollapsed()

FilterTest::testWithCollapsed ( )

Definition at line 420 of file FilterTest.php.

References Vendor\Package\$f, and ILIAS\UI\Implementation\Component\Input\$inputs.

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  }
buildInputFactory()
Definition: FilterTest.php:123

◆ testWithDeactivated()

FilterTest::testWithDeactivated ( )

Definition at line 370 of file FilterTest.php.

References Vendor\Package\$f, and ILIAS\UI\Implementation\Component\Input\$inputs.

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  }
buildInputFactory()
Definition: FilterTest.php:123

◆ testWithExpanded()

FilterTest::testWithExpanded ( )

Definition at line 395 of file FilterTest.php.

References Vendor\Package\$f, and ILIAS\UI\Implementation\Component\Input\$inputs.

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  }
buildInputFactory()
Definition: FilterTest.php:123

◆ 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  }
buildDataFactory()
Definition: FilterTest.php:173
buildInputFactory()
Definition: FilterTest.php:123

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