17 $this->f =
new Validation\Factory(
new Data\
Factory());
27 $constraint = $this->f->parallel(
array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(5)));
29 $this->assertTrue($constraint->accepts(4));
30 $this->assertFalse($constraint->accepts(2));
35 $constraint = $this->f->sequential(
array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(5)));
39 $constraint->check(4);
44 $this->assertFalse($raised);
46 $constraint = $this->f->parallel(
array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(1)));
48 $constraint->check(2);
51 $this->assertEquals(
"'2' is not greater than '3'.'2' is greater than '1'.", $e->getMessage());
55 $this->assertTrue($raised);
60 $constraint = $this->f->parallel(
array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(5)));
62 $this->assertNull($constraint->problemWith(4));
64 $constraint = $this->f->parallel(
array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(1)));
65 $this->assertInternalType(
"string", $constraint->problemWith(2));
66 $this->assertEquals(
"'2' is not greater than '3'.'2' is greater than '1'.", $constraint->problemWith(2));
71 $constraint = $this->f->parallel(
array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(5)));
73 $rf =
new Data\Factory();
76 $error = $rf->error(
"text");
79 $this->assertTrue(
$result->isOk());
81 $result = $constraint->restrict($ok2);
82 $this->assertTrue($result->isError());
84 $result = $constraint->restrict(
$error);
85 $this->assertSame(
$error, $result);
90 $constraint = $this->f->parallel(
array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(1)));
92 $new_constraint = $constraint->withProblemBuilder(
function () {
93 return "This was a vault";
95 $this->assertEquals(
"This was a vault", $new_constraint->problemWith(2));
100 $constraint = $this->f->parallel(
array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(2)));
101 $constraint->accepts(1);
102 $constraint->accepts(3);
103 $constraint->accepts(4);
105 $this->assertEquals(
"'1' is not greater than '3'.", $constraint->problemWith(1));
106 $this->assertEquals(
"'3' is not greater than '3'.'3' is greater than '2'.", $constraint->problemWith(3));
107 $this->assertEquals(
"'4' is greater than '2'.", $constraint->problemWith(4));
Create styles array
The data for the language used.
testCorrectErrorMessagesAfterMultiAccept()
TestCase for the factory of constraints.