class ValidationTest extends TestCase
{ public function testCreateCallableValid() { $validator = Validation::
createCallable(new NotBlank());
$this->
assertEquals('test@example.com',
$validator('test@example.com'
));
} public function testCreateCallableInvalid() { $validator = Validation::
createCallable(new Blank());
try { $validator('test'
);
$this->
fail('No ValidationFailedException thrown'
);
} catch (ValidationFailedException
$e) { $this->
assertEquals('test',
$e->
getValue());
$violations =
$e->
getViolations();
$this->
assertCount(1,
$violations);
$this->
assertEquals('This value should be blank.',
$violations->
get(0
)->
getMessage());
} }