18 public function testAccept($constraint, $ok_value, $error_value)
20 $this->assertTrue($constraint->accepts($ok_value));
21 $this->assertFalse($constraint->accepts($error_value));
27 public function testCheck($constraint, $ok_value, $error_value)
31 $constraint->check($ok_value);
32 }
catch (UnexpectedValueException $e) {
36 $this->assertFalse($raised);
39 $constraint->check($error_value);
40 }
catch (UnexpectedValueException $e) {
44 $this->assertTrue($raised);
52 $this->assertNull($constraint->problemWith($ok_value));
53 $this->assertInternalType(
"string", $constraint->problemWith($error_value));
62 $ok = $rf->ok($ok_value);
63 $ok2 = $rf->ok($error_value);
64 $error = $rf->error(
"text");
67 $this->assertTrue(
$result->isOk());
69 $result = $constraint->restrict($ok2);
70 $this->assertTrue(
$result->isError());
81 $new_constraint = $constraint->withProblemBuilder(
function () {
82 return "This was a vault";
84 $this->assertEquals(
"This was a vault", $new_constraint->problemWith($error_value));
91 return array(array($f->isInt(), 2, 2.2),
92 array($f->greaterThan(5), 6, 4),
93 array($f->lessThan(5), 4, 6)
An exception for terminatinating execution or to throw for unit testing.
TestCase for the factory of constraints.
testWithProblemBuilder($constraint, $ok_value, $error_value)
@dataProvider constraintsProvider
testAccept($constraint, $ok_value, $error_value)
@dataProvider constraintsProvider
testRestrict($constraint, $ok_value, $error_value)
@dataProvider constraintsProvider
testCheck($constraint, $ok_value, $error_value)
@dataProvider constraintsProvider
testProblemWith($constraint, $ok_value, $error_value)
@dataProvider constraintsProvider