1c5927da4bf4d7371c01bf5eda73d971c5de461d
[yaffs-website] / vendor / symfony / validator / Tests / Constraints / IsTrueValidatorTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Validator\Tests\Constraints;
13
14 use Symfony\Component\Validator\Constraints\IsTrue;
15 use Symfony\Component\Validator\Constraints\IsTrueValidator;
16 use Symfony\Component\Validator\Validation;
17
18 class IsTrueValidatorTest extends AbstractConstraintValidatorTest
19 {
20     protected function getApiVersion()
21     {
22         return Validation::API_VERSION_2_5;
23     }
24
25     protected function createValidator()
26     {
27         return new IsTrueValidator();
28     }
29
30     public function testNullIsValid()
31     {
32         $this->validator->validate(null, new IsTrue());
33
34         $this->assertNoViolation();
35     }
36
37     public function testTrueIsValid()
38     {
39         $this->validator->validate(true, new IsTrue());
40
41         $this->assertNoViolation();
42     }
43
44     public function testFalseIsInvalid()
45     {
46         $constraint = new IsTrue(array(
47             'message' => 'myMessage',
48         ));
49
50         $this->validator->validate(false, $constraint);
51
52         $this->buildViolation('myMessage')
53             ->setParameter('{{ value }}', 'false')
54             ->setCode(IsTrue::NOT_TRUE_ERROR)
55             ->assertRaised();
56     }
57 }