19 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../../../libs/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../../../Base.php");
23 require_once(__DIR__ .
"/FormTest.php");
50 public int $count = 0;
54 $name =
"input_{$this->count}";
62 $name = $dedicated_name .
"_{$this->count}";
76 return new I\Input\Container\Form\Factory($this->buildInputFactory());
81 $df =
new Data\Factory();
82 $language = $this->createMock(ilLanguage::class);
83 return new I\Input\Field\Factory(
94 return new I\Button\Factory();
104 $f = $this->buildFactory();
105 $if = $this->buildInputFactory();
107 $form =
$f->standard(
$url, [$if->text(
"label")]);
108 $this->assertEquals(
$url, $form->getPostURL());
113 $f = $this->buildFactory();
114 $if = $this->buildInputFactory();
117 $form =
$f->standard(
$url, [
118 $if->text(
"label",
"byline"),
121 $r = $this->getDefaultRenderer();
122 $html = $this->brutallyTrimHTML($r->render($form));
124 $expected = $this->brutallyTrimHTML(
' 125 <form role="form" class="il-standard-form form-horizontal" enctype="multipart/form-data" action="MY_URL" method="post" novalidate="novalidate"> 126 <div class="il-standard-form-header clearfix"> 127 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 129 <div class="form-group row"> 130 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label> 131 <div class="col-sm-8 col-md-9 col-lg-10"> 132 <input id="id_1" type="text" name="form/input_0" class="form-control form-control-sm"/> 133 <div class="help-block">byline</div> 136 <div class="il-standard-form-footer clearfix"> 137 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 141 $this->assertHTMLEquals($expected, $html);
146 $f = $this->buildFactory();
147 $if = $this->buildInputFactory();
150 $form =
$f->standard(
$url, [
151 $if->text(
"label",
"byline"),
154 $this->assertNull($form->getSubmitCaption());
156 $caption =
'Caption';
157 $form = $form->withSubmitCaption($caption);
159 $this->assertEquals($caption, $form->getSubmitCaption());
164 $f = $this->buildFactory();
165 $if = $this->buildInputFactory();
168 $form =
$f->standard(
$url, [
169 $if->text(
"label",
"byline"),
170 ])->withSubmitCaption(
'create');
172 $r = $this->getDefaultRenderer();
173 $html = $this->brutallyTrimHTML($r->render($form));
175 $expected = $this->brutallyTrimHTML(
' 176 <form role="form" class="il-standard-form form-horizontal" enctype="multipart/form-data" action="MY_URL" method="post" novalidate="novalidate"> 177 <div class="il-standard-form-header clearfix"> 178 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">create</button></div> 180 <div class="form-group row"> 181 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label> 182 <div class="col-sm-8 col-md-9 col-lg-10"> 183 <input id="id_1" type="text" name="form/input_0" class="form-control form-control-sm"/> 184 <div class="help-block">byline</div> 187 <div class="il-standard-form-footer clearfix"> 188 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">create</button></div> 192 $this->assertHTMLEquals($expected, $html);
197 $f = $this->buildFactory();
198 $if = $this->buildInputFactory();
201 $form =
$f->standard(
$url, [
202 $if->text(
"label",
"byline"),
205 $r = $this->getDefaultRenderer();
206 $html = $this->brutallyTrimHTML($r->render($form));
208 $expected = $this->brutallyTrimHTML(
' 209 <form role="form" class="il-standard-form form-horizontal" enctype="multipart/form-data" method="post" novalidate="novalidate"> 210 <div class="il-standard-form-header clearfix"> 211 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 213 <div class="form-group row"> 214 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label> 215 <div class="col-sm-8 col-md-9 col-lg-10"> 216 <input id="id_1" type="text" name="form/input_0" class="form-control form-control-sm"/> 217 <div class="help-block">byline</div> 220 <div class="il-standard-form-footer clearfix"> 221 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 225 $this->assertHTMLEquals($expected, $html);
231 $r = $this->getDefaultRenderer();
232 $df =
new Data\Factory();
233 $language = $this->createMock(\ilLanguage::class);
235 ->expects($this->once())
237 ->willReturn(
'testing error message');
239 $refinery = new \ILIAS\Refinery\Factory($df, $language);
249 $fail =
$refinery->custom()->constraint(
function ($v) {
251 },
"This is invalid...");
252 $input = $if->text(
"label",
"byline");
254 $input = $input->withAdditionalTransformation($fail);
258 $request = $this->createMock(ServerRequestInterface::class);
260 ->expects($this->once())
261 ->method(
"getParsedBody")
263 'form_0/input_1' =>
'' 266 $form = $form->withRequest($request);
267 $this->assertNull($form->getData());
269 $html = $this->brutallyTrimHTML($r->render($form));
270 $expected = $this->brutallyTrimHTML(
' 271 <form role="form" class="il-standard-form form-horizontal" enctype="multipart/form-data" method="post" novalidate="novalidate"> 272 <div class="il-standard-form-header clearfix"> 273 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 276 <div class="help-block alert alert-danger" role="alert">testing error message</div> 278 <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 <div class="help-block alert alert-danger" aria-describedby="id_1" role="alert">This is invalid...</div> 282 <input id="id_1" type="text" name="form_0/input_1" class="form-control form-control-sm" /> 283 <div class="help-block">byline</div> 286 <div class="il-standard-form-footer clearfix"> 287 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 291 $this->assertHTMLEquals($expected, $html);
297 $r = $this->getDefaultRenderer();
298 $df =
new Data\Factory();
299 $language = $this->createMock(\ilLanguage::class);
300 $refinery = new \ILIAS\Refinery\Factory($df, $language);
310 $fail =
$refinery->custom()->constraint(
function ($v) {
312 },
"This is a fail on form.");
313 $input = $if->text(
"label",
"byline");
316 $form = $form->withAdditionalTransformation($fail);
318 $request = $this->createMock(ServerRequestInterface::class);
320 ->expects($this->once())
321 ->method(
"getParsedBody")
323 'form_0/input_1' =>
'' 326 $form = $form->withRequest($request);
327 $this->assertNull($form->getData());
329 $html = $this->brutallyTrimHTML($r->render($form));
330 $expected = $this->brutallyTrimHTML(
' 331 <form role="form" class="il-standard-form form-horizontal" enctype="multipart/form-data" method="post" novalidate="novalidate"> 332 <div class="il-standard-form-header clearfix"> 333 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 336 <div class="help-block alert alert-danger" role="alert">This is a fail on form.</div> 338 <div class="form-group row"> 339 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label> 340 <div class="col-sm-8 col-md-9 col-lg-10"> 341 <input id="id_1" type="text" name="form_0/input_1" class="form-control form-control-sm" /> 342 <div class="help-block">byline</div> 345 <div class="il-standard-form-footer clearfix"> 346 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 350 $this->assertHTMLEquals($expected, $html);
355 $f = $this->buildFactory();
356 $if = $this->buildInputFactory();
359 $form =
$f->standard(
$url, [$if->text(
"label",
"byline")->withRequired(
true)]);
361 $r = $this->getDefaultRenderer();
362 $html = $this->brutallyTrimHTML($r->render($form));
364 $expected = $this->brutallyTrimHTML(
' 365 <form role="form" class="il-standard-form form-horizontal" enctype="multipart/form-data" action="MY_URL" method="post" novalidate="novalidate"> 366 <div class="il-standard-form-header clearfix"> 367 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 369 <div class="form-group row"> 370 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label<span class="asterisk">*</span></label> 371 <div class="col-sm-8 col-md-9 col-lg-10"> 372 <input id="id_1" type="text" name="form/input_0" class="form-control form-control-sm"/> 373 <div class="help-block">byline</div> 376 <div class="il-standard-form-footer clearfix"> 377 <span class="asterisk">*</span><span class="small"> required_field</span> 379 <div class="il-standard-form-footer clearfix"> 380 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 384 $this->assertHTMLEquals($expected, $html);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Provides common functionality for UI tests.
Refinery Factory $refinery