3 declare(strict_types=1);
33 protected function setUp(): void
36 $this->
lng = $this->createMock(ilLanguage::class);
38 $this->min_length = 10;
49 $this->assertTrue($this->c->accepts(
"1234567890"));
54 $this->assertTrue($this->c->accepts(
"12345678901"));
59 $this->assertFalse($this->c->accepts(
"123456789"));
64 $this->c->check(
"1234567890");
65 $this->assertTrue(
true);
70 $this->expectException(UnexpectedValueException::class);
76 $this->assertNull($this->c->problemWith(
"1234567890"));
82 ->expects($this->once())
84 ->with(
"not_min_length")
85 ->willReturn(
"-%s-%s-");
87 $this->assertEquals(
"-3-10-", $this->c->problemWith(
"123"));
92 $ok = $this->df->ok(
"1234567890");
94 $res = $this->c->applyTo($ok);
95 $this->assertTrue(
$res->isOk());
100 $not_ok = $this->df->ok(
"1234");
102 $res = $this->c->applyTo($not_ok);
103 $this->assertFalse(
$res->isOk());
108 $error = $this->df->error(
"error");
110 $res = $this->c->applyTo($error);
111 $this->assertSame($error,
$res);
116 $new_c = $this->c->withProblemBuilder(
static function ():
string {
117 return "This was a fault";
119 $this->assertEquals(
"This was a fault", $new_c->problemWith(
""));
A constraint encodes some resrtictions on values.