19 declare(strict_types=1);
22 require_once(__DIR__ .
"/../../../../../libs/composer/vendor/autoload.php");
23 require_once(__DIR__ .
"/../../../Base.php");
65 $this->child1 = $this->createMock(Input1::class);
66 $this->child2 = $this->createMock(Input2::class);
67 $this->data_factory =
new Data\Factory();
68 $this->
language = $this->createMock(ilLanguage::class);
71 $this->group =
new Group(
75 [$this->child1, $this->child2],
83 $this->assertNotSame($this->child1, $this->child2);
86 ->expects($this->once())
87 ->method(
"withDisabled")
89 ->willReturn($this->child2);
91 ->expects($this->once())
92 ->method(
"withDisabled")
94 ->willReturn($this->child1);
96 $new_group = $this->group->withDisabled(
true);
98 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
99 $this->assertInstanceOf(Group::class, $new_group);
100 $this->assertNotSame($this->group, $new_group);
105 $this->assertNotSame($this->child1, $this->child2);
108 ->expects($this->once())
109 ->method(
"withRequired")
111 ->willReturn($this->child2);
113 ->expects($this->once())
114 ->method(
"withRequired")
116 ->willReturn($this->child1);
118 $new_group = $this->group->withRequired(
true);
120 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
121 $this->assertInstanceOf(Group::class, $new_group);
122 $this->assertNotSame($this->group, $new_group);
127 $this->expectException(InvalidArgumentException::class);
129 $this->group =
new Group(
141 $this->assertNotSame($this->child1, $this->child2);
144 ->expects($this->once())
145 ->method(
"withValue")
147 ->willReturn($this->child2);
149 ->expects($this->once())
150 ->method(
"isClientSideValueOk")
154 ->expects($this->once())
155 ->method(
"withValue")
157 ->willReturn($this->child1);
159 ->expects($this->once())
160 ->method(
"isClientSideValueOk")
164 $new_group = $this->group->withValue([1,2]);
166 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
167 $this->assertInstanceOf(Group::class, $new_group);
168 $this->assertNotSame($this->group, $new_group);
173 $this->assertNotSame($this->child1, $this->child2);
175 $this->group =
new Group(
179 [
"child1" => $this->child1,
"child2" => $this->child2],
185 ->method(
"withValue")
186 ->willReturn($this->child2);
188 ->method(
"isClientSideValueOk")
191 ->method(
"withValue")
192 ->willReturn($this->child1);
194 ->method(
"isClientSideValueOk")
197 $new_group = $this->group->withValue([
"child1" => 1,
"child2" => 2]);
199 $this->assertEquals([
"child1" => $this->child2,
"child2" => $this->child1], $new_group->getInputs());
204 $this->expectException(InvalidArgumentException::class);
206 $this->group->withValue(1);
211 $this->expectException(InvalidArgumentException::class);
213 $this->group->withValue([1]);
218 $this->assertNotSame($this->child1, $this->child2);
221 ->expects($this->once())
226 ->expects($this->once())
231 $vals = $this->group->getValue();
233 $this->assertEquals([
"one",
"two"], $vals);
238 $this->assertNotSame($this->child1, $this->child2);
240 $input_data = $this->createMock(InputData::class);
243 ->expects($this->once())
244 ->method(
"withInput")
246 ->willReturn($this->child2);
248 ->expects($this->once())
249 ->method(
"getContent")
250 ->willReturn($this->data_factory->ok(
"one"));
252 ->expects($this->once())
253 ->method(
"withInput")
255 ->willReturn($this->child1);
257 ->expects($this->once())
258 ->method(
"getContent")
259 ->willReturn($this->data_factory->ok(
"two"));
262 $new_group = $this->group
263 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
function ($v) use (&$called):
string {
265 $this->assertEquals([
"two",
"one"], $v);
268 ->withInput($input_data);
270 $this->assertTrue($called);
271 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
272 $this->assertInstanceOf(Group::class, $new_group);
273 $this->assertNotSame($this->group, $new_group);
274 $this->assertEquals($this->data_factory->ok(
"result"), $new_group->getContent());
279 $this->assertNotSame($this->child1, $this->child2);
281 $input_data = $this->createMock(InputData::class);
284 ->expects($this->once())
285 ->method(
"withInput")
287 ->willReturn($this->child2);
289 ->expects($this->once())
290 ->method(
"getContent")
291 ->willReturn($this->data_factory->error(
""));
293 ->expects($this->once())
294 ->method(
"withInput")
296 ->willReturn($this->child1);
298 ->expects($this->once())
299 ->method(
"getContent")
300 ->willReturn($this->data_factory->ok(
"two"));
302 $i18n =
"THERE IS SOME ERROR IN THIS GROUP";
304 ->expects($this->once())
306 ->with(
"ui_error_in_group")
309 $new_group = $this->group
310 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
function ():
void {
311 $this->fail(
"This should not happen.");
313 ->withInput($input_data);
315 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
316 $this->assertInstanceOf(Group::class, $new_group);
317 $this->assertNotSame($this->group, $new_group);
318 $this->assertTrue($new_group->getContent()->isError());
323 $this->assertNotSame($this->child1, $this->child2);
325 $input_data = $this->createMock(InputData::class);
328 ->method(
"withInput")
329 ->willReturn($this->child2);
331 ->method(
"getContent")
332 ->willReturn($this->data_factory->error(
""));
334 ->method(
"withInput")
335 ->willReturn($this->child1);
337 ->method(
"getContent")
338 ->willReturn($this->data_factory->ok(
"two"));
340 $i18n =
"THERE IS SOME ERROR IN THIS GROUP";
342 ->expects($this->once())
344 ->with(
"ui_error_in_group")
347 $new_group = $this->group
348 ->withInput($input_data);
350 $this->assertTrue($new_group->getContent()->isError());
351 $this->assertEquals($i18n, $new_group->getContent()->error());
365 $this->assertInstanceOf(Ok::class,
$content);
375 $this->getRefinery(),
382 $f = $this->getFieldFactory();
384 $f->text(
"input1",
"in 1"),
385 $f->text(
"input2",
"in 2")
387 $label =
'group label';
391 <div
class=
"form-group row">
392 <label
for=
"id_1" class=
"control-label col-sm-4 col-md-3 col-lg-2">input1</label>
393 <div
class=
"col-sm-8 col-md-9 col-lg-10">
394 <input
id=
"id_1" type=
"text" class=
"form-control form-control-sm" />
395 <div
class=
"help-block">in 1</div>
398 <div
class=
"form-group row">
399 <label
for=
"id_2" class=
"control-label col-sm-4 col-md-3 col-lg-2">input2</label>
400 <div
class=
"col-sm-8 col-md-9 col-lg-10">
401 <input
id=
"id_2" type=
"text" class=
"form-control form-control-sm" />
402 <div
class=
"help-block">in 2</div>
406 $actual = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($group));
407 $expected = $this->brutallyTrimHTML($expected);
408 $this->assertEquals($expected, $actual);
415 $f = $this->getFieldFactory();
416 $group =
$f->group([],
"LABEL", $bl);
417 $this->assertEquals($bl, $group->
getByline());
422 $f = $this->getFieldFactory();
433 $f = $this->getFieldFactory();
436 $f->text(
"")->withRequired(
true)
value()
Get the encapsulated value.
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...