ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
13 {
14  protected $button_factory;
15 
16 
17  public function __construct($button_factory)
18  {
19  $this->button_factory = $button_factory;
20  }
21 
22 
23  public function button()
24  {
25  return $this->button_factory;
26  }
27 }
28 
33 {
34  protected function buildFactory()
35  {
36  return new ILIAS\UI\Implementation\Component\Input\Container\Form\Factory($this->buildInputFactory());
37  }
38 
39 
40  protected function buildInputFactory()
41  {
42  $df = new Data\Factory();
43  $language = $this->createMock(\ilLanguage::class);
45  new SignalGenerator(),
46  $df,
47  new \ILIAS\Refinery\Factory($df, $language),
48  $language
49  );
50  }
51 
52  protected function buildButtonFactory()
53  {
55  }
56 
57 
58  public function getUIFactory()
59  {
60  return new WithButtonNoUIFactory($this->buildButtonFactory());
61  }
62 
63 
64  public function test_getPostURL()
65  {
66  $f = $this->buildFactory();
67  $if = $this->buildInputFactory();
68  $url = "MY_URL";
69  $form = $f->standard($url, [$if->text("label")]);
70  $this->assertEquals($url, $form->getPostURL());
71  }
72 
73 
74  public function test_render()
75  {
76  $f = $this->buildFactory();
77  $if = $this->buildInputFactory();
78 
79  $url = "MY_URL";
80  $form = $f->standard($url, [
81  $if->text("label", "byline"),
82  ]);
83 
84  $r = $this->getDefaultRenderer();
85  $html = $r->render($form);
86 
87  $expected = "<form role=\"form\" class=\"il-standard-form form-horizontal\" enctype=\"multipart/form-data\" 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=\"\">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=\"\">save</button></div> </div></form>";
88  $this->assertHTMLEquals($expected, $html);
89  }
90 
91  public function test_render_no_url()
92  {
93  $f = $this->buildFactory();
94  $if = $this->buildInputFactory();
95 
96  $url = "";
97  $form = $f->standard($url, [
98  $if->text("label", "byline"),
99  ]);
100 
101  $r = $this->getDefaultRenderer();
102  $html = $r->render($form);
103 
104  $expected = "<form role=\"form\" class=\"il-standard-form form-horizontal\" enctype=\"multipart/form-data\" method=\"post\" novalidate=\"novalidate\"> <div class=\"il-standard-form-header clearfix\"> <div class=\"il-standard-form-cmd\"><button class=\"btn btn-default\" data-action=\"\">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=\"\">save</button></div> </div></form>";
105  $this->assertHTMLEquals($expected, $html);
106  }
107 }
Class ChatMainBarProvider .
button()
description: purpose: > Buttons trigger interactions that change the system’s or view&#39;s status...
__construct($button_factory)
Provides common functionality for UI tests.
Definition: Base.php:224
Builds data types.
Definition: Factory.php:19
Test on standard form implementation.
$url