19 declare(strict_types=1);
22 require_once(__DIR__ .
"/../../../../../../../vendor/composer/vendor/autoload.php");
23 require_once(__DIR__ .
"/../../../Base.php");
24 require_once(__DIR__ .
"/CommonFieldRendering.php");
68 $this->child1 = $this->createMock(Input1::class);
69 $this->child2 = $this->createMock(Input2::class);
70 $this->data_factory =
new Data\Factory();
71 $this->
language = $this->createMock(
ILIAS\Language\Language::class);
74 $this->group =
new Group(
78 [$this->child1, $this->child2],
86 $this->assertNotSame($this->child1, $this->child2);
89 ->expects($this->once())
90 ->method(
"withDisabled")
92 ->willReturn($this->child2);
94 ->expects($this->once())
95 ->method(
"withDisabled")
97 ->willReturn($this->child1);
99 $new_group = $this->group->withDisabled(
true);
101 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
102 $this->assertInstanceOf(Group::class, $new_group);
103 $this->assertNotSame($this->group, $new_group);
108 $this->assertNotSame($this->child1, $this->child2);
111 ->expects($this->once())
112 ->method(
"withRequired")
114 ->willReturn($this->child2);
116 ->expects($this->once())
117 ->method(
"withRequired")
119 ->willReturn($this->child1);
121 $new_group = $this->group->withRequired(
true);
123 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
124 $this->assertInstanceOf(Group::class, $new_group);
125 $this->assertNotSame($this->group, $new_group);
130 $this->expectException(InvalidArgumentException::class);
132 $this->group =
new Group(
144 $this->assertNotSame($this->child1, $this->child2);
147 ->expects($this->once())
148 ->method(
"withValue")
150 ->willReturn($this->child2);
152 ->expects($this->once())
153 ->method(
"isClientSideValueOk")
157 ->expects($this->once())
158 ->method(
"withValue")
160 ->willReturn($this->child1);
162 ->expects($this->once())
163 ->method(
"isClientSideValueOk")
167 $new_group = $this->group->withValue([1,2]);
169 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
170 $this->assertInstanceOf(Group::class, $new_group);
171 $this->assertNotSame($this->group, $new_group);
176 $this->assertNotSame($this->child1, $this->child2);
178 $this->group =
new Group(
182 [
"child1" => $this->child1,
"child2" => $this->child2],
188 ->method(
"withValue")
189 ->willReturn($this->child2);
191 ->method(
"isClientSideValueOk")
194 ->method(
"withValue")
195 ->willReturn($this->child1);
197 ->method(
"isClientSideValueOk")
200 $new_group = $this->group->withValue([
"child1" => 1,
"child2" => 2]);
202 $this->assertEquals([
"child1" => $this->child2,
"child2" => $this->child1], $new_group->getInputs());
207 $this->expectException(InvalidArgumentException::class);
209 $this->group->withValue(1);
214 $this->expectException(InvalidArgumentException::class);
216 $this->group->withValue([1]);
221 $this->assertNotSame($this->child1, $this->child2);
224 ->expects($this->once())
229 ->expects($this->once())
234 $vals = $this->group->getValue();
236 $this->assertEquals([
"one",
"two"], $vals);
241 $this->assertNotSame($this->child1, $this->child2);
243 $input_data = $this->createMock(InputData::class);
246 ->expects($this->once())
247 ->method(
"withInput")
249 ->willReturn($this->child2);
251 ->expects($this->once())
252 ->method(
"getContent")
253 ->willReturn($this->data_factory->ok(
"one"));
255 ->expects($this->once())
256 ->method(
"withInput")
258 ->willReturn($this->child1);
260 ->expects($this->once())
261 ->method(
"getContent")
262 ->willReturn($this->data_factory->ok(
"two"));
265 $new_group = $this->group
266 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
function ($v) use (&$called):
string {
268 $this->assertEquals([
"two",
"one"], $v);
271 ->withInput($input_data);
273 $this->assertTrue($called);
274 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
275 $this->assertInstanceOf(Group::class, $new_group);
276 $this->assertNotSame($this->group, $new_group);
277 $this->assertEquals($this->data_factory->ok(
"result"), $new_group->getContent());
282 $this->assertNotSame($this->child1, $this->child2);
284 $input_data = $this->createMock(InputData::class);
287 ->expects($this->once())
288 ->method(
"withInput")
290 ->willReturn($this->child2);
292 ->expects($this->once())
293 ->method(
"getContent")
294 ->willReturn($this->data_factory->error(
""));
296 ->expects($this->once())
297 ->method(
"withInput")
299 ->willReturn($this->child1);
301 ->expects($this->once())
302 ->method(
"getContent")
303 ->willReturn($this->data_factory->ok(
"two"));
305 $i18n =
"THERE IS SOME ERROR IN THIS GROUP";
307 ->expects($this->once())
309 ->with(
"ui_error_in_group")
312 $new_group = $this->group
313 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
function ():
void {
314 $this->fail(
"This should not happen.");
316 ->withInput($input_data);
318 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
319 $this->assertInstanceOf(Group::class, $new_group);
320 $this->assertNotSame($this->group, $new_group);
321 $this->assertTrue($new_group->getContent()->isError());
326 $this->assertNotSame($this->child1, $this->child2);
328 $input_data = $this->createMock(InputData::class);
331 ->method(
"withInput")
332 ->willReturn($this->child2);
334 ->method(
"getContent")
335 ->willReturn($this->data_factory->error(
""));
337 ->method(
"withInput")
338 ->willReturn($this->child1);
340 ->method(
"getContent")
341 ->willReturn($this->data_factory->ok(
"two"));
343 $i18n =
"THERE IS SOME ERROR IN THIS GROUP";
345 ->expects($this->once())
347 ->with(
"ui_error_in_group")
350 $new_group = $this->group
351 ->withInput($input_data);
353 $this->assertTrue($new_group->getContent()->isError());
354 $this->assertEquals($i18n, $new_group->getContent()->error());
368 $this->assertInstanceOf(Ok::class,
$content);
376 $f = $this->getFieldFactory();
378 $f->text(
"input1",
"in 1"),
379 $f->text(
"input2",
"in 2")
381 $label =
'group label';
385 <fieldset
class=
"c-input" data-il-
ui-component=
"text-field-input" data-il-
ui-input-name=
"">
386 <label
for=
"id_1">input1</label>
387 <div
class=
"c-input__field">
388 <input
id=
"id_1" type=
"text" class=
"c-field-text" />
390 <div
class=
"c-input__help-byline">in 1</div>
392 <fieldset
class=
"c-input" data-il-
ui-component=
"text-field-input" data-il-
ui-input-name=
"">
393 <label
for=
"id_2">input2</label>
394 <div
class=
"c-input__field">
395 <input
id=
"id_2" type=
"text" class=
"c-field-text" />
397 <div
class=
"c-input__help-byline">in 2</div>
400 $actual = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($group));
401 $expected = $this->brutallyTrimHTML($expected);
402 $this->assertEquals($expected, $actual);
409 $f = $this->getFieldFactory();
410 $group =
$f->group([],
"LABEL", $bl);
411 $this->assertEquals($bl, $group->
getByline());
416 $f = $this->getFieldFactory();
427 $f = $this->getFieldFactory();
430 $f->text(
"")->withRequired(
true)
value()
Get the encapsulated value.
Interface Observer Contains several chained tasks and infos about them.
language()
description: > Example for rendring a language glyph.