ILIAS  release_8 Revision v8.24
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 ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 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.

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 }
This is a legacy support of Component\Input\Field\Input that has been moved to Component\Input\Contai...
Definition: Input.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.

Referenced by test_get_max_limit(), test_get_min_limit(), test_implements_factory_interface(), test_implements_factory_interface_without_byline(), test_is_limited(), test_renderer(), test_renderer_counter_with_value(), test_renderer_with_disabled(), test_renderer_with_error(), test_renderer_with_max_limit(), test_renderer_with_min_and_max_limit(), test_renderer_with_min_limit(), test_stripsTags(), test_with_max_limit(), and test_with_min_limit().

+ Here is the caller graph for this function:

◆ setUp()

TextareaTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 35 of file TextareaTest.php.

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

◆ test_get_max_limit()

TextareaTest::test_get_max_limit ( )

Definition at line 118 of file TextareaTest.php.

118 : void
119 {
120 $f = $this->buildFactory();
121 $limit = 15;
122 $textarea = $f->textarea('label')->withMaxLimit($limit);
123 $this->assertEquals($textarea->getMaxLimit(), $limit);
124 }

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

+ Here is the call graph for this function:

◆ test_get_min_limit()

TextareaTest::test_get_min_limit ( )

Definition at line 110 of file TextareaTest.php.

110 : void
111 {
112 $f = $this->buildFactory();
113 $limit = 5;
114 $textarea = $f->textarea('label')->withMinLimit($limit);
115 $this->assertEquals($textarea->getMinLimit(), $limit);
116 }

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

+ Here is the call graph for this function:

◆ test_implements_factory_interface()

TextareaTest::test_implements_factory_interface ( )

Definition at line 53 of file TextareaTest.php.

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 }

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

+ Here is the call graph for this function:

◆ test_implements_factory_interface_without_byline()

TextareaTest::test_implements_factory_interface_without_byline ( )

Definition at line 61 of file TextareaTest.php.

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 }

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

+ Here is the call graph for this function:

◆ test_is_limited()

TextareaTest::test_is_limited ( )

Definition at line 89 of file TextareaTest.php.

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 }

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

+ Here is the call graph for this function:

◆ test_renderer()

TextareaTest::test_renderer ( )

Definition at line 127 of file TextareaTest.php.

127 : void
128 {
129 $f = $this->buildFactory();
130 $r = $this->getDefaultRenderer();
131 $label = "label";
132 $byline = "byline";
133 $name = "name_0";
134 $textarea = $f->textarea($label, $byline)->withNameFrom($this->name_source);
135
136 $expected = "<div class=\"form-group row\">"
137 . "<label for=\"id_1\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
138 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
139 . "<textarea id=\"id_1\" name=\"$name\" class=\"form-control form-control-sm\"></textarea>"
140 . "<div class=\"help-block\">byline</div>"
141 . "</div>"
142 . "</div>";
143
144 $html = $this->normalizeHTML($r->render($textarea));
145 $this->assertHTMLEquals($expected, $html);
146 }
normalizeHTML(string $html)
Definition: Base.php:422
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
if($format !==null) $name
Definition: metadata.php:247

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

+ Here is the call graph for this function:

◆ test_renderer_counter_with_value()

TextareaTest::test_renderer_counter_with_value ( )

Definition at line 222 of file TextareaTest.php.

222 : void
223 {
224 $f = $this->buildFactory();
225 $r = $this->getDefaultRenderer();
226 $label = "label";
227 $byline = "byline";
228 $name = "name_0";
229 $value = "Lorem ipsum dolor sit";
230 $textarea = $f->textarea($label, $byline)->withValue($value)->withNameFrom($this->name_source);
231
232 $expected = "<div class=\"form-group row\">"
233 . "<label for=\"id_1\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
234 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
235 . "<textarea id=\"id_1\" name=\"$name\" class=\"form-control form-control-sm\">$value</textarea>"
236 . "<div class=\"help-block\">byline</div>"
237 . "</div>"
238 . "</div>";
239
240 $html = $this->normalizeHTML($r->render($textarea));
241 $this->assertHTMLEquals($expected, $html);
242 }

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

+ Here is the call graph for this function:

◆ test_renderer_with_disabled()

TextareaTest::test_renderer_with_disabled ( )

Definition at line 269 of file TextareaTest.php.

269 : void
270 {
271 $f = $this->buildFactory();
272 $r = $this->getDefaultRenderer();
273 $label = "label";
274 $byline = "byline";
275 $name = "name_0";
276 $textarea = $f->textarea($label, $byline)->withNameFrom($this->name_source)->withDisabled(true);
277
278 $expected = "<div class=\"form-group row\">"
279 . "<label for=\"id_1\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
280 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
281 . "<textarea id=\"id_1\" name=\"$name\" disabled=\"disabled\" class=\"form-control form-control-sm\"></textarea>"
282 . "<div class=\"help-block\">byline</div>"
283 . "</div>"
284 . "</div>";
285
286 $html = $this->normalizeHTML($r->render($textarea));
287 $this->assertHTMLEquals($expected, $html);
288 }

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

+ Here is the call graph for this function:

◆ test_renderer_with_error()

TextareaTest::test_renderer_with_error ( )

Definition at line 244 of file TextareaTest.php.

244 : void
245 {
246 $f = $this->buildFactory();
247 $r = $this->getDefaultRenderer();
248 $label = "label";
249 $min = 5;
250 $byline = "This is just a byline Min: " . $min;
251 $error = "an_error";
252 $textarea = $f->textarea($label, $byline)->withNameFrom($this->name_source)->withError($error);
253
254 $expected = $this->brutallyTrimHTML('
255<div class="form-group row">
256 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label>
257 <div class="col-sm-8 col-md-9 col-lg-10">
258 <div class="help-block alert alert-danger" aria-describedby="id_1" role="alert">an_error</div>
259 <textarea id="id_1" name="name_0" class="form-control form-control-sm"></textarea>
260 <div class="help-block">This is just a byline Min: 5</div>
261 </div>
262</div>
263');
264
265 $html = $this->brutallyTrimHTML($r->render($textarea));
266 $this->assertEquals($expected, $html);
267 }
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444

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

+ Here is the call graph for this function:

◆ test_renderer_with_max_limit()

TextareaTest::test_renderer_with_max_limit ( )

Definition at line 173 of file TextareaTest.php.

173 : void
174 {
175 $f = $this->buildFactory();
176 $r = $this->getDefaultRenderer();
177 $name = "name_0";
178 $id = "id_1";
179 $label = "label";
180 $max = 20;
181 $byline = "This is just a byline Max: " . $max;
182 $textarea = $f->textarea($label, $byline)->withMaxLimit($max)->withNameFrom($this->name_source);
183
184 $expected = "<div class=\"form-group row\">"
185 . "<label for=\"id_1\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
186 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
187 . "<textarea id=\"$id\" name=\"$name\" class=\"form-control form-control-sm\"></textarea>"
188 . "<div id=\"textarea_feedback_$id\" data-maxchars=\"$max\"></div>"
189 . "<div class=\"help-block\">$byline</div>"
190 . "</div>"
191 . "</div>";
192
193 $html = $this->normalizeHTML($r->render($textarea));
194 $this->assertHTMLEquals($expected, $html);
195 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

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

+ 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 197 of file TextareaTest.php.

197 : void
198 {
199 $f = $this->buildFactory();
200 $r = $this->getDefaultRenderer();
201 $name = "name_0";
202 $id = "id_1";
203 $label = "label";
204 $min = 5;
205 $max = 20;
206 $byline = "This is just a byline Min: " . $min . " Max: " . $max;
207 $textarea = $f->textarea($label, $byline)->withMinLimit($min)->withMaxLimit($max)->withNameFrom($this->name_source);
208
209 $expected = "<div class=\"form-group row\">"
210 . "<label for=\"id_1\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
211 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
212 . "<textarea id=\"$id\" name=\"$name\" class=\"form-control form-control-sm\"></textarea>"
213 . "<div id=\"textarea_feedback_$id\" data-maxchars=\"$max\"></div>"
214 . "<div class=\"help-block\">$byline</div>"
215 . "</div>"
216 . "</div>";
217
218 $html = $this->normalizeHTML($r->render($textarea));
219 $this->assertHTMLEquals($expected, $html);
220 }

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

+ Here is the call graph for this function:

◆ test_renderer_with_min_limit()

TextareaTest::test_renderer_with_min_limit ( )

Definition at line 148 of file TextareaTest.php.

148 : void
149 {
150 $f = $this->buildFactory();
151 $r = $this->getDefaultRenderer();
152 $name = "name_0";
153 $id = "id_1";
154 $label = "label";
155
156 $min = 5;
157 $byline = "This is just a byline Min: " . $min;
158 $textarea = $f->textarea($label, $byline)->withMinLimit($min)->withNameFrom($this->name_source);
159
160 $expected = "<div class=\"form-group row\">"
161 . "<label for=\"id_1\" class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
162 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
163 . "<textarea id=\"$id\" name=\"$name\" class=\"form-control form-control-sm\"></textarea>"
164 . "<div id=\"textarea_feedback_$id\" data-maxchars=\"\"></div>"
165 . "<div class=\"help-block\">$byline</div>"
166 . "</div>"
167 . "</div>";
168
169 $html = $this->normalizeHTML($r->render($textarea));
170 $this->assertHTMLEquals($expected, $html);
171 }

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

+ Here is the call graph for this function:

◆ test_stripsTags()

TextareaTest::test_stripsTags ( )

Definition at line 290 of file TextareaTest.php.

290 : void
291 {
292 $f = $this->buildFactory();
293 $name = "name_0";
294 $text = $f->textarea("")
295 ->withNameFrom($this->name_source)
296 ->withInput(new DefInputData([$name => "<script>alert()</script>"]));
297
298 $content = $text->getContent();
299 $this->assertEquals("alert()", $content->value());
300 }

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

+ Here is the call graph for this function:

◆ test_with_max_limit()

TextareaTest::test_with_max_limit ( )

Definition at line 79 of file TextareaTest.php.

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 }

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

+ Here is the call graph for this function:

◆ test_with_min_limit()

TextareaTest::test_with_min_limit ( )

Definition at line 69 of file TextareaTest.php.

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 }

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

+ 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: