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\NotNull;
15 use Symfony\Component\Validator\Constraints\NotNullValidator;
16 use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
18 class NotNullValidatorTest extends ConstraintValidatorTestCase
20 protected function createValidator()
22 return new NotNullValidator();
26 * @dataProvider getValidValues
28 public function testValidValues($value)
30 $this->validator->validate($value, new NotNull());
32 $this->assertNoViolation();
35 public function getValidValues()
45 public function testNullIsInvalid()
47 $constraint = new NotNull(array(
48 'message' => 'myMessage',
51 $this->validator->validate(null, $constraint);
53 $this->buildViolation('myMessage')
54 ->setParameter('{{ value }}', 'null')
55 ->setCode(NotNull::IS_NULL_ERROR)