Definition at line 21 of file GroupInputTest.php.
◆ setUp()
GroupInputTest::setUp |
( |
| ) |
|
Definition at line 28 of file GroupInputTest.php.
References language().
30 $this->child1 = $this->createMock(Input1::class);
31 $this->child2 = $this->createMock(Input2::class);
32 $this->data_factory =
new Data\Factory;
33 $this->
language = $this->createMock(\ilLanguage::class);
34 $this->refinery = new \ILIAS\Refinery\Factory($this->data_factory, $this->
language);
36 $this->group =
new Group(
40 [$this->child1, $this->child2],
◆ testErrorIsI18NOnError()
GroupInputTest::testErrorIsI18NOnError |
( |
| ) |
|
Definition at line 287 of file GroupInputTest.php.
References language().
289 $this->assertNotSame($this->child1, $this->child2);
291 $input_data = $this->createMock(InputData::class);
294 ->method(
"withInput")
295 ->willReturn($this->child2);
297 ->method(
"getContent")
298 ->willReturn($this->data_factory->error(
""));
300 ->method(
"withInput")
301 ->willReturn($this->child1);
303 ->method(
"getContent")
304 ->willReturn($this->data_factory->ok(
"two"));
306 $i18n =
"THERE IS SOME ERROR IN THIS GROUP";
308 ->expects($this->once())
310 ->with(
"ui_error_in_group")
313 $new_group = $this->group
314 ->withInput($input_data);
316 $this->assertTrue($new_group->getContent()->isError());
317 $this->assertEquals($i18n, $new_group->getContent()->error());
◆ testGroupForwardsValuesOnGetValue()
GroupInputTest::testGroupForwardsValuesOnGetValue |
( |
| ) |
|
Definition at line 182 of file GroupInputTest.php.
184 $this->assertNotSame($this->child1, $this->child2);
187 ->expects($this->once())
192 ->expects($this->once())
197 $vals = $this->group->getValue();
199 $this->assertEquals([
"one",
"two"], $vals);
◆ testGroupForwardsValuesOnWithValue()
GroupInputTest::testGroupForwardsValuesOnWithValue |
( |
| ) |
|
Definition at line 104 of file GroupInputTest.php.
106 $this->assertNotSame($this->child1, $this->child2);
109 ->expects($this->once())
110 ->method(
"withValue")
112 ->willReturn($this->child2);
114 ->expects($this->once())
115 ->method(
"isClientSideValueOk")
119 ->expects($this->once())
120 ->method(
"withValue")
122 ->willReturn($this->child1);
124 ->expects($this->once())
125 ->method(
"isClientSideValueOk")
129 $new_group = $this->group->withValue([1,2]);
131 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
132 $this->assertInstanceOf(Group::class, $new_group);
133 $this->assertNotSame($this->group, $new_group);
◆ testGroupMayOnlyHaveInputChildren()
GroupInputTest::testGroupMayOnlyHaveInputChildren |
( |
| ) |
|
◆ testGroupOnlyDoesNoAcceptArrayValuesWithWrongLength()
GroupInputTest::testGroupOnlyDoesNoAcceptArrayValuesWithWrongLength |
( |
| ) |
|
Definition at line 175 of file GroupInputTest.php.
177 $this->expectException(\InvalidArgumentException::class);
179 $new_group = $this->group->withValue([1]);
◆ testGroupOnlyDoesNoAcceptNonArrayValue()
GroupInputTest::testGroupOnlyDoesNoAcceptNonArrayValue |
( |
| ) |
|
Definition at line 168 of file GroupInputTest.php.
170 $this->expectException(\InvalidArgumentException::class);
172 $new_group = $this->group->withValue(1);
◆ testWithDisabledDisablesChildren()
GroupInputTest::testWithDisabledDisablesChildren |
( |
| ) |
|
Definition at line 46 of file GroupInputTest.php.
48 $this->assertNotSame($this->child1, $this->child2);
51 ->expects($this->once())
52 ->method(
"withDisabled")
54 ->willReturn($this->child2);
56 ->expects($this->once())
57 ->method(
"withDisabled")
59 ->willReturn($this->child1);
61 $new_group = $this->group->withDisabled(
true);
63 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
64 $this->assertInstanceOf(Group::class, $new_group);
65 $this->assertNotSame($this->group, $new_group);
◆ testWithInputCallsChildrenAndAppliesOperations()
GroupInputTest::testWithInputCallsChildrenAndAppliesOperations |
( |
| ) |
|
Definition at line 202 of file GroupInputTest.php.
204 $this->assertNotSame($this->child1, $this->child2);
206 $input_data = $this->createMock(InputData::class);
209 ->expects($this->once())
210 ->method(
"withInput")
212 ->willReturn($this->child2);
214 ->expects($this->once())
215 ->method(
"getContent")
216 ->willReturn($this->data_factory->ok(
"one"));
218 ->expects($this->once())
219 ->method(
"withInput")
221 ->willReturn($this->child1);
223 ->expects($this->once())
224 ->method(
"getContent")
225 ->willReturn($this->data_factory->ok(
"two"));
228 $new_group = $this->group
229 ->withAdditionalTransformation($this->refinery->custom()->transformation(
function ($v) use (&$called) {
231 $this->assertEquals([
"two",
"one"], $v);
234 ->withInput($input_data);
236 $this->assertTrue($called);
237 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
238 $this->assertInstanceOf(Group::class, $new_group);
239 $this->assertNotSame($this->group, $new_group);
240 $this->assertEquals($this->data_factory->ok(
"result"), $new_group->getContent());
◆ testWithInputDoesNotApplyOperationsOnError()
GroupInputTest::testWithInputDoesNotApplyOperationsOnError |
( |
| ) |
|
Definition at line 243 of file GroupInputTest.php.
References language().
245 $this->assertNotSame($this->child1, $this->child2);
247 $input_data = $this->createMock(InputData::class);
250 ->expects($this->once())
251 ->method(
"withInput")
253 ->willReturn($this->child2);
255 ->expects($this->once())
256 ->method(
"getContent")
257 ->willReturn($this->data_factory->error(
""));
259 ->expects($this->once())
260 ->method(
"withInput")
262 ->willReturn($this->child1);
264 ->expects($this->once())
265 ->method(
"getContent")
266 ->willReturn($this->data_factory->ok(
"two"));
268 $i18n =
"THERE IS SOME ERROR IN THIS GROUP";
270 ->expects($this->once())
272 ->with(
"ui_error_in_group")
275 $new_group = $this->group
276 ->withAdditionalTransformation($this->refinery->custom()->transformation(
function ($v) {
277 $this->assertFalse(
true,
"This should not happen.");
279 ->withInput($input_data);
281 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
282 $this->assertInstanceOf(Group::class, $new_group);
283 $this->assertNotSame($this->group, $new_group);
284 $this->assertTrue($new_group->getContent()->isError());
◆ testWithoutChildren()
GroupInputTest::testWithoutChildren |
( |
| ) |
|
◆ testWithRequiredRequiresChildren()
GroupInputTest::testWithRequiredRequiresChildren |
( |
| ) |
|
Definition at line 68 of file GroupInputTest.php.
70 $this->assertNotSame($this->child1, $this->child2);
73 ->expects($this->once())
74 ->method(
"withRequired")
76 ->willReturn($this->child2);
78 ->expects($this->once())
79 ->method(
"withRequired")
81 ->willReturn($this->child1);
83 $new_group = $this->group->withRequired(
true);
85 $this->assertEquals([$this->child2, $this->child1], $new_group->getInputs());
86 $this->assertInstanceOf(Group::class, $new_group);
87 $this->assertNotSame($this->group, $new_group);
◆ testWithValuePreservesKeys()
GroupInputTest::testWithValuePreservesKeys |
( |
| ) |
|
Definition at line 136 of file GroupInputTest.php.
References language().
138 $this->assertNotSame($this->child1, $this->child2);
140 $this->group =
new Group(
144 [
"child1" => $this->child1,
"child2" => $this->child2],
150 ->method(
"withValue")
151 ->willReturn($this->child2);
153 ->method(
"isClientSideValueOk")
156 ->method(
"withValue")
157 ->willReturn($this->child1);
159 ->method(
"isClientSideValueOk")
162 $new_group = $this->group->withValue([
"child1" => 1,
"child2" => 2]);
164 $this->assertEquals([
"child1" => $this->child2,
"child2" => $this->child1], $new_group->getInputs());
◆ $refinery
GroupInputTest::$refinery |
|
private |
The documentation for this class was generated from the following file: