ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
TextareaTest Class Reference
+ Inheritance diagram for TextareaTest:
+ Collaboration diagram for TextareaTest:

Public Member Functions

 setUp ()
 
 test_implements_factory_interface ()
 
 test_implements_factory_interface_without_byline ()
 
 test_with_min_limit ()
 
 test_with_max_limit ()
 
 test_is_limited ()
 
 test_get_min_limit ()
 
 test_get_max_limit ()
 
 test_renderer ()
 
 test_renderer_with_min_limit ()
 
 test_renderer_with_max_limit ()
 
 test_renderer_with_min_and_max_limit ()
 
 test_renderer_counter_with_value ()
 
 test_renderer_with_error ()
 
 test_renderer_with_disabled ()
 
 test_stripsTags ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 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...
 

Private Attributes

 $name_source
 

Detailed Description

Definition at line 14 of file TextareaTest.php.

Member Function Documentation

◆ buildFactory()

TextareaTest::buildFactory ( )
protected

◆ setUp()

TextareaTest::setUp ( )

Definition at line 22 of file TextareaTest.php.

22  : void
23  {
24  $this->name_source = new DefNamesource();
25  }

◆ test_get_max_limit()

TextareaTest::test_get_max_limit ( )

Definition at line 112 of file TextareaTest.php.

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

113  {
114  $f = $this->buildFactory();
115  $limit = 15;
116  $textarea = $f->textarea('label')->withMaxLimit($limit);
117  $this->assertEquals($textarea->getMaxLimit(), $limit);
118  }
+ Here is the call graph for this function:

◆ test_get_min_limit()

TextareaTest::test_get_min_limit ( )

Definition at line 103 of file TextareaTest.php.

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

104  {
105  $f = $this->buildFactory();
106  $limit = 5;
107  $textarea = $f->textarea('label')->withMinLimit($limit);
108  $this->assertEquals($textarea->getMinLimit(), $limit);
109  }
+ Here is the call graph for this function:

◆ test_implements_factory_interface()

TextareaTest::test_implements_factory_interface ( )

Definition at line 41 of file TextareaTest.php.

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

42  {
43  $f = $this->buildFactory();
44  $textarea = $f->textarea("label", "byline");
45  $this->assertInstanceOf(Field\Input::class, $textarea);
46  $this->assertInstanceOf(Field\Textarea::class, $textarea);
47  }
+ Here is the call graph for this function:

◆ test_implements_factory_interface_without_byline()

TextareaTest::test_implements_factory_interface_without_byline ( )

Definition at line 50 of file TextareaTest.php.

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

51  {
52  $f = $this->buildFactory();
53  $textarea = $f->textarea("label");
54  $this->assertInstanceOf(Field\Input::class, $textarea);
55  $this->assertInstanceOf(Field\Textarea::class, $textarea);
56  }
+ Here is the call graph for this function:

◆ test_is_limited()

TextareaTest::test_is_limited ( )

Definition at line 81 of file TextareaTest.php.

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

82  {
83  $f = $this->buildFactory();
84 
85  // with min limit
86  $textarea = $f->textarea('label')->withMinLimit(5);
87  $this->assertTrue($textarea->isLimited());
88 
89  // with max limit
90  $textarea = $f->textarea('label')->withMaxLimit(5);
91  $this->assertTrue($textarea->isLimited());
92 
93  // with min-max limit
94  $textarea = $f->textarea('label')->withMinLimit(5)->withMaxLimit(20);
95  $this->assertTrue($textarea->isLimited());
96 
97  // without limit
98  $textarea = $f->textarea('label');
99  $this->assertFalse($textarea->isLimited());
100  }
+ Here is the call graph for this function:

◆ test_renderer()

TextareaTest::test_renderer ( )

Definition at line 122 of file TextareaTest.php.

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

123  {
124  $f = $this->buildFactory();
125  $r = $this->getDefaultRenderer();
126  $label = "label";
127  $byline = "byline";
128  $name = "name_0";
129  $textarea = $f->textarea($label, $byline)->withNameFrom($this->name_source);
130 
131  $expected = "<div class=\"form-group row\">"
132  . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
133  . "<div class=\"col-sm-9\">"
134  . "<textarea name=\"$name\" class=\"form-control form-control-sm\"></textarea>"
135  . "<div class=\"help-block\">byline</div>"
136  . "</div>"
137  . "</div>";
138 
139  $html = $this->normalizeHTML($r->render($textarea));
140  $this->assertHTMLEquals($expected, $html);
141  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_renderer_counter_with_value()

TextareaTest::test_renderer_counter_with_value ( )

Definition at line 217 of file TextareaTest.php.

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

218  {
219  $f = $this->buildFactory();
220  $r = $this->getDefaultRenderer();
221  $label = "label";
222  $byline = "byline";
223  $name = "name_0";
224  $value = "Lorem ipsum dolor sit";
225  $textarea = $f->textarea($label, $byline)->withValue($value)->withNameFrom($this->name_source);
226 
227  $expected = "<div class=\"form-group row\">"
228  . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
229  . "<div class=\"col-sm-9\">"
230  . "<textarea name=\"$name\" class=\"form-control form-control-sm\">$value</textarea>"
231  . "<div class=\"help-block\">byline</div>"
232  . "</div>"
233  . "</div>";
234 
235  $html = $this->normalizeHTML($r->render($textarea));
236  $this->assertHTMLEquals($expected, $html);
237  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_renderer_with_disabled()

TextareaTest::test_renderer_with_disabled ( )

Definition at line 265 of file TextareaTest.php.

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

266  {
267  $f = $this->buildFactory();
268  $r = $this->getDefaultRenderer();
269  $label = "label";
270  $byline = "byline";
271  $name = "name_0";
272  $textarea = $f->textarea($label, $byline)->withNameFrom($this->name_source)->withDisabled(true);
273 
274  $expected = "<div class=\"form-group row\">"
275  . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
276  . "<div class=\"col-sm-9\">"
277  . "<textarea name=\"$name\" disabled=\"disabled\" class=\"form-control form-control-sm\"></textarea>"
278  . "<div class=\"help-block\">byline</div>"
279  . "</div>"
280  . "</div>";
281 
282  $html = $this->normalizeHTML($r->render($textarea));
283  $this->assertHTMLEquals($expected, $html);
284  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_renderer_with_error()

TextareaTest::test_renderer_with_error ( )

Definition at line 239 of file TextareaTest.php.

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

240  {
241  $f = $this->buildFactory();
242  $r = $this->getDefaultRenderer();
243  $name = "name_0";
244  $label = "label";
245  $min = 5;
246  $byline = "This is just a byline Min: " . $min;
247  $error = "an_error";
248  $textarea = $f->textarea($label, $byline)->withNameFrom($this->name_source)->withError($error);
249 
250  $expected = "<div class=\"form-group row\">"
251  . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
252  . "<div class=\"col-sm-9\">"
253  . "<textarea name=\"$name\" class=\"form-control form-control-sm\"></textarea>"
254  . "<div class=\"help-block\">$byline</div>"
255  . "<div class=\"help-block alert alert-danger\" role=\"alert\">"
256  . "<img border=\"0\" src=\"./templates/default/images/icon_alert.svg\" alt=\"alert\" />"
257  . "$error</div></div></div>";
258 
259  $html = $this->normalizeHTML($r->render($textarea));
260  $html = trim(preg_replace('/\t+/', '', $html));
261  $expected = trim(preg_replace('/\t+/', '', $expected));
262  $this->assertEquals($expected, $html);
263  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ test_renderer_with_max_limit()

TextareaTest::test_renderer_with_max_limit ( )

Definition at line 168 of file TextareaTest.php.

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

169  {
170  $f = $this->buildFactory();
171  $r = $this->getDefaultRenderer();
172  $name = "name_0";
173  $id = "id_1";
174  $label = "label";
175  $max = 20;
176  $byline = "This is just a byline Max: " . $max;
177  $textarea = $f->textarea($label, $byline)->withMaxLimit($max)->withNameFrom($this->name_source);
178 
179  $expected = "<div class=\"form-group row\">"
180  . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
181  . "<div class=\"col-sm-9\">"
182  . "<textarea name=\"$name\" class=\"form-control form-control-sm\" id=\"$id\"></textarea>"
183  . "<div id=\"textarea_feedback_$id\" data-maxchars=\"$max\"></div>"
184  . "<div class=\"help-block\">$byline</div>"
185  . "</div>"
186  . "</div>";
187 
188  $html = $this->normalizeHTML($r->render($textarea));
189  $this->assertHTMLEquals($expected, $html);
190  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_renderer_with_min_and_max_limit()

TextareaTest::test_renderer_with_min_and_max_limit ( )

Definition at line 192 of file TextareaTest.php.

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

193  {
194  $f = $this->buildFactory();
195  $r = $this->getDefaultRenderer();
196  $name = "name_0";
197  $id = "id_1";
198  $label = "label";
199  $min = 5;
200  $max = 20;
201  $byline = "This is just a byline Min: " . $min . " Max: " . $max;
202  $textarea = $f->textarea($label, $byline)->withMinLimit($min)->withMaxLimit($max)->withNameFrom($this->name_source);
203 
204  $expected = "<div class=\"form-group row\">"
205  . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
206  . "<div class=\"col-sm-9\">"
207  . "<textarea name=\"$name\" class=\"form-control form-control-sm\" id=\"$id\"></textarea>"
208  . "<div id=\"textarea_feedback_$id\" data-maxchars=\"$max\"></div>"
209  . "<div class=\"help-block\">$byline</div>"
210  . "</div>"
211  . "</div>";
212 
213  $html = $this->normalizeHTML($r->render($textarea));
214  $this->assertHTMLEquals($expected, $html);
215  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_renderer_with_min_limit()

TextareaTest::test_renderer_with_min_limit ( )

Definition at line 143 of file TextareaTest.php.

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

144  {
145  $f = $this->buildFactory();
146  $r = $this->getDefaultRenderer();
147  $name = "name_0";
148  $id = "id_1";
149  $label = "label";
150 
151  $min = 5;
152  $byline = "This is just a byline Min: " . $min;
153  $textarea = $f->textarea($label, $byline)->withMinLimit($min)->withNameFrom($this->name_source);
154 
155  $expected = "<div class=\"form-group row\">"
156  . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
157  . "<div class=\"col-sm-9\">"
158  . "<textarea name=\"$name\" class=\"form-control form-control-sm\" id=\"$id\"></textarea>"
159  . "<div id=\"textarea_feedback_$id\" data-maxchars=\"\"></div>"
160  . "<div class=\"help-block\">$byline</div>"
161  . "</div>"
162  . "</div>";
163 
164  $html = $this->normalizeHTML($r->render($textarea));
165  $this->assertHTMLEquals($expected, $html);
166  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_stripsTags()

TextareaTest::test_stripsTags ( )

Definition at line 286 of file TextareaTest.php.

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

287  {
288  $f = $this->buildFactory();
289  $name = "name_0";
290  $text = $f->textarea("")
291  ->withNameFrom($this->name_source)
292  ->withInput(new DefInputData([$name => "<script>alert()</script>"]));
293 
294  $content = $text->getContent();
295  $this->assertEquals("alert()", $content->value());
296  }
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ test_with_max_limit()

TextareaTest::test_with_max_limit ( )

Definition at line 70 of file TextareaTest.php.

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

71  {
72  $f = $this->buildFactory();
73  $limit = 15;
74  $textarea = $f->textarea('label')->withMaxLimit($limit);
75  $this->assertInstanceOf(Field\Input::class, $textarea);
76  $this->assertInstanceOf(Field\Textarea::class, $textarea);
77  $this->assertEquals($textarea->getMaxLimit(), $limit);
78  }
+ Here is the call graph for this function:

◆ test_with_min_limit()

TextareaTest::test_with_min_limit ( )

Definition at line 59 of file TextareaTest.php.

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

60  {
61  $f = $this->buildFactory();
62  $limit = 5;
63  $textarea = $f->textarea('label')->withMinLimit($limit);
64  $this->assertInstanceOf(Field\Input::class, $textarea);
65  $this->assertInstanceOf(Field\Textarea::class, $textarea);
66  $this->assertEquals($textarea->getMinLimit(), $limit);
67  }
+ Here is the call graph for this function:

Field Documentation

◆ $name_source

TextareaTest::$name_source
private

Definition at line 20 of file TextareaTest.php.


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