19 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../../../../vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../../Base.php");
23 require_once(__DIR__ .
"/InputTest.php");
24 require_once(__DIR__ .
"/CommonFieldRendering.php");
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);
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);
61 $f = $this->getFieldFactory();
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);
71 $f = $this->getFieldFactory();
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);
81 $f = $this->getFieldFactory();
84 $textarea =
$f->textarea(
'label')->withMinLimit(5);
85 $this->assertTrue($textarea->isLimited());
88 $textarea =
$f->textarea(
'label')->withMaxLimit(5);
89 $this->assertTrue($textarea->isLimited());
92 $textarea =
$f->textarea(
'label')->withMinLimit(5)->withMaxLimit(20);
93 $this->assertTrue($textarea->isLimited());
96 $textarea =
$f->textarea(
'label');
97 $this->assertFalse($textarea->isLimited());
102 $f = $this->getFieldFactory();
104 $textarea =
$f->textarea(
'label')->withMinLimit($limit);
105 $this->assertEquals($textarea->getMinLimit(), $limit);
110 $f = $this->getFieldFactory();
112 $textarea =
$f->textarea(
'label')->withMaxLimit($limit);
113 $this->assertEquals($textarea->getMaxLimit(), $limit);
119 $f = $this->getFieldFactory();
122 $textarea =
$f->textarea($label, $byline)->withNameFrom($this->name_source);
123 $expected = $this->getFormWrappedHtml(
124 'textarea-field-input',
127 <textarea id="id_1" class="c-field-textarea" name="name_0"></textarea> 133 $this->assertEquals($expected, $this->render($textarea));
138 $f = $this->getFieldFactory();
140 $textarea =
$f->textarea($label)->withNameFrom($this->name_source);
142 $this->testWithError($textarea);
143 $this->testWithNoByline($textarea);
144 $this->testWithRequired($textarea);
145 $this->testWithDisabled($textarea);
146 $this->testWithAdditionalOnloadCodeRendersId($textarea);
151 $f = $this->getFieldFactory();
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',
160 <textarea id="id_1" class="c-field-textarea" name="name_0" minlength="5"></textarea> 166 $this->assertEquals($expected, $this->render($textarea));
171 $f = $this->getFieldFactory();
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',
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> 187 $this->assertEquals($expected, $this->render($textarea));
192 $f = $this->getFieldFactory();
193 $r = $this->getDefaultRenderer();
199 $byline =
"This is just a byline Min: " . $min .
" Max: " . $max;
200 $textarea =
$f->textarea($label, $byline)->withMinLimit($min)->withMaxLimit($max)->withNameFrom(
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> 208 $this->assertStringContainsString($expected, $this->render($textarea));
213 $f = $this->getFieldFactory();
218 $value =
"Lorem ipsum dolor sit";
219 $textarea =
$f->textarea($label, $byline)->withValue($value)->withNameFrom($this->name_source);
221 $expected = $this->brutallyTrimHTML(
" 222 <div class=\"c-input__field\"> 223 <textarea id=\"$id\" class=\"c-field-textarea\" name=\"$name\">$value</textarea> 226 $this->assertStringContainsString($expected, $this->render($textarea));
231 $f = $this->getFieldFactory();
233 $text =
$f->textarea(
"")
234 ->withNameFrom($this->name_source)
235 ->withInput(
new DefInputData([$name =>
"<script>alert()</script>"]));
237 $content = $text->getContent();
238 $this->assertEquals(
"alert()", $content->value());
243 $f = $this->getFieldFactory();
245 $text =
$f->textarea(
"")
246 ->withNameFrom($this->name_source)
248 ->withInput(
new DefInputData([$name =>
"<script>alert()</script>"]));
250 $content = $text->getContent();
251 $this->assertEquals(
"<script>alert()</script>", $content->value());
testRendererCounterWithValue()
testImplementsFactoryInterface_without_byline()
testRendererWithMaxLimit()
Interface Observer Contains several chained tasks and infos about them.
DefNamesource $name_source
testRendererWithMinAndMaxLimit()
testRendererWithMinLimit()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
testImplementsFactoryInterface()