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\IsFalse;
15 use Symfony\Component\Validator\Constraints\IsFalseValidator;
16 use Symfony\Component\Validator\Validation;
18 class IsFalseValidatorTest extends AbstractConstraintValidatorTest
20 protected function getApiVersion()
22 return Validation::API_VERSION_2_5;
25 protected function createValidator()
27 return new IsFalseValidator();
30 public function testNullIsValid()
32 $this->validator->validate(null, new IsFalse());
34 $this->assertNoViolation();
37 public function testFalseIsValid()
39 $this->validator->validate(false, new IsFalse());
41 $this->assertNoViolation();
44 public function testTrueIsInvalid()
46 $constraint = new IsFalse(array(
47 'message' => 'myMessage',
50 $this->validator->validate(true, $constraint);
52 $this->buildViolation('myMessage')
53 ->setParameter('{{ value }}', 'true')
54 ->setCode(IsFalse::NOT_FALSE_ERROR)