19 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../Base.php");
56 $this->input_factory = $input_factory;
62 return $this->extractRequestData($request);
67 if ($this->input_data !==
null) {
68 return $this->input_data;
71 return parent::extractRequestData($request);
77 $this->input_group = $this->input_factory->group($inputs);
95 return new Input\Container\Form\Factory(
96 $this->buildInputFactory(),
103 $df =
new Data\Factory();
105 return new Input\Field\Factory(
117 return new I\Button\Factory();
122 $dataFactory =
new Data\Factory();
123 $language = $this->createMock(
ILIAS\
Language\Language::class);
126 return $refinery->custom()->transformation($trafo);
136 return new Data\Factory();
141 $this->buildFactory();
142 $if = $this->buildInputFactory();
145 $inputs = [$if->text(
""), $if->text(
"")];
149 $form_inputs = $form->getInputs();
150 $this->assertSameSize($inputs, $form_inputs);
152 foreach ($form_inputs as $input) {
153 $name = $input->getName();
154 $name_source->name =
$name;
157 $this->assertIsString(
$name);
160 $input = array_shift($form_inputs);
161 $this->assertEquals($input->withNameFrom($name_source), $input);
164 $this->assertNotContains(
$name, $seen_names);
165 $seen_names[] =
$name;
172 $request = $this->createMock(ServerRequestInterface::class);
174 ->expects($this->once())
175 ->method(
"getParsedBody")
177 $input_data = $form->_extractRequestData($request);
178 $this->assertInstanceOf(InputData::class, $input_data);
183 $df = $this->buildDataFactory();
184 $request = $this->createMock(ServerRequestInterface::class);
185 $input_data = $this->createMock(InputData::class);
187 $input_1 = $this->inputMock();
189 ->expects($this->once())
190 ->method(
"withInput")
192 ->willReturn($input_1);
194 ->expects($this->once())
195 ->method(
"getContent")
196 ->willReturn($df->ok(0));
198 $input_2 = $this->inputMock();
200 ->expects($this->once())
201 ->method(
"withInput")
203 ->willReturn($input_2);
205 ->expects($this->once())
206 ->method(
"getContent")
207 ->willReturn($df->ok(0));
210 $form->setInputs([$input_1, $input_2]);
211 $form->input_data = $input_data;
213 $form2 = $form->withRequest($request);
215 $this->assertNotSame($form2, $form);
216 $this->assertInstanceOf(Form::class, $form2);
217 $this->assertEquals([$input_1, $input_2], $form2->getInputs());
222 $df = $this->buildDataFactory();
223 $request = $this->createMock(ServerRequestInterface::class);
224 $input_data = $this->createMock(InputData::class);
226 $input_1 = $this->inputMock();
228 ->expects($this->once())
229 ->method(
"withInput")
231 ->willReturn($input_1);
233 ->expects($this->once())
234 ->method(
"getContent")
235 ->willReturn($df->ok(0));
237 $input_2 = $this->inputMock();
239 ->expects($this->once())
240 ->method(
"withInput")
242 ->willReturn($input_2);
244 ->expects($this->once())
245 ->method(
"getContent")
246 ->willReturn($df->ok(0));
249 $form->setInputs([
"foo" => $input_1,
"bar" => $input_2]);
250 $form->input_data = $input_data;
252 $form2 = $form->withRequest($request);
254 $this->assertNotSame($form2, $form);
255 $this->assertInstanceOf(Form::class, $form2);
256 $this->assertEquals([
"foo" => $input_1,
"bar" => $input_2], $form2->getInputs());
261 $df = $this->buildDataFactory();
262 $request = $this->createMock(ServerRequestInterface::class);
264 ->expects($this->once())
265 ->method(
"getParsedBody")
268 $input_1 = $this->inputMock();
270 ->expects($this->once())
271 ->method(
"getContent")
272 ->willReturn($df->ok(1));
274 ->expects($this->once())
275 ->method(
"withInput")
276 ->willReturn($input_1);
278 $input_2 = $this->inputMock();
280 ->expects($this->once())
281 ->method(
"getContent")
282 ->willReturn($df->ok(2));
284 ->expects($this->once())
285 ->method(
"withInput")
286 ->willReturn($input_2);
289 $form->setInputs([$input_1, $input_2]);
290 $form = $form->withRequest($request);
291 $this->assertEquals([1, 2], $form->getData());
296 $df = $this->buildDataFactory();
297 $request = $this->createMock(ServerRequestInterface::class);
299 ->expects($this->once())
300 ->method(
"getParsedBody")
303 $input_1 = $this->inputMock();
305 ->expects($this->once())
306 ->method(
"getContent")
307 ->willReturn($df->ok(1));
309 ->expects($this->once())
310 ->method(
"withInput")
311 ->willReturn($input_1);
313 $input_2 = $this->inputMock();
315 ->expects($this->once())
316 ->method(
"getContent")
317 ->willReturn($df->ok(2));
319 ->expects($this->once())
320 ->method(
"withInput")
321 ->willReturn($input_2);
324 $form->setInputs([
"foo" => $input_1,
"bar" => $input_2]);
325 $form = $form->withRequest($request);
326 $this->assertEquals([
"foo" => 1,
"bar" => 2], $form->getData());
331 $df = $this->buildDataFactory();
332 $request = $this->createMock(ServerRequestInterface::class);
334 ->expects($this->once())
335 ->method(
"getParsedBody")
338 $input_1 = $this->inputMock();
340 ->expects($this->once())
341 ->method(
"getContent")
342 ->willReturn($df->error(
"error"));
344 ->expects($this->once())
345 ->method(
"withInput")
346 ->willReturn($input_1);
348 $input_2 = $this->inputMock();
350 ->expects($this->once())
351 ->method(
"getContent")
352 ->willReturn($df->ok(2));
354 ->expects($this->once())
355 ->method(
"withInput")
356 ->willReturn($input_2);
359 $form->setInputs([
"foo" => $input_1,
"bar" => $input_2]);
361 $i18n =
"THERE IS SOME ERROR IN THIS GROUP";
363 ->expects($this->once())
365 ->with(
"ui_error_in_group")
369 $form = $form->withRequest($request);
375 $df = $this->buildDataFactory();
376 $request = $this->createMock(ServerRequestInterface::class);
378 ->expects($this->once())
379 ->method(
"getParsedBody")
382 $input_1 = $this->inputMock();
384 ->expects($this->once())
385 ->method(
"getContent")
386 ->willReturn($df->ok(1));
388 ->expects($this->once())
389 ->method(
"withInput")
390 ->willReturn($input_1);
392 $input_2 = $this->inputMock();
394 ->expects($this->once())
395 ->method(
"getContent")
396 ->willReturn($df->ok(2));
398 ->expects($this->once())
399 ->method(
"withInput")
400 ->willReturn($input_2);
403 $form->setInputs([$input_1, $input_2]);
405 $form2 = $form->withAdditionalTransformation($this->buildTransformation(
function () {
406 return "transformed";
409 $this->assertNotSame($form2, $form);
410 $form2 = $form2->withRequest($request);
412 $this->assertEquals(
"transformed", $form2->getData());
417 $if = $this->buildInputFactory();
420 "foo" => $if->text(
""),
425 $form->setInputs($inputs);
426 $named_inputs = $form->getInputs();
427 $this->assertEquals(array_keys($inputs), array_keys($named_inputs));
437 ->getMockBuilder(
Input\Field\FormInputInternal::class)
456 "withAdditionalTransformation",
457 "getUpdateOnLoadCode",
460 "withAdditionalOnLoadCode",
464 "withResetTriggeredSignals",
465 "getTriggeredSignals",
468 ->setMockClassName(
"Mock_InputNo" . ($no++))
474 $f = $this->buildFactory();
475 $if = $this->buildInputFactory();
476 $inputs = [$if->text(
""), $if->text(
"")];
479 $this->assertFalse($form->hasRequiredInputs());
484 $f = $this->buildFactory();
485 $if = $this->buildInputFactory();
487 $if->text(
"")->withRequired(
true),
491 $this->assertTrue($form->hasRequiredInputs());
Interface Observer Contains several chained tasks and infos about them.
getNewName()
Generates a unique name on every call.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(Container $dic, ilPlugin $plugin)
language()
description: > Example for rendring a language glyph.