ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
StandardFormTest.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2016 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 require_once(__DIR__ . "/../../../../../../libs/composer/vendor/autoload.php");
6 require_once(__DIR__ . "/../../../../Base.php");
7 require_once(__DIR__ . "/FormTest.php");
8 
10 use \ILIAS\Data;
11 use \ILIAS\Validation;
12 use \ILIAS\Transformation;
13 
15 {
16  protected $button_factory;
17 
18 
19  public function __construct($button_factory)
20  {
21  $this->button_factory = $button_factory;
22  }
23 
24 
25  public function button()
26  {
27  return $this->button_factory;
28  }
29 }
30 
35 {
36  protected function buildFactory()
37  {
38  return new ILIAS\UI\Implementation\Component\Input\Container\Form\Factory($this->buildInputFactory());
39  }
40 
41 
42  protected function buildInputFactory()
43  {
44  $df = new Data\Factory();
46  new SignalGenerator(),
47  $df,
48  new Validation\Factory($df, $this->createMock(\ilLanguage::class)),
50  );
51  }
52 
53  protected function buildButtonFactory()
54  {
56  }
57 
58 
59  public function getUIFactory()
60  {
61  return new WithButtonNoUIFactory($this->buildButtonFactory());
62  }
63 
64 
65  public function test_getPostURL()
66  {
67  $f = $this->buildFactory();
68  $if = $this->buildInputFactory();
69  $url = "MY_URL";
70  $form = $f->standard($url, [$if->text("label")]);
71  $this->assertEquals($url, $form->getPostURL());
72  }
73 
74 
75  public function test_render()
76  {
77  $f = $this->buildFactory();
78  $if = $this->buildInputFactory();
79 
80  $url = "MY_URL";
81  $form = $f->standard($url, [
82  $if->text("label", "byline"),
83  ]);
84 
85  $r = $this->getDefaultRenderer();
86  $html = $r->render($form);
87 
88  $expected = "<form role=\"form\" class=\"il-standard-form form-horizontal\" enctype=\"multipart/formdata\" action=\"MY_URL\" method=\"post\" novalidate=\"novalidate\"> <div class=\"il-standard-form-header clearfix\"> <div class=\"il-standard-form-cmd\"><button class=\"btn btn-default\" data-action=\"#\" id=\"id_1\">save</button></div> </div> <div class=\"form-group row\"> <label for=\"form_input_1\" class=\"control-label col-sm-3\">label</label> <div class=\"col-sm-9\"> <input type=\"text\" name=\"form_input_1\" class=\"form-control form-control-sm\" /> <div class=\"help-block\">byline</div> </div></div> <div class=\"il-standard-form-footer clearfix\"> <div class=\"il-standard-form-cmd\"><button class=\"btn btn-default\" data-action=\"#\" id=\"id_2\">save</button></div> </div></form>";
89  $this->assertHTMLEquals($expected, $html);
90  }
91 }
A transformation is a function from one datatype to another.
button()
description: purpose: > Buttons trigger interactions that change the system’s or view&#39;s status...
__construct($button_factory)
$r
Definition: example_031.php:79
if(isset($_POST['submit'])) $form
Provides common functionality for UI tests.
Definition: Base.php:191
Builds data types.
Definition: Factory.php:14
Test on standard form implementation.
$url
$html
Definition: example_001.php:87