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
5require_once(__DIR__ . "/../../../../../../libs/composer/vendor/autoload.php");
6require_once(__DIR__ . "/../../../../Base.php");
7require_once(__DIR__ . "/FormTest.php");
8
10use \ILIAS\Data;
11use \ILIAS\Validation;
12use \ILIAS\Transformation;
13
15{
16 protected $button_factory;
17
18
20 {
21 $this->button_factory = $button_factory;
22 }
23
24
25 public function button()
26 {
28 }
29}
30
35{
36 protected function buildFactory()
37 {
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}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:15
Provides common functionality for UI tests.
Definition: Base.php:192
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
Test on standard form implementation.
__construct($button_factory)
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79
A transformation is a function from one datatype to another.
$url
if(isset($_POST['submit'])) $form