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\Test\ConstraintValidatorTestCase;
18 class BlankValidatorTest extends ConstraintValidatorTestCase
20 protected function createValidator()
22 return new BlankValidator();
25 public function testNullIsValid()
27 $this->validator->validate(null, new Blank());
29 $this->assertNoViolation();
32 public function testBlankIsValid()
34 $this->validator->validate('', new Blank());
36 $this->assertNoViolation();
40 * @dataProvider getInvalidValues
42 public function testInvalidValues($value, $valueAsString)
44 $constraint = new Blank(array(
45 'message' => 'myMessage',
48 $this->validator->validate($value, $constraint);
50 $this->buildViolation('myMessage')
51 ->setParameter('{{ value }}', $valueAsString)
52 ->setCode(Blank::NOT_BLANK_ERROR)
56 public function getInvalidValues()
59 array('foobar', '"foobar"'),
61 array(false, 'false'),