ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Member Functions

 buildFactory ()
 
 buildInputFactory ()
 
 buildButtonFactory ()
 
 buildGlyphFactory ()
 
 buildPopoverFactory ()
 
 buildLegacyFactory ()
 
 buildListingFactory ()
 
 inputMock ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Test on filter implementation.

Definition at line 74 of file FilterTest.php.

Member Function Documentation

◆ buildButtonFactory()

FilterTest::buildButtonFactory ( )
protected

Definition at line 96 of file FilterTest.php.

97 {
99 }
Builds a Color from either hex- or rgb values.
Definition: Factory.php:14

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ buildDataFactory()

FilterTest::buildDataFactory ( )

Definition at line 132 of file FilterTest.php.

133 {
134 return new \ILIAS\Data\Factory;
135 }

Referenced by test_getData(), and test_withRequest().

+ Here is the caller graph for this function:

◆ buildFactory()

FilterTest::buildFactory ( )
protected

Definition at line 76 of file FilterTest.php.

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

102 {
104 }
This is how the factory for UI elements looks.
Definition: Factory.php:18

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ buildInputFactory()

FilterTest::buildInputFactory ( )
protected

Definition at line 84 of file FilterTest.php.

85 {
86 $df = new Data\Factory();
87 $language = $this->createMock(\ilLanguage::class);
89 new SignalGenerator(),
90 $df,
91 new ILIAS\Refinery\Factory($df, $language),
92 $language
93 );
94 }
Builds data types.
Definition: Factory.php:20
Class ChatMainBarProvider \MainMenu\Provider.

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

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ buildListingFactory()

FilterTest::buildListingFactory ( )
protected

Definition at line 116 of file FilterTest.php.

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ buildPopoverFactory()

FilterTest::buildPopoverFactory ( )
protected

Definition at line 106 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 121 of file FilterTest.php.

122 {
123 return new WithNoUIFactories(
124 $this->buildButtonFactory(),
125 $this->buildGlyphFactory(),
126 $this->buildPopoverFactory(),
127 $this->buildLegacyFactory(),
128 $this->buildListingFactory()
129 );
130 }
buildButtonFactory()
Definition: FilterTest.php:96
buildLegacyFactory()
Definition: FilterTest.php:111
buildListingFactory()
Definition: FilterTest.php:116
buildGlyphFactory()
Definition: FilterTest.php:101
buildPopoverFactory()
Definition: FilterTest.php:106

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

+ Here is the call graph for this function:

◆ inputMock()

FilterTest::inputMock ( )
protected

Definition at line 408 of file FilterTest.php.

409 {
410 static $no = 2000;
411 $config = $this
412 ->getMockBuilder(FormInputInternal::class)
413 ->setMethods(["getName", "withNameFrom", "withInput", "getContent", "getLabel", "withLabel", "getByline", "withByline", "isRequired", "withRequired", "isDisabled", "withDisabled", "getValue", "withValue", "getError", "withError", "withAdditionalTransformation", "withAdditionalConstraint", "getUpdateOnLoadCode", "getCanonicalName", "withOnLoadCode", "withAdditionalOnLoadCode", "getOnLoadCode", "withOnUpdate", "appendOnUpdate", "withResetTriggeredSignals", "getTriggeredSignals"])
414 ->setMockClassName("Mock_InputNo" . ($no++))
415 ->getMock();
416 return $config;
417 }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68

References $config.

Referenced by test_getData(), and test_withRequest().

+ Here is the caller graph for this function:

◆ test_extractParamData()

FilterTest::test_extractParamData ( )

Definition at line 178 of file FilterTest.php.

179 {
180 $filter = new ConcreteFilter(
181 new SignalGenerator(),
182 $this->buildInputFactory(),
183 "#",
184 "#",
185 "#",
186 "#",
187 "#",
188 "#",
189 [],
190 [],
191 false,
192 false
193 );
194 $request = $this->createMock(ServerRequestInterface::class);
195 $request
196 ->expects($this->once())
197 ->method("getQueryParams")
198 ->willReturn([]);
199 $input_data = $filter->_extractParamData($request);
200 $this->assertInstanceOf(InputData::class, $input_data);
201 }

References buildInputFactory().

+ Here is the call graph for this function:

◆ test_getData()

FilterTest::test_getData ( )

Definition at line 256 of file FilterTest.php.

257 {
258 $df = $this->buildDataFactory();
259 $request = $this->createMock(ServerRequestInterface::class);
260 $request
261 ->expects($this->once())
262 ->method("getQueryParams")
263 ->willReturn([]);
264
265 $input_1 = $this->inputMock();
266 $input_1
267 ->expects($this->once())
268 ->method("getContent")
269 ->willReturn($df->ok(1));
270 $input_1
271 ->expects($this->once())
272 ->method("withInput")
273 ->willReturn($input_1);
274
275 $input_2 = $this->inputMock();
276 $input_2
277 ->expects($this->once())
278 ->method("getContent")
279 ->willReturn($df->ok(2));
280 $input_2
281 ->expects($this->once())
282 ->method("withInput")
283 ->willReturn($input_2);
284
285 $filter = new ConcreteFilter(
286 new SignalGenerator(),
287 $this->buildInputFactory(),
288 "#",
289 "#",
290 "#",
291 "#",
292 "#",
293 "#",
294 [],
295 [],
296 false,
297 false
298 );
299 $filter->setInputs([$input_1, $input_2]);
300 $filter = $filter->withRequest($request);
301 $this->assertEquals([1, 2], $filter->getData());
302 }
buildDataFactory()
Definition: FilterTest.php:132

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

+ Here is the call graph for this function:

◆ test_getInputs()

FilterTest::test_getInputs ( )

Definition at line 137 of file FilterTest.php.

138 {
139 $f = $this->buildFactory();
140 $if = $this->buildInputFactory();
141 $name_source = new FixedNameSourceFilter();
142
143 $inputs = [$if->text(""), $if->select("", [])];
144 $inputs_rendered = [true, true];
145 $filter = $f->standard(
146 "#",
147 "#",
148 "#",
149 "#",
150 "#",
151 "#",
152 $inputs,
153 $inputs_rendered,
154 false,
155 false
156 );
157
158 $seen_names = [];
159 $inputs = $filter->getInputs();
160
161 foreach ($inputs as $input) {
162 $name = $input->getName();
163 $name_source->name = $name;
164
165 // name is a string
166 $this->assertIsString($name);
167
168 // only name is attached
169 $input = array_shift($inputs);
170 $this->assertEquals($input->withNameFrom($name_source), $input);
171
172 // every name can only be contained once.
173 $this->assertNotContains($name, $seen_names);
174 $seen_names[] = $name;
175 }
176 }
if($format !==null) $name
Definition: metadata.php:230

References Vendor\Package\$f, $name, buildFactory(), and buildInputFactory().

+ Here is the call graph for this function:

◆ test_with_activated()

FilterTest::test_with_activated ( )

Definition at line 305 of file FilterTest.php.

306 {
307 $f = $this->buildFactory();
308 $if = $this->buildInputFactory();
309 $inputs = [$if->text(""), $if->text("")];
310 $inputs_rendered = [true, true];
311
312 $filter = $f->standard(
313 "#",
314 "#",
315 "#",
316 "#",
317 "#",
318 "#",
319 $inputs,
320 $inputs_rendered,
321 false,
322 false
323 );
324 $filter1 = $filter->withActivated();
325
326 $this->assertFalse($filter->isActivated());
327 $this->assertTrue($filter1->isActivated());
328 }

References Vendor\Package\$f, buildFactory(), and buildInputFactory().

+ Here is the call graph for this function:

◆ test_with_collapsed()

FilterTest::test_with_collapsed ( )

Definition at line 383 of file FilterTest.php.

384 {
385 $f = $this->buildFactory();
386 $if = $this->buildInputFactory();
387 $inputs = [$if->text(""), $if->text("")];
388 $inputs_rendered = [true, true];
389
390 $filter = $f->standard(
391 "#",
392 "#",
393 "#",
394 "#",
395 "#",
396 "#",
397 $inputs,
398 $inputs_rendered,
399 false,
400 true
401 );
402 $filter1 = $filter->withCollapsed();
403
404 $this->assertTrue($filter->isExpanded());
405 $this->assertFalse($filter1->isExpanded());
406 }

References Vendor\Package\$f, buildFactory(), and buildInputFactory().

+ Here is the call graph for this function:

◆ test_with_deactivated()

FilterTest::test_with_deactivated ( )

Definition at line 331 of file FilterTest.php.

332 {
333 $f = $this->buildFactory();
334 $if = $this->buildInputFactory();
335 $inputs = [$if->text(""), $if->text("")];
336 $inputs_rendered = [true, true];
337
338 $filter = $f->standard(
339 "#",
340 "#",
341 "#",
342 "#",
343 "#",
344 "#",
345 $inputs,
346 $inputs_rendered,
347 true,
348 false
349 );
350 $filter1 = $filter->withDeactivated();
351
352 $this->assertTrue($filter->isActivated());
353 $this->assertFalse($filter1->isActivated());
354 }

References Vendor\Package\$f, buildFactory(), and buildInputFactory().

+ Here is the call graph for this function:

◆ test_with_expanded()

FilterTest::test_with_expanded ( )

Definition at line 357 of file FilterTest.php.

358 {
359 $f = $this->buildFactory();
360 $if = $this->buildInputFactory();
361 $inputs = [$if->text(""), $if->text("")];
362 $inputs_rendered = [true, true];
363
364 $filter = $f->standard(
365 "#",
366 "#",
367 "#",
368 "#",
369 "#",
370 "#",
371 $inputs,
372 $inputs_rendered,
373 false,
374 false
375 );
376 $filter1 = $filter->withExpanded();
377
378 $this->assertFalse($filter->isExpanded());
379 $this->assertTrue($filter1->isExpanded());
380 }

References Vendor\Package\$f, buildFactory(), and buildInputFactory().

+ Here is the call graph for this function:

◆ test_withRequest()

FilterTest::test_withRequest ( )

Definition at line 203 of file FilterTest.php.

204 {
205 $request = $this->createMock(ServerRequestInterface::class);
206 $input_data = $this->createMock(InputData::class);
207
208 $df = $this->buildDataFactory();
209
210 $input_1 = $this->inputMock();
211 $input_1
212 ->expects($this->once())
213 ->method("withInput")
214 ->with($input_data)
215 ->willReturn($input_1);
216 $input_1
217 ->expects($this->once())
218 ->method("getContent")
219 ->willReturn($df->ok(0));
220
221 $input_2 = $this->inputMock();
222 $input_2
223 ->expects($this->once())
224 ->method("withInput")
225 ->with($input_data)
226 ->willReturn($input_2);
227 $input_2
228 ->expects($this->once())
229 ->method("getContent")
230 ->willReturn($df->ok(0));
231
232 $filter = new ConcreteFilter(
233 new SignalGenerator(),
234 $this->buildInputFactory(),
235 "#",
236 "#",
237 "#",
238 "#",
239 "#",
240 "#",
241 [],
242 [],
243 false,
244 false
245 );
246 $filter->setInputs([$input_1, $input_2]);
247 $filter->input_data = $input_data;
248
249 $filter2 = $filter->withRequest($request);
250
251 $this->assertNotSame($filter2, $filter);
252 $this->assertInstanceOf(Filter::class, $filter2);
253 $this->assertEquals([$input_1, $input_2], $filter2->getInputs());
254 }

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

+ Here is the call graph for this function:

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