18 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../../libs/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../../Base.php");
64 $this->child1 = $this->createMock(Input1::class);
65 $this->child2 = $this->createMock(Input2::class);
66 $this->data_factory =
new Data\Factory();
67 $this->
language = $this->createMock(ilLanguage::class);
70 $this->group =
new Group(
74 [$this->child1, $this->child2],
82 $this->assertNotSame($this->child1, $this->child2);
85 ->expects($this->once())
86 ->method(
"withDisabled")
88 ->willReturn($this->child2);
90 ->expects($this->once())
91 ->method(
"withDisabled")
93 ->willReturn($this->child1);
95 $new_group = $this->group->withDisabled(
true);
97 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
98 $this->assertInstanceOf(Group::class, $new_group);
99 $this->assertNotSame($this->group, $new_group);
104 $this->assertNotSame($this->child1, $this->child2);
107 ->expects($this->once())
108 ->method(
"withRequired")
110 ->willReturn($this->child2);
112 ->expects($this->once())
113 ->method(
"withRequired")
115 ->willReturn($this->child1);
117 $new_group = $this->group->withRequired(
true);
119 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
120 $this->assertInstanceOf(Group::class, $new_group);
121 $this->assertNotSame($this->group, $new_group);
126 $this->expectException(InvalidArgumentException::class);
128 $this->group =
new Group(
140 $this->assertNotSame($this->child1, $this->child2);
143 ->expects($this->once())
144 ->method(
"withValue")
146 ->willReturn($this->child2);
148 ->expects($this->once())
149 ->method(
"isClientSideValueOk")
153 ->expects($this->once())
154 ->method(
"withValue")
156 ->willReturn($this->child1);
158 ->expects($this->once())
159 ->method(
"isClientSideValueOk")
163 $new_group = $this->group->withValue([1,2]);
165 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
166 $this->assertInstanceOf(Group::class, $new_group);
167 $this->assertNotSame($this->group, $new_group);
172 $this->assertNotSame($this->child1, $this->child2);
174 $this->group =
new Group(
178 [
"child1" => $this->child1,
"child2" => $this->child2],
184 ->method(
"withValue")
185 ->willReturn($this->child2);
187 ->method(
"isClientSideValueOk")
190 ->method(
"withValue")
191 ->willReturn($this->child1);
193 ->method(
"isClientSideValueOk")
196 $new_group = $this->group->withValue([
"child1" => 1,
"child2" => 2]);
198 $this->assertEquals([
"child1" => $this->child2,
"child2" => $this->child1], $new_group->getInputs());
203 $this->expectException(InvalidArgumentException::class);
205 $this->group->withValue(1);
210 $this->expectException(InvalidArgumentException::class);
212 $this->group->withValue([1]);
217 $this->assertNotSame($this->child1, $this->child2);
220 ->expects($this->once())
225 ->expects($this->once())
230 $vals = $this->group->getValue();
232 $this->assertEquals([
"one",
"two"], $vals);
237 $this->assertNotSame($this->child1, $this->child2);
239 $input_data = $this->createMock(InputData::class);
242 ->expects($this->once())
243 ->method(
"withInput")
245 ->willReturn($this->child2);
247 ->expects($this->once())
248 ->method(
"getContent")
249 ->willReturn($this->data_factory->ok(
"one"));
251 ->expects($this->once())
252 ->method(
"withInput")
254 ->willReturn($this->child1);
256 ->expects($this->once())
257 ->method(
"getContent")
258 ->willReturn($this->data_factory->ok(
"two"));
261 $new_group = $this->group
262 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
function ($v) use (&$called):
string {
264 $this->assertEquals([
"two",
"one"], $v);
267 ->withInput($input_data);
269 $this->assertTrue($called);
270 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
271 $this->assertInstanceOf(Group::class, $new_group);
272 $this->assertNotSame($this->group, $new_group);
273 $this->assertEquals($this->data_factory->ok(
"result"), $new_group->getContent());
278 $this->assertNotSame($this->child1, $this->child2);
280 $input_data = $this->createMock(InputData::class);
283 ->expects($this->once())
284 ->method(
"withInput")
286 ->willReturn($this->child2);
288 ->expects($this->once())
289 ->method(
"getContent")
290 ->willReturn($this->data_factory->error(
""));
292 ->expects($this->once())
293 ->method(
"withInput")
295 ->willReturn($this->child1);
297 ->expects($this->once())
298 ->method(
"getContent")
299 ->willReturn($this->data_factory->ok(
"two"));
301 $i18n =
"THERE IS SOME ERROR IN THIS GROUP";
303 ->expects($this->once())
305 ->with(
"ui_error_in_group")
308 $new_group = $this->group
309 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
function ():
void {
310 $this->fail(
"This should not happen.");
312 ->withInput($input_data);
314 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
315 $this->assertInstanceOf(Group::class, $new_group);
316 $this->assertNotSame($this->group, $new_group);
317 $this->assertTrue($new_group->getContent()->isError());
322 $this->assertNotSame($this->child1, $this->child2);
324 $input_data = $this->createMock(InputData::class);
327 ->method(
"withInput")
328 ->willReturn($this->child2);
330 ->method(
"getContent")
331 ->willReturn($this->data_factory->error(
""));
333 ->method(
"withInput")
334 ->willReturn($this->child1);
336 ->method(
"getContent")
337 ->willReturn($this->data_factory->ok(
"two"));
339 $i18n =
"THERE IS SOME ERROR IN THIS GROUP";
341 ->expects($this->once())
343 ->with(
"ui_error_in_group")
346 $new_group = $this->group
347 ->withInput($input_data);
349 $this->assertTrue($new_group->getContent()->isError());
350 $this->assertEquals($i18n, $new_group->getContent()->error());
364 $this->assertInstanceOf(Ok::class, $content);
365 $this->assertCount(0, $content->value());
374 $this->getRefinery(),
381 $f = $this->getFieldFactory();
383 $f->text(
"input1",
"in 1"),
384 $f->text(
"input2",
"in 2")
390 <div
class=
"form-group row">
391 <label
for=
"id_1" class=
"control-label col-sm-4 col-md-3 col-lg-2">input1</label>
392 <div
class=
"col-sm-8 col-md-9 col-lg-10">
393 <input
id=
"id_1" type=
"text" name=
"" class=
"form-control form-control-sm" />
394 <div
class=
"help-block">in 1</div>
397 <div
class=
"form-group row">
398 <label
for=
"id_2" class=
"control-label col-sm-4 col-md-3 col-lg-2">input2</label>
399 <div
class=
"col-sm-8 col-md-9 col-lg-10">
400 <input
id=
"id_2" type=
"text" name=
"" class=
"form-control form-control-sm" />
401 <div
class=
"help-block">in 2</div>
405 $actual = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($group));
406 $expected = $this->brutallyTrimHTML($expected);
407 $this->assertEquals($expected, $actual);
414 $f = $this->getFieldFactory();
415 $group =
$f->group([],
"LABEL", $bl);
416 $this->assertEquals($bl, $group->
getByline());
421 $f = $this->getFieldFactory();
432 $f = $this->getFieldFactory();
435 $f->text(
"")->withRequired(
true)
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.