ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
TextareaTest Class Reference
+ Inheritance diagram for TextareaTest:
+ Collaboration diagram for TextareaTest:

Public Member Functions

 setUp ()
 
 testImplementsFactoryInterface ()
 
 testImplementsFactoryInterface_without_byline ()
 
 testWithMinLimit ()
 
 testWithMaxLimit ()
 
 testIsLimited ()
 
 testGetMinLimit ()
 
 testGetMaxLimit ()
 
 testRenderer ()
 
 testRendererWithMinLimit ()
 
 testRendererWithMaxLimit ()
 
 testRendererWithMinAndMaxLimit ()
 
 testRendererCounterWithValue ()
 
 testRendererWithError ()
 
 testRendererWithDisabled ()
 
 testStripsTags ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getHelpTextRetriever ()
 
 getUploadLimitResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 buildFactory ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Private Attributes

DefNamesource $name_source
 

Detailed Description

Definition at line 31 of file TextareaTest.php.

Member Function Documentation

◆ buildFactory()

TextareaTest::buildFactory ( )
protected

Definition at line 40 of file TextareaTest.php.

Referenced by testGetMaxLimit(), testGetMinLimit(), testImplementsFactoryInterface(), testImplementsFactoryInterface_without_byline(), testIsLimited(), testRenderer(), testRendererCounterWithValue(), testRendererWithDisabled(), testRendererWithError(), testRendererWithMaxLimit(), testRendererWithMinAndMaxLimit(), testRendererWithMinLimit(), testStripsTags(), testWithMaxLimit(), and testWithMinLimit().

40  : I\Input\Field\Factory
41  {
42  $df = new Data\Factory();
43  $language = $this->createMock(ilLanguage::class);
44  return new I\Input\Field\Factory(
45  $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
46  new SignalGenerator(),
47  $df,
48  new Refinery($df, $language),
49  $language
50  );
51  }
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ setUp()

TextareaTest::setUp ( )

Definition at line 35 of file TextareaTest.php.

35  : void
36  {
37  $this->name_source = new DefNamesource();
38  }

◆ testGetMaxLimit()

TextareaTest::testGetMaxLimit ( )

Definition at line 118 of file TextareaTest.php.

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

118  : void
119  {
120  $f = $this->buildFactory();
121  $limit = 15;
122  $textarea = $f->textarea('label')->withMaxLimit($limit);
123  $this->assertEquals($textarea->getMaxLimit(), $limit);
124  }
+ Here is the call graph for this function:

◆ testGetMinLimit()

TextareaTest::testGetMinLimit ( )

Definition at line 110 of file TextareaTest.php.

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

110  : void
111  {
112  $f = $this->buildFactory();
113  $limit = 5;
114  $textarea = $f->textarea('label')->withMinLimit($limit);
115  $this->assertEquals($textarea->getMinLimit(), $limit);
116  }
+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

TextareaTest::testImplementsFactoryInterface ( )

Definition at line 53 of file TextareaTest.php.

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

53  : void
54  {
55  $f = $this->buildFactory();
56  $textarea = $f->textarea("label", "byline");
57  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $textarea);
58  $this->assertInstanceOf(Field\Textarea::class, $textarea);
59  }
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ testImplementsFactoryInterface_without_byline()

TextareaTest::testImplementsFactoryInterface_without_byline ( )

Definition at line 61 of file TextareaTest.php.

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

61  : void
62  {
63  $f = $this->buildFactory();
64  $textarea = $f->textarea("label");
65  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $textarea);
66  $this->assertInstanceOf(Field\Textarea::class, $textarea);
67  }
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ testIsLimited()

TextareaTest::testIsLimited ( )

Definition at line 89 of file TextareaTest.php.

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

89  : void
90  {
91  $f = $this->buildFactory();
92 
93  // with min limit
94  $textarea = $f->textarea('label')->withMinLimit(5);
95  $this->assertTrue($textarea->isLimited());
96 
97  // with max limit
98  $textarea = $f->textarea('label')->withMaxLimit(5);
99  $this->assertTrue($textarea->isLimited());
100 
101  // with min-max limit
102  $textarea = $f->textarea('label')->withMinLimit(5)->withMaxLimit(20);
103  $this->assertTrue($textarea->isLimited());
104 
105  // without limit
106  $textarea = $f->textarea('label');
107  $this->assertFalse($textarea->isLimited());
108  }
+ Here is the call graph for this function:

◆ testRenderer()

TextareaTest::testRenderer ( )

Definition at line 127 of file TextareaTest.php.

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

127  : void
128  {
129  $f = $this->buildFactory();
130  $r = $this->getDefaultRenderer();
131  $id = "id_1";
132  $label = "label";
133  $byline = "byline";
134  $name = "name_0";
135  $textarea = $f->textarea($label, $byline)->withNameFrom($this->name_source);
136 
137  $expected = "
138  <div class=\"form-group row\">
139  <label for=\"$id\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>
140  <div class=\"col-sm-8 col-md-9 col-lg-10\">
141  <div class=\"ui-input-textarea\">
142  <textarea id=\"$id\" class=\"form-control form-control-sm\" name=\"$name\"></textarea>
143  </div>
144  <div class=\"help-block\">$byline</div>
145  </div>
146  </div>
147  ";
148 
149  $html = $this->normalizeHTML($r->render($textarea));
150  $this->assertHTMLEquals($expected, $html);
151  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRendererCounterWithValue()

TextareaTest::testRendererCounterWithValue ( )

Definition at line 240 of file TextareaTest.php.

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

240  : void
241  {
242  $f = $this->buildFactory();
243  $r = $this->getDefaultRenderer();
244  $id = 'id_1';
245  $label = "label";
246  $byline = "byline";
247  $name = "name_0";
248  $value = "Lorem ipsum dolor sit";
249  $textarea = $f->textarea($label, $byline)->withValue($value)->withNameFrom($this->name_source);
250 
251  $expected = "
252  <div class=\"form-group row\">
253  <label for=\"$id\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>
254  <div class=\"col-sm-8 col-md-9 col-lg-10\">
255  <div class=\"ui-input-textarea\">
256  <textarea id=\"$id\" class=\"form-control form-control-sm\" name=\"$name\">$value</textarea>
257  </div>
258  <div class=\"help-block\">$byline</div>
259  </div>
260  </div>
261  ";
262 
263  $html = $this->normalizeHTML($r->render($textarea));
264  $this->assertHTMLEquals($expected, $html);
265  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRendererWithDisabled()

TextareaTest::testRendererWithDisabled ( )

Definition at line 296 of file TextareaTest.php.

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

296  : void
297  {
298  $f = $this->buildFactory();
299  $r = $this->getDefaultRenderer();
300  $id = "id_1";
301  $label = "label";
302  $byline = "byline";
303  $name = "name_0";
304  $textarea = $f->textarea($label, $byline)->withNameFrom($this->name_source)->withDisabled(true);
305 
306  $expected = "
307  <div class=\"form-group row\">
308  <label for=\"$id\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>
309  <div class=\"col-sm-8 col-md-9 col-lg-10\">
310  <div class=\"ui-input-textarea\">
311  <textarea id=\"$id\" class=\"form-control form-control-sm\" name=\"$name\" disabled=\"disabled\"></textarea>
312  </div>
313  <div class=\"help-block\">$byline</div>
314  </div>
315  </div>
316  ";
317 
318  $html = $this->normalizeHTML($r->render($textarea));
319  $this->assertHTMLEquals($expected, $html);
320  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testRendererWithError()

TextareaTest::testRendererWithError ( )

Definition at line 267 of file TextareaTest.php.

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

267  : void
268  {
269  $f = $this->buildFactory();
270  $r = $this->getDefaultRenderer();
271  $id = "id_1";
272  $label = "label";
273  $name = "name_0";
274  $min = 5;
275  $byline = "This is just a byline Min: " . $min;
276  $error = "an_error";
277  $textarea = $f->textarea($label, $byline)->withNameFrom($this->name_source)->withError($error);
278 
279  $expected = "
280  <div class=\"form-group row\">
281  <label for=\"$id\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>
282  <div class=\"col-sm-8 col-md-9 col-lg-10\">
283  <div class=\"help-block alert alert-danger\" aria-describedby=\"$id\" role=\"alert\">an_error</div>
284  <div class=\"ui-input-textarea\">
285  <textarea id=\"$id\" class=\"form-control form-control-sm\" name=\"$name\"></textarea>
286  </div>
287  <div class=\"help-block\">$byline</div>
288  </div>
289  </div>
290  ";
291 
292  $html = $this->brutallyTrimHTML($r->render($textarea));
293  $this->assertEquals($this->brutallyTrimHTML($expected), $html);
294  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:475
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$r
+ Here is the call graph for this function:

◆ testRendererWithMaxLimit()

TextareaTest::testRendererWithMaxLimit ( )

Definition at line 181 of file TextareaTest.php.

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

181  : void
182  {
183  $f = $this->buildFactory();
184  $r = $this->getDefaultRenderer();
185  $name = "name_0";
186  $id = "id_1";
187  $label = "label";
188  $max = 20;
189  $byline = "This is just a byline Max: " . $max;
190  $textarea = $f->textarea($label, $byline)->withMaxLimit($max)->withNameFrom($this->name_source);
191 
192  $expected = "
193  <div class=\"form-group row\">
194  <label for=\"$id\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>
195  <div class=\"col-sm-8 col-md-9 col-lg-10\">
196  <div class=\"ui-input-textarea\">
197  <textarea id=\"$id\" class=\"form-control form-control-sm\" name=\"$name\" maxlength=\"$max\"></textarea>
198  <div class=\"ui-input-textarea-remainder\"> ui_chars_remaining <span data-action=\"remainder\">$max</span> </div>
199  </div>
200  <div class=\"help-block\">$byline</div>
201  </div>
202  </div>
203  ";
204 
205  $html = $this->brutallyTrimHTML($r->render($textarea));
206  $this->assertHTMLEquals($this->brutallyTrimHTML($expected), $html);
207  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:475
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$r
+ Here is the call graph for this function:

◆ testRendererWithMinAndMaxLimit()

TextareaTest::testRendererWithMinAndMaxLimit ( )

Definition at line 209 of file TextareaTest.php.

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

209  : void
210  {
211  $f = $this->buildFactory();
212  $r = $this->getDefaultRenderer();
213  $name = "name_0";
214  $id = "id_1";
215  $label = "label";
216  $min = 5;
217  $max = 20;
218  $byline = "This is just a byline Min: " . $min . " Max: " . $max;
219  $textarea = $f->textarea($label, $byline)->withMinLimit($min)->withMaxLimit($max)->withNameFrom(
220  $this->name_source
221  );
222 
223  $expected = "
224  <div class=\"form-group row\">
225  <label for=\"$id\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>
226  <div class=\"col-sm-8 col-md-9 col-lg-10\">
227  <div class=\"ui-input-textarea\">
228  <textarea id=\"$id\" class=\"form-control form-control-sm\" name=\"$name\" minlength=\"5\" maxlength=\"20\"></textarea>
229  <div class=\"ui-input-textarea-remainder\"> ui_chars_remaining <span data-action=\"remainder\">$max</span> </div>
230  </div>
231  <div class=\"help-block\">$byline</div>
232  </div>
233  </div>
234  ";
235 
236  $html = $this->brutallyTrimHTML($r->render($textarea));
237  $this->assertHTMLEquals($this->brutallyTrimHTML($expected), $html);
238  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:475
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$r
+ Here is the call graph for this function:

◆ testRendererWithMinLimit()

TextareaTest::testRendererWithMinLimit ( )

Definition at line 153 of file TextareaTest.php.

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

153  : void
154  {
155  $f = $this->buildFactory();
156  $r = $this->getDefaultRenderer();
157  $name = "name_0";
158  $id = "id_1";
159  $label = "label";
160 
161  $min = 5;
162  $byline = "This is just a byline Min: " . $min;
163  $textarea = $f->textarea($label, $byline)->withMinLimit($min)->withNameFrom($this->name_source);
164 
165  $expected = "
166  <div class=\"form-group row\">
167  <label for=\"$id\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>
168  <div class=\"col-sm-8 col-md-9 col-lg-10\">
169  <div class=\"ui-input-textarea\">
170  <textarea id=\"$id\" class=\"form-control form-control-sm\" name=\"$name\" minlength=\"$min\"></textarea>
171  </div>
172  <div class=\"help-block\">$byline</div>
173  </div>
174  </div>
175  ";
176 
177  $html = $this->normalizeHTML($r->render($textarea));
178  $this->assertHTMLEquals($expected, $html);
179  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testStripsTags()

TextareaTest::testStripsTags ( )

Definition at line 322 of file TextareaTest.php.

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

322  : void
323  {
324  $f = $this->buildFactory();
325  $name = "name_0";
326  $text = $f->textarea("")
327  ->withNameFrom($this->name_source)
328  ->withInput(new DefInputData([$name => "<script>alert()</script>"]));
329 
330  $content = $text->getContent();
331  $this->assertEquals("alert()", $content->value());
332  }
+ Here is the call graph for this function:

◆ testWithMaxLimit()

TextareaTest::testWithMaxLimit ( )

Definition at line 79 of file TextareaTest.php.

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

79  : void
80  {
81  $f = $this->buildFactory();
82  $limit = 15;
83  $textarea = $f->textarea('label')->withMaxLimit($limit);
84  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $textarea);
85  $this->assertInstanceOf(Field\Textarea::class, $textarea);
86  $this->assertEquals($textarea->getMaxLimit(), $limit);
87  }
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ testWithMinLimit()

TextareaTest::testWithMinLimit ( )

Definition at line 69 of file TextareaTest.php.

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

69  : void
70  {
71  $f = $this->buildFactory();
72  $limit = 5;
73  $textarea = $f->textarea('label')->withMinLimit($limit);
74  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $textarea);
75  $this->assertInstanceOf(Field\Textarea::class, $textarea);
76  $this->assertEquals($textarea->getMinLimit(), $limit);
77  }
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

Field Documentation

◆ $name_source

DefNamesource TextareaTest::$name_source
private

Definition at line 33 of file TextareaTest.php.


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