ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 ()
 
 testCommonRendering ()
 
 testRendererWithMinLimit ()
 
 testRendererWithMaxLimit ()
 
 testRendererWithMinAndMaxLimit ()
 
 testRendererCounterWithValue ()
 
 testStripsTags ()
 

Private Attributes

DefNamesource $name_source
 

Detailed Description

Definition at line 32 of file TextareaTest.php.

Member Function Documentation

◆ setUp()

TextareaTest::setUp ( )

Definition at line 38 of file TextareaTest.php.

38  : void
39  {
40  $this->name_source = new DefNamesource();
41  }

◆ testCommonRendering()

TextareaTest::testCommonRendering ( )

Definition at line 136 of file TextareaTest.php.

References Vendor\Package\$f.

136  : void
137  {
138  $f = $this->getFieldFactory();
139  $label = "label";
140  $textarea = $f->textarea($label)->withNameFrom($this->name_source);
141 
142  $this->testWithError($textarea);
143  $this->testWithNoByline($textarea);
144  $this->testWithRequired($textarea);
145  $this->testWithDisabled($textarea);
146  $this->testWithAdditionalOnloadCodeRendersId($textarea);
147  }

◆ testGetMaxLimit()

TextareaTest::testGetMaxLimit ( )

Definition at line 108 of file TextareaTest.php.

References Vendor\Package\$f.

108  : void
109  {
110  $f = $this->getFieldFactory();
111  $limit = 15;
112  $textarea = $f->textarea('label')->withMaxLimit($limit);
113  $this->assertEquals($textarea->getMaxLimit(), $limit);
114  }

◆ testGetMinLimit()

TextareaTest::testGetMinLimit ( )

Definition at line 100 of file TextareaTest.php.

References Vendor\Package\$f.

100  : void
101  {
102  $f = $this->getFieldFactory();
103  $limit = 5;
104  $textarea = $f->textarea('label')->withMinLimit($limit);
105  $this->assertEquals($textarea->getMinLimit(), $limit);
106  }

◆ testImplementsFactoryInterface()

TextareaTest::testImplementsFactoryInterface ( )

Definition at line 43 of file TextareaTest.php.

References Vendor\Package\$f.

43  : void
44  {
45  $f = $this->getFieldFactory();
46  $textarea = $f->textarea("label", "byline");
47  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $textarea);
48  $this->assertInstanceOf(Field\Textarea::class, $textarea);
49  }
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testImplementsFactoryInterface_without_byline()

TextareaTest::testImplementsFactoryInterface_without_byline ( )

Definition at line 51 of file TextareaTest.php.

References Vendor\Package\$f.

51  : void
52  {
53  $f = $this->getFieldFactory();
54  $textarea = $f->textarea("label");
55  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $textarea);
56  $this->assertInstanceOf(Field\Textarea::class, $textarea);
57  }
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testIsLimited()

TextareaTest::testIsLimited ( )

Definition at line 79 of file TextareaTest.php.

References Vendor\Package\$f.

79  : void
80  {
81  $f = $this->getFieldFactory();
82 
83  // with min limit
84  $textarea = $f->textarea('label')->withMinLimit(5);
85  $this->assertTrue($textarea->isLimited());
86 
87  // with max limit
88  $textarea = $f->textarea('label')->withMaxLimit(5);
89  $this->assertTrue($textarea->isLimited());
90 
91  // with min-max limit
92  $textarea = $f->textarea('label')->withMinLimit(5)->withMaxLimit(20);
93  $this->assertTrue($textarea->isLimited());
94 
95  // without limit
96  $textarea = $f->textarea('label');
97  $this->assertFalse($textarea->isLimited());
98  }

◆ testRenderer()

TextareaTest::testRenderer ( )

Definition at line 117 of file TextareaTest.php.

References Vendor\Package\$f.

117  : void
118  {
119  $f = $this->getFieldFactory();
120  $label = "label";
121  $byline = "byline";
122  $textarea = $f->textarea($label, $byline)->withNameFrom($this->name_source);
123  $expected = $this->getFormWrappedHtml(
124  'textarea-field-input',
125  $label,
126  '
127  <textarea id="id_1" class="c-field-textarea" name="name_0"></textarea>
128  ',
129  $byline,
130  'id_1',
131  'id_2',
132  );
133  $this->assertEquals($expected, $this->render($textarea));
134  }

◆ testRendererCounterWithValue()

TextareaTest::testRendererCounterWithValue ( )

Definition at line 211 of file TextareaTest.php.

References Vendor\Package\$f, and $id.

211  : void
212  {
213  $f = $this->getFieldFactory();
214  $id = 'id_1';
215  $label = "label";
216  $byline = "byline";
217  $name = "name_0";
218  $value = "Lorem ipsum dolor sit";
219  $textarea = $f->textarea($label, $byline)->withValue($value)->withNameFrom($this->name_source);
220 
221  $expected = $this->brutallyTrimHTML("
222  <div class=\"c-input__field\">
223  <textarea id=\"$id\" class=\"c-field-textarea\" name=\"$name\">$value</textarea>
224  </div>
225  ");
226  $this->assertStringContainsString($expected, $this->render($textarea));
227  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24

◆ testRendererWithMaxLimit()

TextareaTest::testRendererWithMaxLimit ( )

Definition at line 169 of file TextareaTest.php.

References Vendor\Package\$f.

169  : void
170  {
171  $f = $this->getFieldFactory();
172  $label = "label";
173  $max = 20;
174  $byline = "This is just a byline Max: " . $max;
175  $textarea = $f->textarea($label, $byline)->withMaxLimit($max)->withNameFrom($this->name_source);
176  $expected = $this->getFormWrappedHtml(
177  'textarea-field-input',
178  $label,
179  '
180  <textarea id="id_1" class="c-field-textarea" name="name_0" maxlength="20"></textarea>
181  <div class="ui-input-textarea-remainder"> ui_chars_remaining<span data-action="remainder">20</span></div>
182  ',
183  $byline,
184  'id_1',
185  'id_2'
186  );
187  $this->assertEquals($expected, $this->render($textarea));
188  }

◆ testRendererWithMinAndMaxLimit()

TextareaTest::testRendererWithMinAndMaxLimit ( )

Definition at line 190 of file TextareaTest.php.

References Vendor\Package\$f, $id, and $r.

190  : void
191  {
192  $f = $this->getFieldFactory();
193  $r = $this->getDefaultRenderer();
194  $name = "name_0";
195  $id = "id_1";
196  $label = "label";
197  $min = 5;
198  $max = 20;
199  $byline = "This is just a byline Min: " . $min . " Max: " . $max;
200  $textarea = $f->textarea($label, $byline)->withMinLimit($min)->withMaxLimit($max)->withNameFrom(
201  $this->name_source
202  );
203 
204  $expected = $this->brutallyTrimHTML("
205  <textarea id=\"$id\" class=\"c-field-textarea\" name=\"$name\" minlength=\"5\" maxlength=\"20\"></textarea>
206  <div class=\"ui-input-textarea-remainder\"> ui_chars_remaining <span data-action=\"remainder\">$max</span> </div>
207  ");
208  $this->assertStringContainsString($expected, $this->render($textarea));
209  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
$r

◆ testRendererWithMinLimit()

TextareaTest::testRendererWithMinLimit ( )

Definition at line 149 of file TextareaTest.php.

References Vendor\Package\$f.

149  : void
150  {
151  $f = $this->getFieldFactory();
152  $label = "label";
153  $min = 5;
154  $byline = "This is just a byline Min: " . $min;
155  $textarea = $f->textarea($label, $byline)->withMinLimit($min)->withNameFrom($this->name_source);
156  $expected = $this->getFormWrappedHtml(
157  'textarea-field-input',
158  $label,
159  '
160  <textarea id="id_1" class="c-field-textarea" name="name_0" minlength="5"></textarea>
161  ',
162  $byline,
163  'id_1',
164  'id_2'
165  );
166  $this->assertEquals($expected, $this->render($textarea));
167  }

◆ testStripsTags()

TextareaTest::testStripsTags ( )

Definition at line 229 of file TextareaTest.php.

References Vendor\Package\$f, and $text.

229  : void
230  {
231  $f = $this->getFieldFactory();
232  $name = "name_0";
233  $text = $f->textarea("")
234  ->withNameFrom($this->name_source)
235  ->withInput(new DefInputData([$name => "<script>alert()</script>"]));
236 
237  $content = $text->getContent();
238  $this->assertEquals("alert()", $content->value());
239  }
$text
Definition: xapiexit.php:21

◆ testWithMaxLimit()

TextareaTest::testWithMaxLimit ( )

Definition at line 69 of file TextareaTest.php.

References Vendor\Package\$f.

69  : void
70  {
71  $f = $this->getFieldFactory();
72  $limit = 15;
73  $textarea = $f->textarea('label')->withMaxLimit($limit);
74  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $textarea);
75  $this->assertInstanceOf(Field\Textarea::class, $textarea);
76  $this->assertEquals($textarea->getMaxLimit(), $limit);
77  }
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testWithMinLimit()

TextareaTest::testWithMinLimit ( )

Definition at line 59 of file TextareaTest.php.

References Vendor\Package\$f.

59  : void
60  {
61  $f = $this->getFieldFactory();
62  $limit = 5;
63  $textarea = $f->textarea('label')->withMinLimit($limit);
64  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $textarea);
65  $this->assertInstanceOf(Field\Textarea::class, $textarea);
66  $this->assertEquals($textarea->getMinLimit(), $limit);
67  }
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Field Documentation

◆ $name_source

DefNamesource TextareaTest::$name_source
private

Definition at line 36 of file TextareaTest.php.


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