19 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../../../../../vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../../../Base.php");
23 require_once(__DIR__ .
"/FormTest.php");
24 require_once(__DIR__ .
"/../../Field/CommonFieldRendering.php");
51 public int $count = 0;
55 $name =
"input_{$this->count}";
63 $name = $dedicated_name .
"_{$this->count}";
80 return new I\Input\Container\Form\Factory(
81 $this->getFieldFactory(),
88 return new I\Button\Factory();
98 $f = $this->buildFactory();
99 $if = $this->getFieldFactory();
101 $form =
$f->standard(
$url, [$if->text(
"label")]);
102 $this->assertEquals(
$url, $form->getPostURL());
107 return $this->getFormWrappedHtml(
110 '<input id="id_1" type="text" name="form/input_0" class="c-field-text" />',
120 $f = $this->buildFactory();
121 $if = $this->getFieldFactory();
124 $form =
$f->standard(
$url, [
125 $if->text(
"label",
"byline"),
128 $r = $this->getDefaultRenderer();
129 $html = $this->getDefaultRenderer()->render($form);
131 $expected = $this->brutallyTrimHTML(
' 132 <form class="c-form c-form--horizontal" enctype="multipart/form-data" action="MY_URL" method="post"> 133 <div class="c-form__header"> 134 <div class="c-form__actions"><button class="btn btn-default" data-action="">save</button></div> 136 . $this->getTextFieldHtml() .
137 '<div class="c-form__footer"> 138 <div class="c-form__actions"><button class="btn btn-default" data-action="">save</button></div> 142 $this->assertHTMLEquals($expected, $html);
147 $f = $this->buildFactory();
148 $if = $this->getFieldFactory();
151 $form =
$f->standard(
$url, [
152 $if->text(
"label",
"byline"),
155 $this->assertNull($form->getSubmitLabel());
157 $caption =
'Caption';
158 $form = $form->withSubmitLabel($caption);
160 $this->assertEquals($caption, $form->getSubmitLabel());
165 $f = $this->buildFactory();
166 $if = $this->getFieldFactory();
169 $form =
$f->standard(
$url, [
170 $if->text(
"label",
"byline"),
171 ])->withSubmitLabel(
'create');
173 $r = $this->getDefaultRenderer();
174 $html = $this->brutallyTrimHTML(
$r->render($form));
176 $expected = $this->brutallyTrimHTML(
' 177 <form class="c-form c-form--horizontal" enctype="multipart/form-data" action="MY_URL" method="post"> 178 <div class="c-form__header"> 179 <div class="c-form__actions"><button class="btn btn-default" data-action="">create</button></div> 181 . $this->getTextFieldHtml() .
182 '<div class="c-form__footer"> 183 <div class="c-form__actions"><button class="btn btn-default" data-action="">create</button></div> 187 $this->assertHTMLEquals($expected, $html);
192 $f = $this->buildFactory();
193 $if = $this->getFieldFactory();
196 $form =
$f->standard(
$url, [
197 $if->text(
"label",
"byline"),
200 $r = $this->getDefaultRenderer();
201 $html = $this->brutallyTrimHTML(
$r->render($form));
203 $expected = $this->brutallyTrimHTML(
' 204 <form class="c-form c-form--horizontal" enctype="multipart/form-data" method="post"> 205 <div class="c-form__header"> 206 <div class="c-form__actions"> 207 <button class="btn btn-default" data-action="">save</button> 210 . $this->getTextFieldHtml() .
211 '<div class="c-form__footer"> 212 <div class="c-form__actions"> 213 <button class="btn btn-default" data-action="">save</button> 218 $this->assertHTMLEquals($expected, $html);
224 $r = $this->getDefaultRenderer();
225 $df =
new Data\Factory();
226 $language = $this->createMock(\
ILIAS\
Language\Language::class);
228 ->expects($this->once())
230 ->willReturn(
'testing error message');
232 $refinery = new \ILIAS\Refinery\Factory($df, $language);
242 $fail =
$refinery->custom()->constraint(
function ($v) {
244 },
"This is invalid...");
245 $input = $if->text(
"label",
"byline");
247 $input = $input->withAdditionalTransformation($fail);
251 $request = $this->createMock(ServerRequestInterface::class);
253 ->expects($this->once())
254 ->method(
"getParsedBody")
256 'form_0/input_1' =>
'' 259 $form = $form->withRequest($request);
260 $this->assertNull($form->getData());
262 $html = $this->brutallyTrimHTML(
$r->render($form));
263 $expected = $this->brutallyTrimHTML(
' 264 <form class="c-form c-form--horizontal" enctype="multipart/form-data" method="post"> 265 <div class="c-form__header"> 266 <div class="c-form__actions"> 267 <button class="btn btn-default" data-action="">save</button> 270 <div class="c-form__error-msg alert alert-danger"><span class="sr-only">ui_error:</span>testing error 273 <fieldset class="c-input" data-il-ui-component="text-field-input" data-il-ui-input-name="form_0/input_1" 274 aria-describedby="id_2"><label for="id_1">label</label> 275 <div class="c-input__field"><input id="id_1" type="text" name="form_0/input_1" class="c-field-text" /></div> 276 <div class="c-input__error-msg alert alert-danger" id="id_2"><span class="sr-only">ui_error:</span>This is 279 <div class="c-input__help-byline">byline</div> 281 <div class="c-form__footer"> 282 <div class="c-form__actions"> 283 <button class="btn btn-default" data-action="">save</button> 288 $this->assertEquals($expected, $html);
289 $this->assertHTMLEquals($expected, $html);
295 $r = $this->getDefaultRenderer();
296 $df =
new Data\Factory();
297 $language = $this->createMock(\
ILIAS\
Language\Language::class);
298 $refinery = new \ILIAS\Refinery\Factory($df, $language);
308 $fail =
$refinery->custom()->constraint(
function ($v) {
310 },
"This is a fail on form.");
311 $input = $if->text(
"label",
"byline");
314 $form = $form->withAdditionalTransformation($fail);
316 $request = $this->createMock(ServerRequestInterface::class);
318 ->expects($this->once())
319 ->method(
"getParsedBody")
321 'form_0/input_1' =>
'' 324 $form = $form->withRequest($request);
325 $this->assertNull($form->getData());
328 $field_html = $this->getFormWrappedHtml(
331 '<input id="id_1" type="text" name="form_0/input_1" class="c-field-text"/>',
338 $html = $this->brutallyTrimHTML(
$r->render($form));
339 $expected = $this->brutallyTrimHTML(
' 340 <form class="c-form c-form--horizontal" enctype="multipart/form-data" method="post"> 341 <div class="c-form__header"> 342 <div class="c-form__actions"><button class="btn btn-default" data-action="">save</button></div> 344 <div class="c-form__error-msg alert alert-danger"><span class="sr-only">ui_error:</span>This is a fail on form.</div> 346 <div class="c-form__footer"> 347 <div class="c-form__actions"><button class="btn btn-default" data-action="">save</button></div> 351 $this->assertHTMLEquals($expected, $html);
356 $f = $this->buildFactory();
357 $if = $this->getFieldFactory();
360 $form =
$f->standard(
$url, [$if->text(
"label",
"byline")->withRequired(
true)]);
362 $r = $this->getDefaultRenderer();
363 $html = $this->brutallyTrimHTML(
$r->render($form));
365 $field_html = $this->getFormWrappedHtml(
367 'label<span class="asterisk" aria-label="required_field">*</span>',
368 '<input id="id_1" type="text" name="form/input_0" class="c-field-text" />',
375 $expected = $this->brutallyTrimHTML(
' 376 <form class="c-form c-form--horizontal" enctype="multipart/form-data" action="MY_URL" method="post"> 377 <div class="c-form__header"> 378 <div class="c-form__actions"><button class="btn btn-default" data-action="">save</button></div> 379 <div class="c-form__required"> 380 <span class="asterisk">*</span><span class="small"> required_field</span> 384 <div class="c-form__footer"> 385 <div class="c-form__required"> 386 <span class="asterisk">*</span><span class="small"> required_field</span> 388 <div class="c-form__actions"><button class="btn btn-default" data-action="">save</button></div> 392 $this->assertHTMLEquals($expected, $html);
Interface Observer Contains several chained tasks and infos about them.
Builds a Color from either hex- or rgb values.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null