18 declare(strict_types=1);
20 require_once(__DIR__ .
"/../../../../../../libs/composer/vendor/autoload.php");
21 require_once(__DIR__ .
"/../../../../Base.php");
22 require_once(__DIR__ .
"/FormTest.php");
59 $df =
new Data\Factory();
60 $language = $this->createMock(\ilLanguage::class);
83 $f = $this->buildFactory();
84 $if = $this->buildInputFactory();
86 $form =
$f->standard(
$url, [$if->text(
"label")]);
87 $this->assertEquals(
$url, $form->getPostURL());
93 $f = $this->buildFactory();
94 $if = $this->buildInputFactory();
97 $form =
$f->standard(
$url, [
98 $if->text(
"label",
"byline"),
101 $r = $this->getDefaultRenderer();
102 $html = $this->brutallyTrimHTML($r->render($form));
104 $expected = $this->brutallyTrimHTML(
' 105 <form role="form" class="il-standard-form form-horizontal" enctype="multipart/form-data" action="MY_URL" method="post" novalidate="novalidate"> 106 <div class="il-standard-form-header clearfix"> 107 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 109 <div class="form-group row"> 110 <label for="id_1" class="control-label col-sm-3">label</label> 111 <div class="col-sm-9"> 112 <input id="id_1" type="text" name="form_input_1" class="form-control form-control-sm"/> 113 <div class="help-block">byline</div> 116 <div class="il-standard-form-footer clearfix"> 117 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 121 $this->assertHTMLEquals($expected, $html);
126 $f = $this->buildFactory();
127 $if = $this->buildInputFactory();
130 $form =
$f->standard(
$url, [
131 $if->text(
"label",
"byline"),
134 $r = $this->getDefaultRenderer();
135 $html = $this->brutallyTrimHTML($r->render($form));
137 $expected = $this->brutallyTrimHTML(
' 138 <form role="form" class="il-standard-form form-horizontal" enctype="multipart/form-data" method="post" novalidate="novalidate"> 139 <div class="il-standard-form-header clearfix"> 140 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 142 <div class="form-group row"> 143 <label for="id_1" class="control-label col-sm-3">label</label> 144 <div class="col-sm-9"> 145 <input id="id_1" type="text" name="form_input_1" class="form-control form-control-sm"/> 146 <div class="help-block">byline</div> 149 <div class="il-standard-form-footer clearfix"> 150 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 154 $this->assertHTMLEquals($expected, $html);
160 $r = $this->getDefaultRenderer();
161 $df =
new Data\Factory();
162 $language = $this->createMock(\ilLanguage::class);
164 ->expects($this->once())
166 ->willReturn(
'testing error message');
168 $refinery = new \ILIAS\Refinery\Factory($df, $language);
177 $fail = $refinery->custom()->constraint(
function ($v) {
179 },
"This is invalid...");
180 $input = $if->text(
"label",
"byline");
182 $input = $input->withAdditionalTransformation($fail);
184 $form =
new Form\Standard($if,
'', [$input]);
186 $request = $this->createMock(ServerRequestInterface::class);
188 ->expects($this->once())
189 ->method(
"getParsedBody")
194 $form = $form->withRequest($request);
195 $this->assertNull($form->getData());
197 $html = $this->brutallyTrimHTML($r->render($form));
198 $expected = $this->brutallyTrimHTML(
' 199 <form role="form" class="il-standard-form form-horizontal" enctype="multipart/form-data" method="post" novalidate="novalidate"> 200 <div class="il-standard-form-header clearfix"> 201 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 204 <div class="help-block alert alert-danger" role="alert">testing error message</div> 206 <div class="form-group row"> 207 <label for="id_1" class="control-label col-sm-3">label</label> 208 <div class="col-sm-9"> 209 <div class="help-block alert alert-danger" role="alert">This is invalid...</div> 210 <input id="id_1" type="text" name="form_input_1" class="form-control form-control-sm" /> 211 <div class="help-block">byline</div> 214 <div class="il-standard-form-footer clearfix"> 215 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 219 $this->assertHTMLEquals($expected, $html);
225 $r = $this->getDefaultRenderer();
226 $df =
new Data\Factory();
227 $language = $this->createMock(\ilLanguage::class);
228 $refinery = new \ILIAS\Refinery\Factory($df, $language);
237 $fail = $refinery->custom()->constraint(
function ($v) {
239 },
"This is a fail on form.");
240 $input = $if->text(
"label",
"byline");
242 $form =
new Form\Standard($if,
'', [$input]);
243 $form = $form->withAdditionalTransformation($fail);
245 $request = $this->createMock(ServerRequestInterface::class);
247 ->expects($this->once())
248 ->method(
"getParsedBody")
253 $form = $form->withRequest($request);
254 $this->assertNull($form->getData());
256 $html = $this->brutallyTrimHTML($r->render($form));
257 $expected = $this->brutallyTrimHTML(
' 258 <form role="form" class="il-standard-form form-horizontal" enctype="multipart/form-data" method="post" novalidate="novalidate"> 259 <div class="il-standard-form-header clearfix"> 260 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 263 <div class="help-block alert alert-danger" role="alert">This is a fail on form.</div> 265 <div class="form-group row"> 266 <label for="id_1" class="control-label col-sm-3">label</label> 267 <div class="col-sm-9"> 268 <input id="id_1" type="text" name="form_input_1" class="form-control form-control-sm" /> 269 <div class="help-block">byline</div> 272 <div class="il-standard-form-footer clearfix"> 273 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 277 $this->assertHTMLEquals($expected, $html);
282 $f = $this->buildFactory();
283 $if = $this->buildInputFactory();
286 $form =
$f->standard(
$url, [$if->text(
"label",
"byline")->withRequired(
true)]);
288 $r = $this->getDefaultRenderer();
289 $html = $this->brutallyTrimHTML($r->render($form));
291 $expected = $this->brutallyTrimHTML(
' 292 <form role="form" class="il-standard-form form-horizontal" enctype="multipart/form-data" action="MY_URL" method="post" novalidate="novalidate"> 293 <div class="il-standard-form-header clearfix"> 294 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 296 <div class="form-group row"> 297 <label for="id_1" class="control-label col-sm-3">label<span class="asterisk">*</span></label> 298 <div class="col-sm-9"> 299 <input id="id_1" type="text" name="form_input_1" class="form-control form-control-sm"/> 300 <div class="help-block">byline</div> 303 <div class="il-standard-form-footer clearfix"> 304 <span class="asterisk">*</span><span class="small"> required_field</span> 306 <div class="il-standard-form-footer clearfix"> 307 <div class="il-standard-form-cmd"><button class="btn btn-default" data-action="">save</button></div> 311 $this->assertHTMLEquals($expected, $html);
Class ChatMainBarProvider .
Provides common functionality for UI tests.