ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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_stripsTags ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Member Functions

 buildFactory ()
 

Private Attributes

 $name_source
 

Detailed Description

Definition at line 15 of file TextareaTest.php.

Member Function Documentation

◆ buildFactory()

TextareaTest::buildFactory ( )
protected

◆ setUp()

TextareaTest::setUp ( )

Definition at line 23 of file TextareaTest.php.

24  {
25  $this->name_source = new DefNamesource();
26  }

◆ test_get_max_limit()

TextareaTest::test_get_max_limit ( )

Definition at line 112 of file TextareaTest.php.

References $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 $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 $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 $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 $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 $f, $html, $name, $r, 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\" id=\"\"></textarea>"
135  . "<div id=\"textarea_feedback_\" data-maxchars=\"\"></div>"
136  . "<div class=\"help-block\">byline</div>"
137  . "</div>"
138  . "</div>";
139 
140  $html = $this->normalizeHTML($r->render($textarea));
141  $this->assertHTMLEquals($expected, $html);
142  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_renderer_counter_with_value()

TextareaTest::test_renderer_counter_with_value ( )

Definition at line 218 of file TextareaTest.php.

References $f, $html, $name, $r, ILIAS_UI_TestBase\assertHTMLEquals(), buildFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

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

◆ test_renderer_with_error()

TextareaTest::test_renderer_with_error ( )

Definition at line 241 of file TextareaTest.php.

References $f, $html, $name, $r, buildFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

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

◆ test_renderer_with_max_limit()

TextareaTest::test_renderer_with_max_limit ( )

Definition at line 169 of file TextareaTest.php.

References $f, $html, $id, $name, $r, ILIAS_UI_TestBase\assertHTMLEquals(), buildFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

170  {
171  $f = $this->buildFactory();
172  $r = $this->getDefaultRenderer();
173  $name = "name_0";
174  $id = "id_1";
175  $label = "label";
176  $max = 20;
177  $byline = "This is just a byline Max: " . $max;
178  $textarea = $f->textarea($label, $byline)->withMaxLimit($max)->withNameFrom($this->name_source);
179 
180  $expected = "<div class=\"form-group row\">"
181  . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
182  . "<div class=\"col-sm-9\">"
183  . "<textarea name=\"$name\" class=\"form-control form-control-sm\" id=\"$id\"></textarea>"
184  . "<div id=\"textarea_feedback_$id\" data-maxchars=\"$max\"></div>"
185  . "<div class=\"help-block\">$byline</div>"
186  . "</div>"
187  . "</div>";
188 
189  $html = $this->normalizeHTML($r->render($textarea));
190  $this->assertHTMLEquals($expected, $html);
191  }
if(!array_key_exists('StateId', $_REQUEST)) $id
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$html
Definition: example_001.php:87
+ 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 193 of file TextareaTest.php.

References $f, $html, $id, $name, $r, ILIAS_UI_TestBase\assertHTMLEquals(), buildFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

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

◆ test_renderer_with_min_limit()

TextareaTest::test_renderer_with_min_limit ( )

Definition at line 144 of file TextareaTest.php.

References $f, $html, $id, $name, $r, ILIAS_UI_TestBase\assertHTMLEquals(), buildFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

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

◆ test_stripsTags()

TextareaTest::test_stripsTags ( )

Definition at line 268 of file TextareaTest.php.

References $f, $name, $text, and buildFactory().

269  {
270  $f = $this->buildFactory();
271  $name = "name_0";
272  $text = $f->textarea("")
273  ->withNameFrom($this->name_source)
274  ->withInput(new DefPostData([$name => "<script>alert()</script>"]));
275 
276  $content = $text->getContent();
277  $this->assertEquals("alert()", $content->value());
278  }
$text
Definition: errorreport.php:18
+ 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 $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 $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 21 of file TextareaTest.php.


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