ILIAS  release_8 Revision v8.24
InputTest Class Reference

Test on field implementation. More...

+ Inheritance diagram for InputTest:
+ Collaboration diagram for InputTest:

Public Member Functions

 setUp ()
 
 test_constructor ()
 
 test_withLabel ()
 
 test_withByline ()
 
 test_withRequired ()
 
 test_withRequired_and_custom_constraint ()
 
 test_withDisabled ()
 
 test_withValue ()
 
 test_withValue_throws ()
 
 test_withName ()
 
 test_withNameForNamedInput ()
 
 test_withError ()
 
 test_getContent ()
 
 test_withInput ()
 
 test_only_run_withInput_with_name ()
 
 test_withInput_and_transformation ()
 
 test_withInput_and_transformation_different_order ()
 
 test_withInput_and_constraint_successfull ()
 
 test_withInput_and_constraint_fails ()
 
 test_withInput_and_constraint_fails_different_order ()
 
 test_withInput_transformation_and_constraint ()
 
 test_withInput_transformation_and_constraint_different_order ()
 
 test_withInput_constraint_and_transformation ()
 
 test_withInput_constraint_fails_and_transformation ()
 
 test_withInput_constraint_fails_and_transformation_different_order ()
 
 test_withInput_requirement_constraint ()
 
 test_withInput_toggle_requirement ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Attributes

DataFactory $data_factory
 
Refinery $refinery
 
DefInput $input
 
DefInput $dedicated_input
 
DefNamesource $name_source
 
FormInput $named_input
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Detailed Description

Test on field implementation.

Definition at line 123 of file InputTest.php.

Member Function Documentation

◆ setUp()

InputTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 132 of file InputTest.php.

132 : void
133 {
134 $this->data_factory = new DataFactory();
135 $language = $this->createMock(ilLanguage::class);
136 $this->refinery = new Refinery($this->data_factory, $language);
137 $this->input = new DefInput(
138 $this->data_factory,
139 $this->refinery,
140 "label",
141 "byline"
142 );
143 $this->named_input = $this->input->withDedicatedName('dedicated_name');
144 $this->name_source = new DefNamesource();
145 }

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ test_constructor()

InputTest::test_constructor ( )

Definition at line 147 of file InputTest.php.

147 : void
148 {
149 $this->assertEquals("label", $this->input->getLabel());
150 $this->assertEquals("byline", $this->input->getByline());
151 }

◆ test_getContent()

InputTest::test_getContent ( )

Definition at line 252 of file InputTest.php.

252 : void
253 {
254 $this->expectException(LogicException::class);
255
256 $this->input->getContent();
257 }

◆ test_only_run_withInput_with_name()

InputTest::test_only_run_withInput_with_name ( )

Definition at line 277 of file InputTest.php.

277 : void
278 {
279 $raised = false;
280 try {
281 $this->input->withInput(new DefInputData([]));
282 $this->assertFalse("This should not happen.");
283 } catch (LogicException $e) {
284 $raised = true;
285 }
286 $this->assertTrue($raised);
287 }

References Vendor\Package\$e.

◆ test_withByline()

InputTest::test_withByline ( )

Definition at line 161 of file InputTest.php.

161 : void
162 {
163 $byline = "new byline";
164 $input = $this->input->withByline($byline);
165 $this->assertEquals($byline, $input->getByline());
166 $this->assertNotSame($this->input, $input);
167 }
withByline(string $byline)
Get an input like this, but with an additional/replaced label.static
Definition: FormInput.php:106
DefInput $input
Definition: InputTest.php:127

References $input, ILIAS\UI\Implementation\Component\Input\Field\FormInput\getByline(), and ILIAS\UI\Implementation\Component\Input\Field\FormInput\withByline().

+ Here is the call graph for this function:

◆ test_withDisabled()

InputTest::test_withDisabled ( )

Definition at line 191 of file InputTest.php.

191 : void
192 {
193 $this->assertFalse($this->input->isDisabled());
194 $input = $this->input->withDisabled(true);
195 $this->assertTrue($input->isDisabled());
196 $input = $input->withDisabled(false);
197 $this->assertFalse($input->isDisabled());
198 }
withDisabled(bool $is_disabled)
Get an input like this, but set it to a disabled state.static
Definition: FormInput.php:143

References $input, ILIAS\UI\Implementation\Component\Input\Field\FormInput\isDisabled(), and ILIAS\UI\Implementation\Component\Input\Field\FormInput\withDisabled().

+ Here is the call graph for this function:

◆ test_withError()

InputTest::test_withError ( )

Definition at line 243 of file InputTest.php.

243 : void
244 {
245 $error = "error";
246 $input = $this->input->withError($error);
247 $this->assertEquals(null, $this->input->getError());
248 $this->assertEquals($error, $input->getError());
249 $this->assertNotSame($this->input, $input);
250 }
withError(string $error)
Get an input like this one, with a different error.
getError()
The error of the input as used in HTML.

References $input, ILIAS\UI\Implementation\Component\Input\InputInternal\getError(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withError().

+ Here is the call graph for this function:

◆ test_withInput()

InputTest::test_withInput ( )

Definition at line 259 of file InputTest.php.

259 : void
260 {
261 $name = "name_0";
262 $value = "valu";
263 $input = $this->input->withNameFrom($this->name_source);
264 $values = new DefInputData([$name => $value]);
265
266 $input2 = $input->withInput($values);
267 $res = $input2->getContent();
268
269 $this->assertInstanceOf(Result::class, $res);
270 $this->assertTrue($res->isOk());
271 $this->assertEquals($value, $res->value());
272
273 $this->assertNotSame($input, $input2);
274 $this->assertEquals($value, $input2->getValue());
275 }
withNameFrom(NameSource $source)
Get an input like this one, with a different name.
$res
Definition: ltiservices.php:69
if($format !==null) $name
Definition: metadata.php:247

References $input, $name, $res, ILIAS\UI\Implementation\Component\Input\Field\FormInput\withInput(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withInput_and_constraint_fails()

InputTest::test_withInput_and_constraint_fails ( )

Definition at line 361 of file InputTest.php.

361 : void
362 {
363 $name = "name_0";
364 $value = "value";
365 $error = "an error";
366 $input = $this->input->withNameFrom($this->name_source);
367 $values = new DefInputData([$name => $value]);
368
369 $input2 = $input->withAdditionalTransformation($this->refinery->custom()->constraint(function () {
370 return false;
371 }, $error))->withInput($values);
372 $res = $input2->getContent();
373
374 $this->assertInstanceOf(Result::class, $res);
375 $this->assertTrue($res->isError());
376 $this->assertEquals($error, $res->error());
377
378 $this->assertNotSame($input, $input2);
379 $this->assertEquals($value, $input2->getValue());
380 $this->assertEquals($error, $input2->getError());
381 }
static return function(ContainerConfigurator $containerConfigurator)
Definition: basic_rector.php:9
withAdditionalTransformation(Transformation $trafo)
Apply a transformation to the content of the input.

References $input, $name, $res, function, ILIAS\Repository\refinery(), ILIAS\UI\Component\Input\Input\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withInput_and_constraint_fails_different_order()

InputTest::test_withInput_and_constraint_fails_different_order ( )

Definition at line 383 of file InputTest.php.

383 : void
384 {
385 $rc = $this->refinery->custom();
386
387 $name = "name_0";
388 $value = "value";
389 $error = "an error";
390 $input = $this->input->withNameFrom($this->name_source);
391 $values = new DefInputData([$name => $value]);
392
393 $input2 = $input
394 ->withInput($values)
395 ->withAdditionalTransformation($rc->constraint(function () {
396 return false;
397 }, $error));
398
399 $res = $input2->getContent();
400
401 $this->assertInstanceOf(Result::class, $res);
402 $this->assertTrue($res->isError());
403 $this->assertEquals($error, $res->error());
404
405 $this->assertNotSame($input, $input2);
406 $this->assertEquals($value, $input2->getValue());
407 $this->assertEquals($error, $input2->getError());
408 }

References $input, $name, $res, function, ILIAS\Repository\refinery(), ILIAS\UI\Implementation\Component\Input\Field\FormInput\withInput(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withInput_and_constraint_successfull()

InputTest::test_withInput_and_constraint_successfull ( )

Definition at line 339 of file InputTest.php.

339 : void
340 {
341 $name = "name_0";
342 $value = "value";
343 $error = "an error";
344 $input = $this->input->withNameFrom($this->name_source);
345 $values = new DefInputData([$name => $value]);
346
347 $input2 = $input->withAdditionalTransformation($this->refinery->custom()->constraint(function () {
348 return true;
349 }, $error))->withInput($values);
350 $res = $input2->getContent();
351
352 $this->assertInstanceOf(Result::class, $res);
353 $this->assertTrue($res->isOk());
354 $this->assertEquals($value, $res->value());
355
356 $this->assertNotSame($input, $input2);
357 $this->assertEquals($value, $input2->getValue());
358 $this->assertEquals(null, $input2->getError());
359 }

References $input, $name, $res, function, ILIAS\Repository\refinery(), ILIAS\UI\Component\Input\Input\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withInput_and_transformation()

InputTest::test_withInput_and_transformation ( )

Definition at line 289 of file InputTest.php.

289 : void
290 {
291 $name = "name_0";
292 $value = "value";
293 $transform_to = "other value";
294 $input = $this->input->withNameFrom($this->name_source);
295 $values = new DefInputData([$name => $value]);
296
298 $this->refinery->custom()->transformation(function ($v) use ($value, $transform_to): string {
299 $this->assertEquals($value, $v);
300 return $transform_to;
301 })
302 )->withInput($values);
303
304 $res = $input2->getContent();
305
306 $this->assertInstanceOf(Result::class, $res);
307 $this->assertTrue($res->isOk());
308 $this->assertEquals($transform_to, $res->value());
309
310 $this->assertNotSame($input, $input2);
311 $this->assertEquals($value, $input2->getValue());
312 }

References $input, $name, $res, function, ILIAS\Repository\refinery(), ILIAS\UI\Component\Input\Input\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withInput_and_transformation_different_order()

InputTest::test_withInput_and_transformation_different_order ( )

Definition at line 314 of file InputTest.php.

314 : void
315 {
316 $name = "name_0";
317 $value = "value";
318 $transform_to = "other value";
319 $input = $this->input->withNameFrom($this->name_source);
320 $values = new DefInputData([$name => $value]);
321
322 $input2 = $input->withInput($values)->withAdditionalTransformation(
323 $this->refinery->custom()->transformation(function ($v) use ($value, $transform_to): string {
324 $this->assertEquals($value, $v);
325 return $transform_to;
326 })
327 );
328
329 $res = $input2->getContent();
330
331 $this->assertInstanceOf(Result::class, $res);
332 $this->assertTrue($res->isOk());
333 $this->assertEquals($transform_to, $res->value());
334
335 $this->assertNotSame($input, $input2);
336 $this->assertEquals($value, $input2->getValue());
337 }

References $input, $name, $res, function, ILIAS\Repository\refinery(), ILIAS\UI\Implementation\Component\Input\Field\FormInput\withInput(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withInput_constraint_and_transformation()

InputTest::test_withInput_constraint_and_transformation ( )

Definition at line 474 of file InputTest.php.

474 : void
475 {
476 $name = "name_0";
477 $value = "value";
478 $transform_to = "other value";
479 $error = "an error";
480 $input = $this->input->withNameFrom($this->name_source);
481 $values = new DefInputData([$name => $value]);
482
484 $this->refinery->custom()->constraint(function ($v) use ($value): bool {
485 $this->assertEquals($value, $v);
486 return true;
487 }, $error)
488 )->withAdditionalTransformation(
489 $this->refinery->custom()->transformation(function ($v) use ($value, $transform_to): string {
490 $this->assertEquals($value, $v);
491 return $transform_to;
492 })
493 )->withInput($values);
494
495 $res = $input2->getContent();
496
497 $this->assertInstanceOf(Result::class, $res);
498 $this->assertTrue($res->isOk());
499 $this->assertEquals($transform_to, $res->value());
500
501 $this->assertNotSame($input, $input2);
502 $this->assertEquals($value, $input2->getValue());
503 $this->assertEquals(null, $input2->getError());
504 }

References $input, $name, $res, function, ILIAS\Repository\refinery(), ILIAS\UI\Component\Input\Input\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withInput_constraint_fails_and_transformation()

InputTest::test_withInput_constraint_fails_and_transformation ( )

Definition at line 506 of file InputTest.php.

506 : void
507 {
508 $rc = $this->refinery->custom();
509
510 $name = "name_0";
511 $value = "value";
512 $transform_to = "other value";
513 $error = "an error";
514 $input = $this->input->withNameFrom($this->name_source);
515 $values = new DefInputData([$name => $value]);
516
517 $input2 = $input
518 ->withAdditionalTransformation($rc->constraint(function ($v) use ($value): bool {
519 $this->assertEquals($value, $v);
520
521 return false;
522 }, $error))
523 ->withAdditionalTransformation($rc->transformation(function () use ($value, $transform_to): string {
524 $this->assertFalse("This should not happen");
525
526 return $transform_to;
527 }))->withInput($values);
528 $res = $input2->getContent();
529
530 $this->assertInstanceOf(Result::class, $res);
531 $this->assertTrue($res->isError());
532 $this->assertEquals($error, $res->error());
533
534 $this->assertNotSame($input, $input2);
535 $this->assertEquals($value, $input2->getValue());
536 $this->assertEquals($error, $input2->getError());
537 }

References $input, $name, $res, function, ILIAS\Repository\refinery(), ILIAS\UI\Component\Input\Input\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withInput_constraint_fails_and_transformation_different_order()

InputTest::test_withInput_constraint_fails_and_transformation_different_order ( )

Definition at line 539 of file InputTest.php.

539 : void
540 {
541 $name = "name_0";
542 $value = "value";
543 $transform_to = "other value";
544 $error = "an error";
545 $input = $this->input->withNameFrom($this->name_source);
546 $values = new DefInputData([$name => $value]);
547
548 $input2 = $input->withInput($values)->withAdditionalTransformation(
549 $this->refinery->custom()->constraint(function ($v) use ($value): bool {
550 $this->assertEquals($value, $v);
551 return false;
552 }, $error)
553 )->withAdditionalTransformation(
554 $this->refinery->custom()->transformation(function () use ($value, $transform_to): string {
555 $this->assertFalse("This should not happen");
556 return $transform_to;
557 })
558 );
559
560 $res = $input2->getContent();
561
562 $this->assertInstanceOf(Result::class, $res);
563 $this->assertTrue($res->isError());
564 $this->assertEquals($error, $res->error());
565
566 $this->assertNotSame($input, $input2);
567 $this->assertEquals($value, $input2->getValue());
568 $this->assertEquals($error, $input2->getError());
569 }

References $input, $name, $res, function, ILIAS\Repository\refinery(), ILIAS\UI\Implementation\Component\Input\Field\FormInput\withInput(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withInput_requirement_constraint()

InputTest::test_withInput_requirement_constraint ( )

Definition at line 571 of file InputTest.php.

571 : void
572 {
573 $name = "name_0";
574 $value = "Adam";
575 $error = "Your name does not start with an H";
576 $input = $this->input->withNameFrom($this->name_source);
577 $values = new DefInputData([$name => $value]);
578 $custom_constraint = $this->refinery->custom()->constraint(
579 function ($value) {
580 return (substr($value, 0, 1) === 'H') ? true : false;
581 },
582 $error
583 );
584 $input2 = $input->withRequired(true, $custom_constraint)->withInput($values);
585 $res = $input2->getContent();
586 $this->assertInstanceOf(Result::class, $res);
587 $this->assertFalse($res->isOk());
588 $this->assertEquals($error, $input2->getError());
589 }
withRequired(bool $is_required, ?Constraint $requirement_constraint=null)
Get an input like this, but set the field to be required (or not).With the optional $required_constra...
Definition: FormInput.php:124

References $input, $name, $res, ILIAS\Repository\refinery(), ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom(), and ILIAS\UI\Implementation\Component\Input\Field\FormInput\withRequired().

+ Here is the call graph for this function:

◆ test_withInput_toggle_requirement()

InputTest::test_withInput_toggle_requirement ( )

Definition at line 591 of file InputTest.php.

591 : void
592 {
593 $name = "name_0";
594 $value = "value";
595 $error = "an error";
596 $input = $this->input->withNameFrom($this->name_source);
597 $values = new DefInputData([$name => $value]);
598
599 $custom_constraint = $this->refinery->custom()->constraint(function () {
600 return false;
601 }, $error);
602
603 $input2 = $input->withRequired(true, $custom_constraint)->withRequired(false)->withInput($values);
604 $res = $input2->getContent();
605
606 $this->assertInstanceOf(Result::class, $res);
607 $this->assertFalse($res->isError());
608 $this->assertEquals($value, $res->value());
609 }

References $input, $name, $res, ILIAS\Repository\refinery(), ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom(), and ILIAS\UI\Implementation\Component\Input\Field\FormInput\withRequired().

+ Here is the call graph for this function:

◆ test_withInput_transformation_and_constraint()

InputTest::test_withInput_transformation_and_constraint ( )

Definition at line 410 of file InputTest.php.

410 : void
411 {
412 $name = "name_0";
413 $value = "value";
414 $transform_to = "other value";
415 $error = "an error";
416 $input = $this->input->withNameFrom($this->name_source);
417 $values = new DefInputData([$name => $value]);
418
420 $this->refinery->custom()->transformation(function ($v) use ($value, $transform_to): string {
421 $this->assertEquals($value, $v);
422 return $transform_to;
423 })
424 )->withAdditionalTransformation(
425 $this->refinery->custom()->constraint(function ($v) use ($transform_to): bool {
426 $this->assertEquals($transform_to, $v);
427 return true;
428 }, $error)
429 )->withInput($values);
430
431 $res = $input2->getContent();
432
433 $this->assertInstanceOf(Result::class, $res);
434 $this->assertTrue($res->isOk());
435 $this->assertEquals($transform_to, $res->value());
436
437 $this->assertNotSame($input, $input2);
438 $this->assertEquals($value, $input2->getValue());
439 $this->assertEquals(null, $input2->getError());
440 }

References $input, $name, $res, function, ILIAS\Repository\refinery(), ILIAS\UI\Component\Input\Input\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withInput_transformation_and_constraint_different_order()

InputTest::test_withInput_transformation_and_constraint_different_order ( )

Definition at line 442 of file InputTest.php.

442 : void
443 {
444 $name = "name_0";
445 $value = "value";
446 $transform_to = "other value";
447 $error = "an error";
448 $input = $this->input->withNameFrom($this->name_source);
449 $values = new DefInputData([$name => $value]);
450
451 $input2 = $input->withInput($values)->withAdditionalTransformation(
452 $this->refinery->custom()->transformation(function ($v) use ($value, $transform_to): string {
453 $this->assertEquals($value, $v);
454 return $transform_to;
455 })
456 )->withAdditionalTransformation(
457 $this->refinery->custom()->constraint(function ($v) use ($transform_to): bool {
458 $this->assertEquals($transform_to, $v);
459 return true;
460 }, $error)
461 );
462
463 $res = $input2->getContent();
464
465 $this->assertInstanceOf(Result::class, $res);
466 $this->assertTrue($res->isOk());
467 $this->assertEquals($transform_to, $res->value());
468
469 $this->assertNotSame($input, $input2);
470 $this->assertEquals($value, $input2->getValue());
471 $this->assertEquals(null, $input2->getError());
472 }

References $input, $name, $res, function, ILIAS\Repository\refinery(), ILIAS\UI\Implementation\Component\Input\Field\FormInput\withInput(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withLabel()

InputTest::test_withLabel ( )

Definition at line 153 of file InputTest.php.

153 : void
154 {
155 $label = "new label";
156 $input = $this->input->withLabel($label);
157 $this->assertEquals($label, $input->getLabel());
158 $this->assertNotSame($this->input, $input);
159 }
withLabel(string $label)
Get an input like this, but with a replaced label.static
Definition: FormInput.php:88

References $input, ILIAS\UI\Implementation\Component\Input\Field\FormInput\getLabel(), and ILIAS\UI\Implementation\Component\Input\Field\FormInput\withLabel().

+ Here is the call graph for this function:

◆ test_withName()

InputTest::test_withName ( )

Definition at line 223 of file InputTest.php.

223 : void
224 {
225 $name = "name_0";
226 $input = $this->input->withNameFrom($this->name_source);
227 $this->assertEquals(null, $this->input->getName());
228 $this->assertEquals($name, $input->getName());
229 $this->assertNotSame($this->input, $input);
230 $this->assertEquals(1, $this->name_source->count);
231 }
getName()
The name of the input as used in HTML.

References $input, $name, ILIAS\UI\Implementation\Component\Input\InputInternal\getName(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withNameForNamedInput()

InputTest::test_withNameForNamedInput ( )

Definition at line 233 of file InputTest.php.

233 : void
234 {
235 $name = "dedicated_name_0";
236 $input = $this->named_input->withNameFrom($this->name_source);
237 $this->assertEquals(null, $this->named_input->getName());
238 $this->assertEquals($name, $input->getName());
239 $this->assertNotSame($this->named_input, $input);
240 $this->assertEquals(1, $this->name_source->count);
241 }

References $input, $name, ILIAS\UI\Implementation\Component\Input\InputInternal\getName(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().

+ Here is the call graph for this function:

◆ test_withRequired()

InputTest::test_withRequired ( )

Definition at line 169 of file InputTest.php.

169 : void
170 {
171 $this->assertFalse($this->input->isRequired());
172 $input = $this->input->withRequired(true);
173 $this->assertTrue($input->isRequired());
174 $input = $input->withRequired(false);
175 $this->assertFalse($input->isRequired());
176 }

References $input, ILIAS\UI\Implementation\Component\Input\Field\FormInput\isRequired(), and ILIAS\UI\Implementation\Component\Input\Field\FormInput\withRequired().

+ Here is the call graph for this function:

◆ test_withRequired_and_custom_constraint()

InputTest::test_withRequired_and_custom_constraint ( )

Definition at line 178 of file InputTest.php.

178 : void
179 {
180 $custom_constraint = $this->refinery->custom()->constraint(
181 function ($value) {
182 return (substr($value, 0, 1) === 'H') ? true : false;
183 },
184 "Your name does not start with an H"
185 );
186 $input = $this->input->withRequired(true, $custom_constraint);
187 $this->assertTrue($input->isRequired());
188 $this->assertEquals($input->requirement_constraint, $custom_constraint);
189 }

References $input, ILIAS\UI\Implementation\Component\Input\Field\FormInput\isRequired(), ILIAS\Repository\refinery(), and ILIAS\UI\Implementation\Component\Input\Field\FormInput\withRequired().

+ Here is the call graph for this function:

◆ test_withValue()

InputTest::test_withValue ( )

Definition at line 200 of file InputTest.php.

200 : void
201 {
202 $value = "some value";
203 $input = $this->input->withValue($value);
204 $this->assertEquals(null, $this->input->getValue());
205 $this->assertEquals($value, $input->getValue());
206 $this->assertNotSame($this->input, $input);
207 }
getValue()
Get the value that is displayed in the input client side.
withValue($value)
Get an input like this with another value displayed on the client side.

References $input, ILIAS\UI\Component\Input\Input\getValue(), and ILIAS\UI\Component\Input\Input\withValue().

+ Here is the call graph for this function:

◆ test_withValue_throws()

InputTest::test_withValue_throws ( )

Definition at line 209 of file InputTest.php.

209 : void
210 {
211 $this->input->value_ok = false;
212 $raised = false;
213 try {
214 $this->input->withValue("foo");
215 $this->assertFalse("This should not happen.");
216 } catch (InvalidArgumentException $e) {
217 $raised = true;
218 }
219 $this->assertTrue($raised);
220 $this->assertEquals(null, $this->input->getValue());
221 }

References Vendor\Package\$e.

Field Documentation

◆ $data_factory

DataFactory InputTest::$data_factory
protected

Definition at line 125 of file InputTest.php.

◆ $dedicated_input

DefInput InputTest::$dedicated_input
protected

Definition at line 128 of file InputTest.php.

◆ $input

◆ $name_source

DefNamesource InputTest::$name_source
protected

Definition at line 129 of file InputTest.php.

◆ $named_input

FormInput InputTest::$named_input
protected

Definition at line 130 of file InputTest.php.

◆ $refinery

Refinery InputTest::$refinery
protected

Definition at line 126 of file InputTest.php.


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