◆ buildFactory()
SwitchableGroupInputTest::buildFactory |
( |
| ) |
|
|
protected |
◆ setUp()
SwitchableGroupInputTest::setUp |
( |
| ) |
|
Definition at line 70 of file SwitchableGroupInputTest.php.
References ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\UI\Implementation\Component\Input\InputInternal\withNameFrom().
72 $this->nested_child = $this->createMock(
I\
Input\Field\FormInputInternal::class);
73 $this->child1 = $this->createMock(Group1::class);
74 $this->child2 = $this->createMock(Group2::class);
75 $this->data_factory =
new Data\Factory();
76 $this->
refinery =
new Refinery($this->data_factory, $this->createMock(ilLanguage::class));
77 $this->
lng = $this->createMock(ilLanguage::class);
80 ->method(
"withNameFrom")
81 ->willReturn($this->nested_child);
84 ->method(
"withNameFrom")
85 ->willReturn($this->child1);
88 ->willReturn([$this->nested_child]);
91 ->method(
"withNameFrom")
92 ->willReturn($this->child2);
95 ->willReturn([$this->nested_child]);
101 [
"child1" => $this->child1,
"child2" => $this->child2],
105 public function getNewName(): string
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
◆ testErrorIsI18NOnError()
SwitchableGroupInputTest::testErrorIsI18NOnError |
( |
| ) |
|
Definition at line 340 of file SwitchableGroupInputTest.php.
References ILIAS\Repository\lng().
342 $this->assertNotSame($this->child1, $this->child2);
344 $input_data = $this->createMock(InputData::class);
347 ->expects($this->once())
350 ->willReturn(
"child2");
353 ->method(
"withInput")
354 ->willReturn($this->child2);
356 ->method(
"getContent")
357 ->willReturn($this->data_factory->error(
""));
359 $i18n =
"THERE IS SOME ERROR IN THIS GROUP";
361 ->expects($this->once())
363 ->with(
"ui_error_in_group")
367 ->withInput($input_data);
◆ testGroupForwardsValuesOnGetValue()
SwitchableGroupInputTest::testGroupForwardsValuesOnGetValue |
( |
| ) |
|
Definition at line 223 of file SwitchableGroupInputTest.php.
225 $this->assertNotSame($this->child1, $this->child2);
228 ->expects($this->once())
233 ->expects($this->never())
234 ->method(
"getValue");
236 $vals = $this->switchable_group->withValue(
"child1")->getValue();
238 $this->assertEquals([
"child1",
"one"], $vals);
◆ testGroupOnlyDoesAcceptKeyOnly()
SwitchableGroupInputTest::testGroupOnlyDoesAcceptKeyOnly |
( |
| ) |
|
Definition at line 209 of file SwitchableGroupInputTest.php.
211 $new_group = $this->switchable_group->withValue(
"child1");
212 $this->assertEquals([
"child1" => $this->child1,
"child2" => $this->child2], $new_group->getInputs());
213 $this->assertInstanceOf(SwitchableGroup::class, $new_group);
214 $this->assertNotSame($this->switchable_group, $new_group);
◆ testGroupOnlyDoesNoAcceptArrayValuesWithWrongLength()
SwitchableGroupInputTest::testGroupOnlyDoesNoAcceptArrayValuesWithWrongLength |
( |
| ) |
|
Definition at line 203 of file SwitchableGroupInputTest.php.
205 $this->expectException(InvalidArgumentException::class);
206 $this->switchable_group->withValue([1, 2, 3]);
◆ testGroupOnlyDoesNotAcceptInvalidKey()
SwitchableGroupInputTest::testGroupOnlyDoesNotAcceptInvalidKey |
( |
| ) |
|
Definition at line 217 of file SwitchableGroupInputTest.php.
219 $this->expectException(InvalidArgumentException::class);
220 $this->switchable_group->withValue(
"child3");
◆ testGroupOnlyDoesNotAcceptNonArrayValue()
SwitchableGroupInputTest::testGroupOnlyDoesNotAcceptNonArrayValue |
( |
| ) |
|
Definition at line 197 of file SwitchableGroupInputTest.php.
199 $this->expectException(InvalidArgumentException::class);
200 $this->switchable_group->withValue(null);
◆ testRender()
SwitchableGroupInputTest::testRender |
( |
| ) |
|
Definition at line 405 of file SwitchableGroupInputTest.php.
References Vendor\Package\$f.
411 $group1 =
$f->group([
412 "field_1" =>
$f->text(
"f",
"some field")
414 $group2 =
$f->group([
415 "field_2" =>
$f->text(
"f2",
"some other field")
418 $sg =
$f->switchableGroup(
428 $html = $r->render($sg);
430 <div
class=
"form-group row">
431 <label
class=
"control-label col-sm-4 col-md-3 col-lg-2">label</label>
432 <div
class=
"col-sm-8 col-md-9 col-lg-10">
433 <div
id=
"id_1" class=
"il-input-radio">
434 <div
class=
"form-control form-control-sm il-input-radiooption">
435 <input type=
"radio" id=
"id_1_g1_opt" name=
"" value=
"g1" /><label
for=
"id_1_g1_opt"></label>
436 <div
class=
"form-group row">
437 <label
for=
"id_2" class=
"control-label col-sm-4 col-md-3 col-lg-2">f</label>
438 <div
class=
"col-sm-8 col-md-9 col-lg-10">
439 <input
id=
"id_2" type=
"text" name=
"" class=
"form-control form-control-sm" />
440 <div
class=
"help-block">some field</div>
444 <div
class=
"form-control form-control-sm il-input-radiooption">
445 <input type=
"radio" id=
"id_1_g2_opt" name=
"" value=
"g2" /><label
for=
"id_1_g2_opt"></label>
446 <div
class=
"form-group row">
447 <label
for=
"id_3" class=
"control-label col-sm-4 col-md-3 col-lg-2">f2</label>
448 <div
class=
"col-sm-8 col-md-9 col-lg-10">
449 <input
id=
"id_3" type=
"text" name=
"" class=
"form-control form-control-sm" />
450 <div
class=
"help-block">some other field</div>
455 <div
class=
"help-block">byline</div>
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
◆ testRenderWithValue()
SwitchableGroupInputTest::testRenderWithValue |
( |
SG |
$sg | ) |
|
testRender
Definition at line 470 of file SwitchableGroupInputTest.php.
473 $html = $r->render($sg->withValue(
'g2'));
475 <div
class=
"form-group row">
476 <label
class=
"control-label col-sm-4 col-md-3 col-lg-2">label</label>
477 <div
class=
"col-sm-8 col-md-9 col-lg-10">
478 <div
id=
"id_1" class=
"il-input-radio">
479 <div
class=
"form-control form-control-sm il-input-radiooption">
480 <input type=
"radio" id=
"id_1_g1_opt" name=
"" value=
"g1" /><label
for=
"id_1_g1_opt"></label>
481 <div
class=
"form-group row">
482 <label
for=
"id_2" class=
"control-label col-sm-4 col-md-3 col-lg-2">f</label>
483 <div
class=
"col-sm-8 col-md-9 col-lg-10">
484 <input
id=
"id_2" type=
"text" name=
"" class=
"form-control form-control-sm" />
485 <div
class=
"help-block">some field</div>
489 <div
class=
"form-control form-control-sm il-input-radiooption">
490 <input type=
"radio" id=
"id_1_g2_opt" name=
"" value=
"g2" checked=
"checked" /><label
for=
"id_1_g2_opt"></label>
491 <div
class=
"form-group row">
492 <label
for=
"id_3" class=
"control-label col-sm-4 col-md-3 col-lg-2">f2</label>
493 <div
class=
"col-sm-8 col-md-9 col-lg-10">
494 <input
id=
"id_3" type=
"text" name=
"" class=
"form-control form-control-sm" />
495 <div
class=
"help-block">some other field</div>
500 <div
class=
"help-block">byline</div>
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
◆ testRenderWithValueByIndex()
SwitchableGroupInputTest::testRenderWithValueByIndex |
( |
| ) |
|
Definition at line 511 of file SwitchableGroupInputTest.php.
References Vendor\Package\$f.
517 $group1 =
$f->group([
518 "field_1" =>
$f->text(
"f",
"some field")
520 $group2 =
$f->group([
521 "field_2" =>
$f->text(
"f2",
"some other field")
523 $empty_group_title =
'empty group, the title';
524 $empty_group_byline =
'empty group, the byline';
525 $group3 =
$f->group([], $empty_group_title, $empty_group_byline);
527 $sg =
$f->switchableGroup([$group1, $group2, $group3], $label, $byline);
529 $html = $r->render($sg->withValue(
'1'));
532 <div
class=
"form-group row">
533 <label
class=
"control-label col-sm-4 col-md-3 col-lg-2">label</label>
534 <div
class=
"col-sm-8 col-md-9 col-lg-10">
535 <div
id=
"id_1" class=
"il-input-radio">
536 <div
class=
"form-control form-control-sm il-input-radiooption">
537 <input type=
"radio" id=
"id_1_0_opt" name=
"" value=
"0" /><label
for=
"id_1_0_opt"></label>
538 <div
class=
"form-group row">
539 <label
for=
"id_2" class=
"control-label col-sm-4 col-md-3 col-lg-2">f</label>
540 <div
class=
"col-sm-8 col-md-9 col-lg-10">
541 <input
id=
"id_2" type=
"text" name=
"" class=
"form-control form-control-sm" />
542 <div
class=
"help-block">some field</div>
546 <div
class=
"form-control form-control-sm il-input-radiooption">
547 <input type=
"radio" id=
"id_1_1_opt" name=
"" value=
"1" checked=
"checked" /><label
for=
"id_1_1_opt"></label>
548 <div
class=
"form-group row">
549 <label
for=
"id_3" class=
"control-label col-sm-4 col-md-3 col-lg-2">f2</label>
550 <div
class=
"col-sm-8 col-md-9 col-lg-10">
551 <input
id=
"id_3" type=
"text" name=
"" class=
"form-control form-control-sm" />
552 <div
class=
"help-block">some other field</div>
557 <div
class=
"form-control form-control-sm il-input-radiooption">
558 <input type=
"radio" id=
"id_1_2_opt" name=
"" value=
"2" /><label
for=
"id_1_2_opt">empty group, the title</label>
559 <div
class=
"help-block">empty group, the byline</div>
562 <div
class=
"help-block">byline</div>
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
◆ testSwitchableGroupForwardsValuesOnWithValue()
SwitchableGroupInputTest::testSwitchableGroupForwardsValuesOnWithValue |
( |
| ) |
|
Definition at line 177 of file SwitchableGroupInputTest.php.
179 $this->assertNotSame($this->child1, $this->child2);
182 ->expects($this->never())
183 ->method(
"withValue");
185 ->expects($this->once())
186 ->method(
"withValue")
188 ->willReturn($this->child2);
190 $new_group = $this->switchable_group->withValue([
"child2", 2]);
192 $this->assertEquals([
"child1" => $this->child1,
"child2" => $this->child2], $new_group->getInputs());
193 $this->assertInstanceOf(SwitchableGroup::class, $new_group);
194 $this->assertNotSame($this->switchable_group, $new_group);
◆ testSwitchableGroupMayOnlyHaveGroupChildren()
SwitchableGroupInputTest::testSwitchableGroupMayOnlyHaveGroupChildren |
( |
| ) |
|
◆ testWithDisabledDisablesChildren()
SwitchableGroupInputTest::testWithDisabledDisablesChildren |
( |
| ) |
|
Definition at line 123 of file SwitchableGroupInputTest.php.
125 $this->assertNotSame($this->child1, $this->child2);
128 ->expects($this->once())
129 ->method(
"withDisabled")
131 ->willReturn($this->child2);
133 ->expects($this->once())
134 ->method(
"withDisabled")
136 ->willReturn($this->child1);
138 $new_group = $this->switchable_group->withDisabled(
true);
140 $this->assertEquals([
"child1" => $this->child2,
"child2" => $this->child1], $new_group->getInputs());
141 $this->assertInstanceOf(SwitchableGroup::class, $new_group);
142 $this->assertNotSame($this->switchable_group, $new_group);
◆ testWithInputCallsChildrenAndAppliesOperations()
SwitchableGroupInputTest::testWithInputCallsChildrenAndAppliesOperations |
( |
| ) |
|
Definition at line 241 of file SwitchableGroupInputTest.php.
References ILIAS\Repository\refinery().
243 $this->assertNotSame($this->child1, $this->child2);
245 $input_data = $this->createMock(InputData::class);
248 ->expects($this->once())
251 ->willReturn(
"child1");
253 $expected_result = $this->data_factory->ok(
"one");
256 ->expects($this->once())
257 ->method(
"withInput")
259 ->willReturn($this->child1);
261 ->expects($this->once())
262 ->method(
"getContent")
264 ->willReturn($expected_result);
266 ->expects($this->once())
267 ->method(
"getContent")
269 ->willReturn($expected_result);
271 ->expects($this->never())
272 ->method(
"withInput");
274 ->expects($this->never())
275 ->method(
"getContent");
278 $new_group = $this->switchable_group
279 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
function ($v) use (&$called):
string {
281 $this->assertEquals([
"child1", [
"one"]], $v);
284 ->withInput($input_data);
286 $this->assertTrue($called);
287 $this->assertEquals([
"child1" => $this->child1,
"child2" => $this->child2], $new_group->getInputs());
288 $this->assertInstanceOf(SwitchableGroup::class, $new_group);
289 $this->assertNotSame($this->switchable_group, $new_group);
290 $this->assertEquals($this->data_factory->ok(
"result"), $new_group->getContent());
◆ testWithInputDoesNotAcceptUnknownKeys()
SwitchableGroupInputTest::testWithInputDoesNotAcceptUnknownKeys |
( |
| ) |
|
Definition at line 373 of file SwitchableGroupInputTest.php.
References ILIAS\Repository\refinery().
375 $this->expectException(InvalidArgumentException::class);
377 $input_data = $this->createMock(InputData::class);
380 ->expects($this->once())
386 ->expects($this->never())
387 ->method(
"withInput");
389 ->expects($this->never())
390 ->method(
"getContent");
392 ->expects($this->never())
393 ->method(
"withInput");
395 ->expects($this->never())
396 ->method(
"getContent");
398 $this->switchable_group
399 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
function () use (&$called):
void {
400 $this->fail(
"This should not happen.");
402 ->withInput($input_data);
◆ testWithInputDoesNotApplyOperationsOnError()
SwitchableGroupInputTest::testWithInputDoesNotApplyOperationsOnError |
( |
| ) |
|
Definition at line 293 of file SwitchableGroupInputTest.php.
References ILIAS\Repository\lng(), and ILIAS\Repository\refinery().
295 $this->assertNotSame($this->child1, $this->child2);
297 $input_data = $this->createMock(InputData::class);
300 ->expects($this->once())
303 ->willReturn(
"child2");
306 ->expects($this->never())
307 ->method(
"withInput");
309 ->expects($this->never())
310 ->method(
"getContent");
312 ->expects($this->once())
313 ->method(
"withInput")
315 ->willReturn($this->child2);
317 ->expects($this->once())
318 ->method(
"getContent")
319 ->willReturn($this->data_factory->error(
""));
321 $i18n =
"THERE IS SOME ERROR IN THIS GROUP";
323 ->expects($this->once())
325 ->with(
"ui_error_in_group")
328 $new_group = $this->switchable_group
329 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
function ():
void {
330 $this->fail(
"This should not happen.");
332 ->withInput($input_data);
334 $this->assertEquals([
"child1" => $this->child1,
"child2" => $this->child2], $new_group->getInputs());
335 $this->assertInstanceOf(SwitchableGroup::class, $new_group);
336 $this->assertNotSame($this->switchable_group, $new_group);
337 $this->assertTrue($new_group->getContent()->isError());
◆ testWithRequiredDoesNotRequire()
SwitchableGroupInputTest::testWithRequiredDoesNotRequire |
( |
| ) |
|
Definition at line 145 of file SwitchableGroupInputTest.php.
147 $this->assertNotSame($this->child1, $this->child2);
150 ->expects($this->never())
151 ->method(
"withRequired");
153 ->expects($this->never())
154 ->method(
"withRequired");
156 $new_group = $this->switchable_group->withRequired(
true);
158 $this->assertEquals([
"child1" => $this->child1,
"child2" => $this->child2], $new_group->getInputs());
159 $this->assertInstanceOf(SwitchableGroup::class, $new_group);
160 $this->assertNotSame($this->switchable_group, $new_group);
◆ $child1
SwitchableGroupInputTest::$child1 |
|
protected |
◆ $child2
SwitchableGroupInputTest::$child2 |
|
protected |
◆ $data_factory
Data Factory SwitchableGroupInputTest::$data_factory |
|
protected |
◆ $group
◆ $lng
SwitchableGroupInputTest::$lng |
|
protected |
◆ $nested_child
SwitchableGroupInputTest::$nested_child |
|
protected |
◆ $refinery
Refinery SwitchableGroupInputTest::$refinery |
|
protected |
◆ $switchable_group
ILIAS UI Component Input Field Group SwitchableGroupInputTest::$switchable_group |
|
protected |
The documentation for this class was generated from the following file: