18 public function testAccept($constraint, $ok_value, $error_value)
20 $this->assertFalse($constraint->accepts($ok_value));
21 $this->assertTrue($constraint->accepts($error_value));
27 public function testCheck($constraint, $ok_value, $error_value)
32 $constraint->check($ok_value);
33 }
catch (UnexpectedValueException $e) {
37 $this->assertTrue($raised);
40 $constraint->check($error_value);
42 }
catch (UnexpectedValueException $e) {
46 $this->assertFalse($raised);
54 $this->assertNull($constraint->problemWith($error_value));
55 $this->assertInternalType(
"string", $constraint->problemWith($ok_value));
64 $ok = $rf->ok($error_value);
65 $ok2 = $rf->ok($ok_value);
66 $error = $rf->error(
"text");
69 $this->assertTrue(
$result->isOk());
71 $result = $constraint->restrict($ok2);
72 $this->assertTrue(
$result->isError());
83 $new_constraint = $constraint->withProblemBuilder(
function () {
84 return "This was a vault";
86 $this->assertEquals(
"This was a vault", $new_constraint->problemWith($ok_value));
93 return array(array($f->not($f->isInt()), 2, 2.2),
94 array($f->not($f->greaterThan(5)), 6, 4),
95 array($f->not($f->lessThan(5)), 4, 6)
An exception for terminatinating execution or to throw for unit testing.
TestCase for the factory of constraints.
testRestrict($constraint, $ok_value, $error_value)
@dataProvider constraintsProvider
testCheck($constraint, $ok_value, $error_value)
@dataProvider constraintsProvider
testWithProblemBuilder($constraint, $ok_value, $error_value)
@dataProvider constraintsProvider
testProblemWith($constraint, $ok_value, $error_value)
@dataProvider constraintsProvider
testAccept($constraint, $ok_value, $error_value)
@dataProvider constraintsProvider