4 require_once(
"libs/composer/vendor/autoload.php");
42 protected function setUp() : void
44 $this->df =
new Data\Factory();
45 $this->lng = $this->createMock(\ilLanguage::class);
46 $this->refinery = new \ILIAS\Refinery\Factory($this->df, $this->lng);
48 $group = $this->refinery->custom();
50 $this->greater_than_3 = $group->constraint(
57 $this->less_than_5 = $group->constraint(
64 $this->c = $this->refinery
66 ->sequential([$this->greater_than_3, $this->less_than_5]);
71 $this->assertTrue($this->c->accepts(4));
76 $this->assertFalse($this->c->accepts(2));
82 $this->assertTrue(
true);
87 $this->expectException(\UnexpectedValueException::class);
93 $this->assertNull($this->c->problemWith(4));
99 ->expects($this->never())
102 $this->assertEquals(
"not_greater_than_3", $this->c->problemWith(2));
108 ->expects($this->never())
111 $this->assertEquals(
"not_less_than_5", $this->c->problemWith(6));
116 $ok = $this->df->ok(4);
119 $this->assertTrue(
$res->isOk());
124 $not_ok = $this->df->ok(7);
126 $res = $this->c->applyTo($not_ok);
127 $this->assertFalse(
$res->isOk());
132 $error = $this->df->error(
"error");
134 $res = $this->c->applyTo($error);
135 $this->assertSame($error,
$res);
140 $new_c = $this->c->withProblemBuilder(
function () {
141 return "This was a fault";
143 $this->assertEquals(
"This was a fault", $new_c->problemWith(7));
TestCase for the sequential constraint.
foreach($_POST as $key=> $value) $res