5require_once(__DIR__ . 
"/../../../../../../libs/composer/vendor/autoload.php");
 
    6require_once(__DIR__ . 
"/../../../../Base.php");
 
    9use \ILIAS\UI\Implementation\Component\Input\Field\InputInternal;
 
   10use \ILIAS\UI\Implementation\Component\Input\NameSource;
 
   11use \ILIAS\UI\Implementation\Component\Input\PostData;
 
   12use \ILIAS\UI\Implementation\Component\Input\Container\Form\Form;
 
   15use \ILIAS\Transformation\Factory as TransformationFactory;
 
   18use \ILIAS\Transformation;
 
   38        $this->input_factory = $field_factory;
 
   39        parent::__construct($field_factory, $inputs);
 
   50        if ($this->post_data !== 
null) {
 
   54        return parent::extractPostData(
$request);
 
   60        $this->input_group = $this->input_factory->group($inputs);
 
   61        $this->inputs = $inputs;
 
   67        return $this->getPostInput(
$request);
 
   88            new Validation\
Factory($df, $this->createMock(\ilLanguage::class)),
 
  102        $f = 
new TransformationFactory();
 
  104        return $f->custom($trafo);
 
  116        return new \ILIAS\Data\Factory;
 
  132        $inputs = [$if->text(
""), $if->text(
"")];
 
  136        $inputs = 
$form->getInputs();
 
  137        $this->assertEquals(count($inputs), count($inputs));
 
  139        foreach ($inputs as 
$input) {
 
  141            $name_source->name = 
$name;
 
  144            $this->assertInternalType(
"string", 
$name);
 
  147            $input = array_shift($inputs);
 
  148            $this->assertEquals(
$input->withNameFrom($name_source), 
$input);
 
  151            $this->assertNotContains(
$name, $seen_names);
 
  152            $seen_names[] = 
$name;
 
  160        $request = \Mockery::mock(ServerRequestInterface::class);
 
  161        $request->shouldReceive(
"getParsedBody")->once()->andReturn([]);
 
  163        $this->assertInstanceOf(PostData::class, $post_data);
 
  169        $request = \Mockery::mock(ServerRequestInterface::class);
 
  170        $post_data = \Mockery::Mock(PostData::class);
 
  171        $post_data->shouldReceive(
"getOr")->once()->andReturn(
"");
 
  175        $input_1 = \Mockery::mock(InputInternal::class);
 
  176        $input_1->shouldReceive(
"withInput")->once()->with($post_data)->andReturn($input_1);
 
  178        $input_1->shouldReceive(
"getContent")->once()->andReturn($df->ok(0));
 
  180        $input_2 = \Mockery::mock(InputInternal::class);
 
  181        $input_2->shouldReceive(
"withInput")->once()->with($post_data)->andReturn($input_2);
 
  183        $input_2->shouldReceive(
"getContent")->once()->andReturn($df->ok(0));
 
  186        $form->setInputs([$input_1, $input_2]);
 
  187        $form->post_data = $post_data;
 
  191        $this->assertNotSame($form2, 
$form);
 
  192        $this->assertInstanceOf(Form::class, $form2);
 
  193        $this->assertEquals([$input_1, $input_2], $form2->getInputs());
 
  199        $request = \Mockery::mock(ServerRequestInterface::class);
 
  200        $post_data = \Mockery::Mock(PostData::class);
 
  201        $post_data->shouldReceive(
"getOr")->once()->andReturn(
"");
 
  205        $input_1 = \Mockery::mock(InputInternal::class);
 
  206        $input_1->shouldReceive(
"withInput")->once()->with($post_data)->andReturn($input_1);
 
  207        $input_1->shouldReceive(
"getContent")->once()->andReturn($df->ok(0));
 
  209        $input_2 = \Mockery::mock(InputInternal::class);
 
  210        $input_2->shouldReceive(
"withInput")->once()->with($post_data)->andReturn($input_2);
 
  211        $input_2->shouldReceive(
"getContent")->once()->andReturn($df->ok(0));
 
  214        $form->setInputs([
"foo" => $input_1, 
"bar" => $input_2]);
 
  215        $form->post_data = $post_data;
 
  219        $this->assertNotSame($form2, 
$form);
 
  220        $this->assertInstanceOf(Form::class, $form2);
 
  221        $this->assertEquals([
"foo" => $input_1, 
"bar" => $input_2], $form2->getInputs());
 
  228        $request = \Mockery::mock(ServerRequestInterface::class);
 
  229        $request->shouldReceive(
"getParsedBody")->once()->andReturn([]);
 
  231        $input_1 = \Mockery::mock(InputInternal::class);
 
  232        $input_1->shouldReceive(
"getContent")->once()->andReturn($df->ok(1));
 
  234        $input_1->shouldReceive(
"withInput")->once()->andReturn($input_1);
 
  236        $input_2 = \Mockery::mock(InputInternal::class);
 
  237        $input_2->shouldReceive(
"getContent")->once()->andReturn($df->ok(2));
 
  239        $input_2->shouldReceive(
"withInput")->once()->andReturn($input_2);
 
  242        $form->setInputs([$input_1, $input_2]);
 
  244        $this->assertEquals([1, 2], 
$form->getData());
 
  251        $request = \Mockery::mock(ServerRequestInterface::class);
 
  252        $request->shouldReceive(
"getParsedBody")->once()->andReturn([]);
 
  254        $input_1 = \Mockery::mock(InputInternal::class);
 
  255        $input_1->shouldReceive(
"getContent")->once()->andReturn($df->ok(1));
 
  257        $input_1->shouldReceive(
"withInput")->once()->andReturn($input_1);
 
  259        $input_2 = \Mockery::mock(InputInternal::class);
 
  260        $input_2->shouldReceive(
"getContent")->once()->andReturn($df->ok(2));
 
  262        $input_2->shouldReceive(
"withInput")->once()->andReturn($input_2);
 
  265        $form->setInputs([
"foo" => $input_1, 
"bar" => $input_2]);
 
  267        $this->assertEquals([
"foo" => 1, 
"bar" => 2], 
$form->getData());
 
  274        $request = \Mockery::mock(ServerRequestInterface::class);
 
  275        $request->shouldReceive(
"getParsedBody")->once()->andReturn([]);
 
  277        $input_1 = \Mockery::mock(InputInternal::class);
 
  278        $input_1->shouldReceive(
"getContent")->once()->andReturn($df->error(
"error"));
 
  280        $input_1->shouldReceive(
"withInput")->once()->andReturn($input_1);
 
  282        $input_2 = \Mockery::mock(InputInternal::class);
 
  283        $input_2->shouldReceive(
"getContent")->once()->andReturn($df->ok(2));
 
  285        $input_2->shouldReceive(
"withInput")->once()->andReturn($input_2);
 
  288        $form->setInputs([
"foo" => $input_1, 
"bar" => $input_2]);
 
  292        $this->assertEquals(
null, 
null);
 
  299        $request = \Mockery::mock(ServerRequestInterface::class);
 
  300        $request->shouldReceive(
"getParsedBody")->once()->andReturn([]);
 
  302        $input_1 = \Mockery::mock(InputInternal::class);
 
  303        $input_1->shouldReceive(
"getContent")->once()->andReturn($df->ok(1));
 
  305        $input_1->shouldReceive(
"withInput")->once()->andReturn($input_1);
 
  307        $input_2 = \Mockery::mock(InputInternal::class);
 
  308        $input_2->shouldReceive(
"getContent")->once()->andReturn($df->ok(2));
 
  310        $input_2->shouldReceive(
"withInput")->once()->andReturn($input_2);
 
  313        $form->setInputs([$input_1, $input_2]);
 
  316            return "transformed";
 
  319        $this->assertNotSame($form2, 
$form);
 
  320        $form2 = $form2->withRequest(
$request);
 
  322        $this->assertEquals(
"transformed", $form2->getData());
 
  331            "foo" => $if->text(
""),
 
  336        $form->setInputs($inputs);
 
  337        $named_inputs = 
$form->getInputs();
 
  338        $this->assertEquals(array_keys($inputs), array_keys($named_inputs));
 
foreach($paths as $path) $request
An exception for terminatinating execution or to throw for unit testing.
getNewName()
Generates a unique name on every call.
Provides common functionality for UI tests.
Representation of an incoming, server-side HTTP request.
if(isset($_POST['submit'])) $form