7938b0a7e389967b441eff6b1438900b2edc3ceb
[yaffs-website] / vendor / symfony / validator / Tests / Constraints / NotIdenticalToValidatorTest.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\NotIdenticalTo;
15 use Symfony\Component\Validator\Constraints\NotIdenticalToValidator;
16
17 /**
18  * @author Daniel Holmes <daniel@danielholmes.org>
19  */
20 class NotIdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
21 {
22     protected function createValidator()
23     {
24         return new NotIdenticalToValidator();
25     }
26
27     protected function createConstraint(array $options = null)
28     {
29         return new NotIdenticalTo($options);
30     }
31
32     protected function getErrorCode()
33     {
34         return NotIdenticalTo::IS_IDENTICAL_ERROR;
35     }
36
37     /**
38      * {@inheritdoc}
39      */
40     public function provideValidComparisons()
41     {
42         return array(
43             array(1, 2),
44             array('2', 2),
45             array('22', '333'),
46             array(new \DateTime('2001-01-01'), new \DateTime('2000-01-01')),
47             array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01')),
48             array(new \DateTime('2001-01-01'), '2000-01-01'),
49             array(new \DateTime('2000-01-01'), '2000-01-01'),
50             array(new \DateTime('2001-01-01'), '2000-01-01'),
51             array(new \DateTime('2000-01-01 UTC'), '2000-01-01 UTC'),
52             array(null, 1),
53         );
54     }
55
56     public function provideAllInvalidComparisons()
57     {
58         $this->setDefaultTimezone('UTC');
59
60         // Don't call addPhp5Dot5Comparisons() automatically, as it does
61         // not take care of identical objects
62         $comparisons = $this->provideInvalidComparisons();
63
64         $this->restoreDefaultTimezone();
65
66         return $comparisons;
67     }
68
69     /**
70      * {@inheritdoc}
71      */
72     public function provideInvalidComparisons()
73     {
74         $date = new \DateTime('2000-01-01');
75         $object = new ComparisonTest_Class(2);
76
77         $comparisons = array(
78             array(3, '3', 3, '3', 'integer'),
79             array('a', '"a"', 'a', '"a"', 'string'),
80             array($date, 'Jan 1, 2000, 12:00 AM', $date, 'Jan 1, 2000, 12:00 AM', 'DateTime'),
81             array($object, '2', $object, '2', __NAMESPACE__.'\ComparisonTest_Class'),
82         );
83
84         return $comparisons;
85     }
86 }