19 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../Base.php");
62 array $is_input_rendered,
66 $this->input_factory = $field_factory;
85 return $this->extractParamData($request);
90 if ($this->input_data !==
null) {
91 return $this->input_data;
94 return parent::extractParamData($request);
99 $this->input_group = $this->input_factory->group($inputs);
119 $this->buildInputFactory()
125 $df =
new Data\Factory();
126 $language = $this->createMock(
ILIAS\
Language\Language::class);
164 $this->buildButtonFactory(),
165 $this->buildGlyphFactory(),
166 $this->buildPopoverFactory(),
167 $this->buildLegacyFactory(),
168 $this->buildListingFactory()
174 return new Data\Factory();
179 $f = $this->buildFactory();
180 $if = $this->buildInputFactory();
183 $inputs = [$if->text(
""), $if->select(
"", [])];
184 $inputs_rendered = [
true,
true];
185 $filter =
$f->standard(
199 $inputs = $filter->getInputs();
202 $name = $input->getName();
203 $name_source->name =
$name;
206 $this->assertIsString(
$name);
210 $this->assertEquals($input->withNameFrom($name_source), $input);
213 $this->assertNotContains(
$name, $seen_names);
214 $seen_names[] =
$name;
222 $this->buildInputFactory(),
234 $request = $this->createMock(ServerRequestInterface::class);
236 ->expects($this->once())
237 ->method(
"getQueryParams")
239 $input_data = $filter->_extractParamData($request);
240 $this->assertInstanceOf(InputData::class, $input_data);
245 $request = $this->createMock(ServerRequestInterface::class);
246 $input_data = $this->createMock(InputData::class);
248 $df = $this->buildDataFactory();
250 $input_1 = $this->inputMock();
252 ->expects($this->once())
253 ->method(
"withInput")
255 ->willReturn($input_1);
257 ->expects($this->once())
258 ->method(
"getContent")
259 ->willReturn($df->ok(0));
261 $input_2 = $this->inputMock();
263 ->expects($this->once())
264 ->method(
"withInput")
266 ->willReturn($input_2);
268 ->expects($this->once())
269 ->method(
"getContent")
270 ->willReturn($df->ok(0));
274 $this->buildInputFactory(),
286 $filter->setInputs([$input_1, $input_2]);
287 $filter->input_data = $input_data;
289 $filter2 = $filter->withRequest($request);
291 $this->assertNotSame($filter2, $filter);
292 $this->assertInstanceOf(Filter::class, $filter2);
293 $this->assertEquals([$input_1, $input_2], $filter2->getInputs());
298 $df = $this->buildDataFactory();
299 $request = $this->createMock(ServerRequestInterface::class);
301 ->expects($this->once())
302 ->method(
"getQueryParams")
305 $input_1 = $this->inputMock();
307 ->expects($this->once())
308 ->method(
"getContent")
309 ->willReturn($df->ok(1));
311 ->expects($this->once())
312 ->method(
"withInput")
313 ->willReturn($input_1);
315 $input_2 = $this->inputMock();
317 ->expects($this->once())
318 ->method(
"getContent")
319 ->willReturn($df->ok(2));
321 ->expects($this->once())
322 ->method(
"withInput")
323 ->willReturn($input_2);
327 $this->buildInputFactory(),
339 $filter->setInputs([$input_1, $input_2]);
340 $filter = $filter->withRequest($request);
341 $this->assertEquals([1, 2], $filter->getData());
346 $f = $this->buildFactory();
347 $if = $this->buildInputFactory();
348 $inputs = [$if->text(
""), $if->text(
"")];
349 $inputs_rendered = [
true,
true];
351 $filter =
$f->standard(
363 $filter1 = $filter->withActivated();
365 $this->assertFalse($filter->isActivated());
366 $this->assertTrue($filter1->isActivated());
371 $f = $this->buildFactory();
372 $if = $this->buildInputFactory();
373 $inputs = [$if->text(
""), $if->text(
"")];
374 $inputs_rendered = [
true,
true];
376 $filter =
$f->standard(
388 $filter1 = $filter->withDeactivated();
390 $this->assertTrue($filter->isActivated());
391 $this->assertFalse($filter1->isActivated());
396 $f = $this->buildFactory();
397 $if = $this->buildInputFactory();
398 $inputs = [$if->text(
""), $if->text(
"")];
399 $inputs_rendered = [
true,
true];
401 $filter =
$f->standard(
413 $filter1 = $filter->withExpanded();
415 $this->assertFalse($filter->isExpanded());
416 $this->assertTrue($filter1->isExpanded());
421 $f = $this->buildFactory();
422 $if = $this->buildInputFactory();
423 $inputs = [$if->text(
""), $if->text(
"")];
424 $inputs_rendered = [
true,
true];
426 $filter =
$f->standard(
438 $filter1 = $filter->withCollapsed();
440 $this->assertTrue($filter->isExpanded());
441 $this->assertFalse($filter1->isExpanded());
451 ->getMockBuilder(
Input\Field\FormInputInternal::class)
470 "withAdditionalTransformation",
471 "getUpdateOnLoadCode",
474 "withAdditionalOnLoadCode",
478 "withResetTriggeredSignals",
479 "getTriggeredSignals" 481 ->setMockClassName(
"Mock_InputNo" . ($no++))
Input Field Factory $input_factory
Interface Observer Contains several chained tasks and infos about them.
getNewName()
Generates a unique name on every call.
_extractParamData(ServerRequestInterface $request)
__construct(SignalGenerator $signal_generator, Input\Field\Factory $field_factory, $toggle_action_on, $toggle_action_off, $expand_action, $collapse_action, $apply_action, $reset_action, array $inputs, array $is_input_rendered, bool $is_activated, bool $is_expanded)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Test on filter implementation.
extractParamData(ServerRequestInterface $request)
__construct(Container $dic, ilPlugin $plugin)