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\EqualTo;
15 use Symfony\Component\Validator\Constraints\EqualToValidator;
18 * @author Daniel Holmes <daniel@danielholmes.org>
20 class EqualToValidatorTest extends AbstractComparisonValidatorTestCase
22 protected function createValidator()
24 return new EqualToValidator();
27 protected function createConstraint(array $options = null)
29 return new EqualTo($options);
32 protected function getErrorCode()
34 return EqualTo::NOT_EQUAL_ERROR;
40 public function provideValidComparisons()
46 array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01')),
47 array(new \DateTime('2000-01-01'), '2000-01-01'),
48 array(new \DateTime('2000-01-01 UTC'), '2000-01-01 UTC'),
49 array(new ComparisonTest_Class(5), new ComparisonTest_Class(5)),
57 public function provideInvalidComparisons()
60 array(1, '1', 2, '2', 'integer'),
61 array('22', '"22"', '333', '"333"', 'string'),
62 array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
63 array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
64 array(new \DateTime('2001-01-01 UTC'), 'Jan 1, 2001, 12:00 AM', '2000-01-01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
65 array(new ComparisonTest_Class(4), '4', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'),