19 declare(strict_types=1);
    21 require_once(__DIR__ . 
"/../../../../../../../vendor/composer/vendor/autoload.php");
    22 require_once(__DIR__ . 
"/../../../Base.php");
    49         return function (): 
void {
    56     public int $count = 0;
    60         $name = 
"name_{$this->count}";
    77     public array $values = array();
    81         $this->values = $values;
    87     public function get(
string $name)
    89         if (!is_string(
$name)) {
    92         if (!isset($this->values[
$name])) {
    96         return $this->values[
$name];
   104         if (!is_string($name)) {
   107         if (!isset($this->values[$name])) {
   111         return $this->values[
$name];
   116         return array_key_exists(
$name, $this->values);
   135         $language = $this->createMock(
ILIAS\Language\Language::class);
   143         $this->named_input = $this->input->withDedicatedName(
'dedicated_name');
   149         $this->assertEquals(
"label", $this->input->getLabel());
   150         $this->assertEquals(
"byline", $this->input->getByline());
   155         $label = 
"new label";
   156         $input = $this->input->
withLabel($label);
   157         $this->assertEquals($label, $input->
getLabel());
   158         $this->assertNotSame($this->input, $input);
   163         $byline = 
"new byline";
   165         $this->assertEquals($byline, $input->
getByline());
   166         $this->assertNotSame($this->input, $input);
   171         $this->assertFalse($this->input->isRequired());
   173         $this->assertTrue($input->isRequired());
   174         $input = $input->withRequired(
false);
   175         $this->assertFalse($input->isRequired());
   180         $custom_constraint = $this->
refinery->custom()->constraint(
   182                 return (substr(
$value, 0, 1) === 
'H') ? 
true : 
false;
   184             "Your name does not start with an H"   186         $input = $this->input->
withRequired(
true, $custom_constraint);
   188         $this->assertEquals($input->requirement_constraint, $custom_constraint);
   193         $this->assertFalse($this->input->isDisabled());
   195         $this->assertTrue($input->isDisabled());
   196         $input = $input->withDisabled(
false);
   197         $this->assertFalse($input->isDisabled());
   204         $this->assertEquals(null, $this->input->getValue());
   206         $this->assertNotSame($this->input, $input);
   211         $this->input->value_ok = 
false;
   214             $this->input->withValue(
"foo");
   215             $this->assertFalse(
"This should not happen.");
   219         $this->assertTrue($raised);
   220         $this->assertEquals(null, $this->input->getValue());
   226         $input = $this->input->
withNameFrom($this->name_source);
   227         $this->assertEquals(null, $this->input->getName());
   229         $this->assertNotSame($this->input, $input);
   230         $this->assertEquals(1, $this->name_source->count);
   235         $name = 
"dedicated_name_0";
   236         $input = $this->named_input->
withNameFrom($this->name_source);
   237         $this->assertEquals(null, $this->named_input->getName());
   239         $this->assertNotSame($this->named_input, $input);
   240         $this->assertEquals(1, $this->name_source->count);
   247         $this->assertEquals(null, $this->input->getError());
   249         $this->assertNotSame($this->input, $input);
   254         $this->expectException(LogicException::class);
   256         $this->input->getContent();
   263         $input = $this->input->
withNameFrom($this->name_source);
   267         $res = $input2->getContent();
   269         $this->assertInstanceOf(Result::class, 
$res);
   270         $this->assertTrue(
$res->isOk());
   273         $this->assertNotSame($input, $input2);
   274         $this->assertEquals(
$value, $input2->getValue());
   282             $this->assertFalse(
"This should not happen.");
   286         $this->assertTrue($raised);
   293         $transform_to = 
"other value";
   294         $input = $this->input->
withNameFrom($this->name_source);
   298             $this->
refinery->custom()->transformation(
function ($v) use (
$value, $transform_to): 
string {
   299                 $this->assertEquals(
$value, $v);
   300                 return $transform_to;
   302         )->withInput($values);
   304         $res = $input2->getContent();
   306         $this->assertInstanceOf(Result::class, 
$res);
   307         $this->assertTrue(
$res->isOk());
   308         $this->assertEquals($transform_to, 
$res->value());
   310         $this->assertNotSame($input, $input2);
   311         $this->assertEquals(
$value, $input2->getValue());
   318         $transform_to = 
"other value";
   319         $input = $this->input->
withNameFrom($this->name_source);
   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;
   329         $res = $input2->getContent();
   331         $this->assertInstanceOf(Result::class, 
$res);
   332         $this->assertTrue(
$res->isOk());
   333         $this->assertEquals($transform_to, 
$res->value());
   335         $this->assertNotSame($input, $input2);
   336         $this->assertEquals(
$value, $input2->getValue());
   344         $input = $this->input->
withNameFrom($this->name_source);
   349         }, 
$error))->withInput($values);
   350         $res = $input2->getContent();
   352         $this->assertInstanceOf(Result::class, 
$res);
   353         $this->assertTrue(
$res->isOk());
   356         $this->assertNotSame($input, $input2);
   357         $this->assertEquals(
$value, $input2->getValue());
   358         $this->assertEquals(null, $input2->getError());
   366         $input = $this->input->
withNameFrom($this->name_source);
   371         }, 
$error))->withInput($values);
   372         $res = $input2->getContent();
   374         $this->assertInstanceOf(Result::class, 
$res);
   375         $this->assertTrue(
$res->isError());
   378         $this->assertNotSame($input, $input2);
   379         $this->assertEquals(
$value, $input2->getValue());
   380         $this->assertEquals(
$error, $input2->getError());
   390         $input = $this->input->
withNameFrom($this->name_source);
   395             ->withAdditionalTransformation($rc->constraint(
function () {
   399         $res = $input2->getContent();
   401         $this->assertInstanceOf(Result::class, 
$res);
   402         $this->assertTrue(
$res->isError());
   405         $this->assertNotSame($input, $input2);
   406         $this->assertEquals(
$value, $input2->getValue());
   407         $this->assertEquals(
$error, $input2->getError());
   414         $transform_to = 
"other value";
   416         $input = $this->input->
withNameFrom($this->name_source);
   420             $this->
refinery->custom()->transformation(
function ($v) use (
$value, $transform_to): 
string {
   421                 $this->assertEquals(
$value, $v);
   422                 return $transform_to;
   424         )->withAdditionalTransformation(
   425             $this->
refinery->custom()->constraint(
function ($v) use ($transform_to): 
bool {
   426                 $this->assertEquals($transform_to, $v);
   429         )->withInput($values);
   431         $res = $input2->getContent();
   433         $this->assertInstanceOf(Result::class, 
$res);
   434         $this->assertTrue(
$res->isOk());
   435         $this->assertEquals($transform_to, 
$res->value());
   437         $this->assertNotSame($input, $input2);
   438         $this->assertEquals(
$value, $input2->getValue());
   439         $this->assertEquals(null, $input2->getError());
   446         $transform_to = 
"other value";
   448         $input = $this->input->
withNameFrom($this->name_source);
   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;
   456         )->withAdditionalTransformation(
   457             $this->
refinery->custom()->constraint(
function ($v) use ($transform_to): 
bool {
   458                 $this->assertEquals($transform_to, $v);
   463         $res = $input2->getContent();
   465         $this->assertInstanceOf(Result::class, 
$res);
   466         $this->assertTrue(
$res->isOk());
   467         $this->assertEquals($transform_to, 
$res->value());
   469         $this->assertNotSame($input, $input2);
   470         $this->assertEquals(
$value, $input2->getValue());
   471         $this->assertEquals(null, $input2->getError());
   478         $transform_to = 
"other value";
   480         $input = $this->input->
withNameFrom($this->name_source);
   484             $this->
refinery->custom()->constraint(
function ($v) use (
$value): 
bool {
   485                 $this->assertEquals(
$value, $v);
   488         )->withAdditionalTransformation(
   489             $this->
refinery->custom()->transformation(
function ($v) use (
$value, $transform_to): 
string {
   490                 $this->assertEquals(
$value, $v);
   491                 return $transform_to;
   493         )->withInput($values);
   495         $res = $input2->getContent();
   497         $this->assertInstanceOf(Result::class, 
$res);
   498         $this->assertTrue(
$res->isOk());
   499         $this->assertEquals($transform_to, 
$res->value());
   501         $this->assertNotSame($input, $input2);
   502         $this->assertEquals(
$value, $input2->getValue());
   503         $this->assertEquals(null, $input2->getError());
   512         $transform_to = 
"other value";
   514         $input = $this->input->
withNameFrom($this->name_source);
   519                 $this->assertEquals(
$value, $v);
   523             ->withAdditionalTransformation($rc->transformation(
function () use (
$value, $transform_to): 
string {
   524                 $this->assertFalse(
"This should not happen");
   526                 return $transform_to;
   527             }))->withInput($values);
   528         $res = $input2->getContent();
   530         $this->assertInstanceOf(Result::class, 
$res);
   531         $this->assertTrue(
$res->isError());
   534         $this->assertNotSame($input, $input2);
   535         $this->assertEquals(
$value, $input2->getValue());
   536         $this->assertEquals(
$error, $input2->getError());
   543         $transform_to = 
"other value";
   545         $input = $this->input->
withNameFrom($this->name_source);
   548         $input2 = $input->
withInput($values)->withAdditionalTransformation(
   549             $this->
refinery->custom()->constraint(
function ($v) use (
$value): 
bool {
   550                 $this->assertEquals(
$value, $v);
   553         )->withAdditionalTransformation(
   554             $this->
refinery->custom()->transformation(
function () use (
$value, $transform_to): 
string {
   555                 $this->assertFalse(
"This should not happen");
   556                 return $transform_to;
   560         $res = $input2->getContent();
   562         $this->assertInstanceOf(Result::class, 
$res);
   563         $this->assertTrue(
$res->isError());
   566         $this->assertNotSame($input, $input2);
   567         $this->assertEquals(
$value, $input2->getValue());
   568         $this->assertEquals(
$error, $input2->getError());
   575         $error = 
"Your name does not start with an H";
   576         $input = $this->input->
withNameFrom($this->name_source);
   578         $custom_constraint = $this->
refinery->custom()->constraint(
   580                 return (substr(
$value, 0, 1) === 
'H') ? 
true : 
false;
   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());
   596         $input = $this->input->
withNameFrom($this->name_source);
   599         $custom_constraint = $this->
refinery->custom()->constraint(
function () {
   603         $input2 = $input->
withRequired(
true, $custom_constraint)->withRequired(
false)->withInput($values);
   604         $res = $input2->getContent();
   606         $this->assertInstanceOf(Result::class, 
$res);
   607         $this->assertFalse(
$res->isError());
 
Interface Observer  Contains several chained tasks and infos about them. 
 
A constraint encodes some resrtictions on values. 
 
getNewDedicatedName($dedicated_name='dedicated_name')
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getNewName()
Generates a unique name on every call.