use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Exception\ValidationFailedException;
use Symfony\Component\Validator\Validation;
/**
* @author Jan Vernieuwe <
[email protected]>
*/
class ValidationTest extends TestCase
{ public function testCreateCallableValid() { $validator = Validation::
createCallable(new NotBlank());
$this->
assertEquals('
[email protected]',
$validator('
[email protected]'
));
} public function testCreateCallableInvalid() { $validator = Validation::
createCallable(new Blank());
try { $validator('test'
);
$this->
fail('No ValidationFailedException thrown'
);
} catch (ValidationFailedException
$e) { $this->
assertEquals('test',
$e->
getValue());