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\NotIdenticalTo;
15 use Symfony\Component\Validator\Constraints\NotIdenticalToValidator;
18 * @author Daniel Holmes <daniel@danielholmes.org>
20 class NotIdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
22 protected function createValidator()
24 return new NotIdenticalToValidator();
27 protected function createConstraint(array $options = null)
29 return new NotIdenticalTo($options);
32 protected function getErrorCode()
34 return NotIdenticalTo::IS_IDENTICAL_ERROR;
40 public function provideValidComparisons()
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'),
56 public function provideAllInvalidComparisons()
58 $this->setDefaultTimezone('UTC');
60 // Don't call addPhp5Dot5Comparisons() automatically, as it does
61 // not take care of identical objects
62 $comparisons = $this->provideInvalidComparisons();
64 $this->restoreDefaultTimezone();
72 public function provideInvalidComparisons()
74 $date = new \DateTime('2000-01-01');
75 $object = new ComparisonTest_Class(2);
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'),