4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Validator\Tests\Constraints;
14 use Symfony\Component\Validator\Constraints\Blank;
15 use Symfony\Component\Validator\Constraints\BlankValidator;
16 use Symfony\Component\Validator\Validation;
18 class BlankValidatorTest extends AbstractConstraintValidatorTest
20 protected function getApiVersion()
22 return Validation::API_VERSION_2_5;
25 protected function createValidator()
27 return new BlankValidator();
30 public function testNullIsValid()
32 $this->validator->validate(null, new Blank());
34 $this->assertNoViolation();
37 public function testBlankIsValid()
39 $this->validator->validate('', new Blank());
41 $this->assertNoViolation();
45 * @dataProvider getInvalidValues
47 public function testInvalidValues($value, $valueAsString)
49 $constraint = new Blank(array(
50 'message' => 'myMessage',
53 $this->validator->validate($value, $constraint);
55 $this->buildViolation('myMessage')
56 ->setParameter('{{ value }}', $valueAsString)
57 ->setCode(Blank::NOT_BLANK_ERROR)
61 public function getInvalidValues()
64 array('foobar', '"foobar"'),
66 array(false, 'false'),