Test on form implementation.
More...
Test on form implementation.
Definition at line 71 of file FormTest.php.
◆ buildButtonFactory()
FormTest::buildButtonFactory |
( |
| ) |
|
|
protected |
◆ buildDataFactory()
FormTest::buildDataFactory |
( |
| ) |
|
Definition at line 114 of file FormTest.php.
116 return new \ILIAS\Data\Factory;
◆ buildFactory()
FormTest::buildFactory |
( |
| ) |
|
|
protected |
◆ buildInputFactory()
FormTest::buildInputFactory |
( |
| ) |
|
|
protected |
Definition at line 79 of file FormTest.php.
References language().
81 $df =
new Data\Factory();
82 $this->
language = $this->createMock(\ilLanguage::class);
Class ChatMainBarProvider .
◆ buildTransformation()
FormTest::buildTransformation |
( |
\Closure |
$trafo | ) |
|
|
protected |
Definition at line 98 of file FormTest.php.
100 $dataFactory =
new Data\Factory();
101 $language = $this->createMock(\ilLanguage::class);
102 $refinery = new \ILIAS\Refinery\Factory($dataFactory, $language);
104 return $refinery->custom()->transformation($trafo);
◆ getUIFactory()
FormTest::getUIFactory |
( |
| ) |
|
◆ inputMock()
Definition at line 419 of file FormTest.php.
References $config.
423 ->getMockBuilder(InputInternal::class)
424 ->setMethods([
"getName",
"withNameFrom",
"withInput",
"getContent",
"getLabel",
"withLabel",
"getByline",
"withByline",
"isRequired",
"withRequired",
"isDisabled",
"withDisabled",
"getValue",
"withValue",
"getError",
"withError",
"withAdditionalTransformation",
"withAdditionalConstraint",
"getUpdateOnLoadCode",
"getCanonicalName",
"withOnLoadCode",
"withAdditionalOnLoadCode",
"getOnLoadCode",
"withOnUpdate",
"appendOnUpdate",
"withResetTriggeredSignals",
"getTriggeredSignals"])
425 ->setMockClassName(
"Mock_InputNo" . ($no++))
◆ test_extractPostData()
FormTest::test_extractPostData |
( |
| ) |
|
Definition at line 151 of file FormTest.php.
154 $request = $this->createMock(ServerRequestInterface::class);
156 ->expects($this->once())
157 ->method(
"getParsedBody")
159 $input_data = $form->_extractPostData($request);
160 $this->assertInstanceOf(InputData::class, $input_data);
◆ test_getData()
FormTest::test_getData |
( |
| ) |
|
Definition at line 244 of file FormTest.php.
247 $request = $this->createMock(ServerRequestInterface::class);
249 ->expects($this->once())
250 ->method(
"getParsedBody")
255 ->expects($this->once())
256 ->method(
"getContent")
257 ->willReturn($df->ok(1));
259 ->expects($this->once())
260 ->method(
"withInput")
261 ->willReturn($input_1);
265 ->expects($this->once())
266 ->method(
"getContent")
267 ->willReturn($df->ok(2));
269 ->expects($this->once())
270 ->method(
"withInput")
271 ->willReturn($input_2);
274 $form->setInputs([$input_1, $input_2]);
275 $form = $form->withRequest($request);
276 $this->assertEquals([1, 2], $form->getData());
◆ test_getData_faulty()
FormTest::test_getData_faulty |
( |
| ) |
|
Definition at line 316 of file FormTest.php.
References language().
319 $request = $this->createMock(ServerRequestInterface::class);
321 ->expects($this->once())
322 ->method(
"getParsedBody")
327 ->expects($this->once())
328 ->method(
"getContent")
329 ->willReturn($df->error(
"error"));
331 ->expects($this->once())
332 ->method(
"withInput")
333 ->willReturn($input_1);
337 ->expects($this->once())
338 ->method(
"getContent")
339 ->willReturn($df->ok(2));
341 ->expects($this->once())
342 ->method(
"withInput")
343 ->willReturn($input_2);
346 $form->setInputs([
"foo" => $input_1,
"bar" => $input_2]);
348 $i18n =
"THERE IS SOME ERROR IN THIS GROUP";
350 ->expects($this->once())
352 ->with(
"ui_error_in_group")
356 $form = $form->withRequest($request);
357 $this->assertEquals(null, null);
◆ test_getData_respects_keys()
FormTest::test_getData_respects_keys |
( |
| ) |
|
Definition at line 280 of file FormTest.php.
283 $request = $this->createMock(ServerRequestInterface::class);
285 ->expects($this->once())
286 ->method(
"getParsedBody")
291 ->expects($this->once())
292 ->method(
"getContent")
293 ->willReturn($df->ok(1));
295 ->expects($this->once())
296 ->method(
"withInput")
297 ->willReturn($input_1);
301 ->expects($this->once())
302 ->method(
"getContent")
303 ->willReturn($df->ok(2));
305 ->expects($this->once())
306 ->method(
"withInput")
307 ->willReturn($input_2);
310 $form->setInputs([
"foo" => $input_1,
"bar" => $input_2]);
311 $form = $form->withRequest($request);
312 $this->assertEquals([
"foo" => 1,
"bar" => 2], $form->getData());
◆ test_getInputs()
FormTest::test_getInputs |
( |
| ) |
|
Definition at line 120 of file FormTest.php.
References Vendor\Package\$f, ILIAS\GlobalScreen\Provider\$if, and FixedNameSource\$name.
126 $inputs = [
$if->text(
""),
$if->text(
"")];
130 $inputs = $form->getInputs();
131 $this->assertEquals(count($inputs), count($inputs));
133 foreach ($inputs as $input) {
134 $name = $input->getName();
135 $name_source->name =
$name;
138 $this->assertIsString(
$name);
141 $input = array_shift($inputs);
142 $this->assertEquals($input->withNameFrom($name_source), $input);
145 $this->assertNotContains(
$name, $seen_names);
146 $seen_names[] =
$name;
◆ test_nameInputs_respects_keys()
FormTest::test_nameInputs_respects_keys |
( |
| ) |
|
Definition at line 404 of file FormTest.php.
References ILIAS\GlobalScreen\Provider\$if.
409 "foo" =>
$if->text(
""),
414 $form->setInputs($inputs);
415 $named_inputs = $form->getInputs();
416 $this->assertEquals(array_keys($inputs), array_keys($named_inputs));
◆ test_withAdditionalTransformation()
FormTest::test_withAdditionalTransformation |
( |
| ) |
|
Definition at line 361 of file FormTest.php.
364 $request = $this->createMock(ServerRequestInterface::class);
366 ->expects($this->once())
367 ->method(
"getParsedBody")
372 ->expects($this->once())
373 ->method(
"getContent")
374 ->willReturn($df->ok(1));
376 ->expects($this->once())
377 ->method(
"withInput")
378 ->willReturn($input_1);
382 ->expects($this->once())
383 ->method(
"getContent")
384 ->willReturn($df->ok(2));
386 ->expects($this->once())
387 ->method(
"withInput")
388 ->willReturn($input_2);
391 $form->setInputs([$input_1, $input_2]);
394 return "transformed";
397 $this->assertNotSame($form2, $form);
398 $form2 = $form2->withRequest($request);
400 $this->assertEquals(
"transformed", $form2->getData());
◆ test_withRequest()
FormTest::test_withRequest |
( |
| ) |
|
Definition at line 164 of file FormTest.php.
167 $request = $this->createMock(ServerRequestInterface::class);
168 $input_data = $this->createMock(InputData::class);
172 ->expects($this->once())
173 ->method(
"withInput")
175 ->willReturn($input_1);
177 ->expects($this->once())
178 ->method(
"getContent")
179 ->willReturn($df->ok(0));
183 ->expects($this->once())
184 ->method(
"withInput")
186 ->willReturn($input_2);
188 ->expects($this->once())
189 ->method(
"getContent")
190 ->willReturn($df->ok(0));
193 $form->setInputs([$input_1, $input_2]);
194 $form->input_data = $input_data;
196 $form2 = $form->withRequest($request);
198 $this->assertNotSame($form2, $form);
199 $this->assertInstanceOf(Form::class, $form2);
200 $this->assertEquals([$input_1, $input_2], $form2->getInputs());
◆ test_withRequest_respects_keys()
FormTest::test_withRequest_respects_keys |
( |
| ) |
|
Definition at line 204 of file FormTest.php.
207 $request = $this->createMock(ServerRequestInterface::class);
208 $input_data = $this->createMock(InputData::class);
212 ->expects($this->once())
213 ->method(
"withInput")
215 ->willReturn($input_1);
217 ->expects($this->once())
218 ->method(
"getContent")
219 ->willReturn($df->ok(0));
223 ->expects($this->once())
224 ->method(
"withInput")
226 ->willReturn($input_2);
228 ->expects($this->once())
229 ->method(
"getContent")
230 ->willReturn($df->ok(0));
233 $form->setInputs([
"foo" => $input_1,
"bar" => $input_2]);
234 $form->input_data = $input_data;
236 $form2 = $form->withRequest($request);
238 $this->assertNotSame($form2, $form);
239 $this->assertInstanceOf(Form::class, $form2);
240 $this->assertEquals([
"foo" => $input_1,
"bar" => $input_2], $form2->getInputs());
The documentation for this class was generated from the following file: