ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
TextInputTest Class Reference
+ Inheritance diagram for TextInputTest:
+ Collaboration diagram for TextInputTest:

Public Member Functions

 setUp ()
 
 test_implements_factory_interface ()
 
 test_render ()
 
 test_render_error ()
 
 test_render_no_byline ()
 
 test_render_value ()
 
 test_render_value_0 ()
 
 test_render_required ()
 
 test_render_disabled ()
 
 test_value_required ()
 
 test_stripsTags ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Member Functions

 buildFactory ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Definition at line 14 of file TextInputTest.php.

Member Function Documentation

◆ buildFactory()

TextInputTest::buildFactory ( )
protected

Definition at line 22 of file TextInputTest.php.

Referenced by test_implements_factory_interface(), test_render(), test_render_disabled(), test_render_error(), test_render_no_byline(), test_render_required(), test_render_value(), test_render_value_0(), test_stripsTags(), and test_value_required().

23  {
24  $df = new Data\Factory();
25  $language = $this->createMock(\ilLanguage::class);
27  new SignalGenerator(),
28  $df,
29  new ILIAS\Refinery\Factory($df, $language),
30  $language
31  );
32  }
Class ChatMainBarProvider .
Builds data types.
Definition: Factory.php:19
+ Here is the caller graph for this function:

◆ setUp()

TextInputTest::setUp ( )

Definition at line 16 of file TextInputTest.php.

16  : void
17  {
18  $this->name_source = new DefNamesource();
19  }

◆ test_implements_factory_interface()

TextInputTest::test_implements_factory_interface ( )

Definition at line 35 of file TextInputTest.php.

References Vendor\Package\$f, and buildFactory().

36  {
37  $f = $this->buildFactory();
38 
39  $text = $f->text("label", "byline");
40 
41  $this->assertInstanceOf(Field\Input::class, $text);
42  $this->assertInstanceOf(Field\Text::class, $text);
43  }
+ Here is the call graph for this function:

◆ test_render()

TextInputTest::test_render ( )

Definition at line 46 of file TextInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

47  {
48  $f = $this->buildFactory();
49  $label = "label";
50  $byline = "byline";
51  $name = "name_0";
52  $text = $f->text($label, $byline)->withNameFrom($this->name_source);
53 
54  $r = $this->getDefaultRenderer();
55  $html = $this->brutallyTrimHTML($r->render($text));
56 
57  $expected = $this->brutallyTrimHTML('
58 <div class="form-group row">
59  <label for="id_1" class="control-label col-sm-3">label</label>
60  <div class="col-sm-9">
61  <input id="id_1" type="text" name="name_0" class="form-control form-control-sm" />
62  <div class="help-block">byline</div>
63  </div>
64 </div>
65 ');
66  $this->assertEquals($expected, $html);
67  }
if($format !==null) $name
Definition: metadata.php:230
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_disabled()

TextInputTest::test_render_disabled ( )

Definition at line 174 of file TextInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

175  {
176  $f = $this->buildFactory();
177  $label = "label";
178  $name = "name_0";
179  $text = $f->text($label)->withNameFrom($this->name_source)->withDisabled(true);
180 
181  $r = $this->getDefaultRenderer();
182  $html = $this->brutallyTrimHTML($r->render($text));
183 
184  $expected = $this->brutallyTrimHTML('
185 <div class="form-group row">
186  <label for="id_1" class="control-label col-sm-3">label</label>
187  <div class="col-sm-9"><input id="id_1" type="text" name="name_0" disabled="disabled" class="form-control form-control-sm" /></div>
188 </div>
189 ');
190  $this->assertEquals($expected, $html);
191  }
if($format !==null) $name
Definition: metadata.php:230
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_error()

TextInputTest::test_render_error ( )

Definition at line 70 of file TextInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

71  {
72  $f = $this->buildFactory();
73  $label = "label";
74  $byline = "byline";
75  $name = "name_0";
76  $error = "an_error";
77  $text = $f->text($label, $byline)->withNameFrom($this->name_source)->withError($error);
78 
79  $r = $this->getDefaultRenderer();
80  $html = $this->brutallyTrimHTML($r->render($text));
81 
82  $expected = $this->brutallyTrimHTML('
83 <div class="form-group row">
84  <label for="id_1" class="control-label col-sm-3">label</label>
85  <div class="col-sm-9">
86  <div class="help-block alert alert-danger" role="alert">an_error</div>
87  <input id="id_1" type="text" name="name_0" class="form-control form-control-sm" />
88  <div class="help-block">byline</div>
89  </div>
90 </div>
91 ');
92  $this->assertEquals($expected, $html);
93  }
if($format !==null) $name
Definition: metadata.php:230
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_no_byline()

TextInputTest::test_render_no_byline ( )

Definition at line 96 of file TextInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

97  {
98  $f = $this->buildFactory();
99  $label = "label";
100  $name = "name_0";
101  $text = $f->text($label)->withNameFrom($this->name_source);
102 
103  $r = $this->getDefaultRenderer();
104  $html = $this->brutallyTrimHTML($r->render($text));
105 
106  $expected = $this->brutallyTrimHTML('
107 <div class="form-group row">
108  <label for="id_1" class="control-label col-sm-3">label</label>
109  <div class="col-sm-9"><input id="id_1" type="text" name="name_0" class="form-control form-control-sm" /></div>
110 </div>
111 ');
112  $this->assertEquals($expected, $html);
113  }
if($format !==null) $name
Definition: metadata.php:230
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_required()

TextInputTest::test_render_required ( )

Definition at line 155 of file TextInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

155  : void
156  {
157  $f = $this->buildFactory();
158  $label = "label";
159  $name = "name_0";
160  $text = $f->text($label)->withNameFrom($this->name_source)->withRequired(true);
161 
162  $r = $this->getDefaultRenderer();
163  $html = $this->brutallyTrimHTML($r->render($text));
164 
165  $expected = $this->brutallyTrimHTML('
166 <div class="form-group row">
167  <label for="id_1" class="control-label col-sm-3">label<span class="asterisk">*</span></label>
168  <div class="col-sm-9"><input id="id_1" type="text" name="name_0" class="form-control form-control-sm" /></div>
169 </div>
170 ');
171  $this->assertEquals($expected, $html);
172  }
if($format !==null) $name
Definition: metadata.php:230
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_value()

TextInputTest::test_render_value ( )

Definition at line 116 of file TextInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

117  {
118  $f = $this->buildFactory();
119  $label = "label";
120  $value = "value";
121  $name = "name_0";
122  $text = $f->text($label)->withValue($value)->withNameFrom($this->name_source);
123 
124  $r = $this->getDefaultRenderer();
125  $html = $this->brutallyTrimHTML($r->render($text));
126 
127  $expected = $this->brutallyTrimHTML('
128 <div class="form-group row">
129  <label for="id_1" class="control-label col-sm-3">label</label>
130  <div class="col-sm-9"><input id="id_1" type="text" value="value" name="name_0" class="form-control form-control-sm" /></div>
131 </div>
132 ');
133  $this->assertEquals($expected, $html);
134  }
if($format !==null) $name
Definition: metadata.php:230
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_value_0()

TextInputTest::test_render_value_0 ( )

Definition at line 136 of file TextInputTest.php.

References Vendor\Package\$f, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

136  : void
137  {
138  $f = $this->buildFactory();
139  $label = "label";
140  $value = "0";
141  $text = $f->text($label)->withValue($value)->withNameFrom($this->name_source);
142 
143  $r = $this->getDefaultRenderer();
144  $html = $this->brutallyTrimHTML($r->render($text));
145 
146  $expected = $this->brutallyTrimHTML('
147 <div class="form-group row">
148  <label for="id_1" class="control-label col-sm-3">label</label>
149  <div class="col-sm-9"><input id="id_1" type="text" value="0" name="name_0" class="form-control form-control-sm" /></div>
150 </div>
151 ');
152  $this->assertEquals($expected, $html);
153  }
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_stripsTags()

TextInputTest::test_stripsTags ( )

Definition at line 211 of file TextInputTest.php.

References Vendor\Package\$f, $name, and buildFactory().

212  {
213  $f = $this->buildFactory();
214  $name = "name_0";
215  $text = $f->text("")
216  ->withNameFrom($this->name_source)
217  ->withInput(new DefInputData([$name => "<script>alert()</script>"]));
218 
219  $content = $text->getContent();
220  $this->assertEquals("alert()", $content->value());
221  }
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ test_value_required()

TextInputTest::test_value_required ( )

Definition at line 194 of file TextInputTest.php.

References Vendor\Package\$f, $name, and buildFactory().

195  {
196  $f = $this->buildFactory();
197  $label = "label";
198  $name = "name_0";
199  $text = $f->text($label)->withNameFrom($this->name_source)->withRequired(true);
200 
201  $text1 = $text->withInput(new DefInputData([$name => "0"]));
202  $value1 = $text1->getContent();
203  $this->assertTrue($value1->isOk());
204  $this->assertEquals("0", $value1->value());
205 
206  $text2 = $text->withInput(new DefInputData([$name => ""]));
207  $value2 = $text2->getContent();
208  $this->assertTrue($value2->isError());
209  }
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: