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\LessThanOrEqual;
15 use Symfony\Component\Validator\Constraints\LessThanOrEqualValidator;
18 * @author Daniel Holmes <daniel@danielholmes.org>
20 class LessThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase
22 protected function createValidator()
24 return new LessThanOrEqualValidator();
27 protected function createConstraint(array $options = null)
29 return new LessThanOrEqual($options);
32 protected function getErrorCode()
34 return LessThanOrEqual::TOO_HIGH_ERROR;
40 public function provideValidComparisons()
45 array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01')),
46 array(new \DateTime('2000-01-01'), new \DateTime('2020-01-01')),
47 array(new \DateTime('2000-01-01'), '2000-01-01'),
48 array(new \DateTime('2000-01-01'), '2020-01-01'),
49 array(new \DateTime('2000-01-01 UTC'), '2000-01-01 UTC'),
50 array(new \DateTime('2000-01-01 UTC'), '2020-01-01 UTC'),
51 array(new ComparisonTest_Class(4), new ComparisonTest_Class(5)),
52 array(new ComparisonTest_Class(5), new ComparisonTest_Class(5)),
62 public function provideValidComparisonsToPropertyPath()
73 public function provideInvalidComparisons()
76 array(2, '2', 1, '1', 'integer'),
77 array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
78 array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
79 array(new \DateTime('2010-01-01 UTC'), 'Jan 1, 2010, 12:00 AM', '2000-01-01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
80 array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(4), '4', __NAMESPACE__.'\ComparisonTest_Class'),
81 array('c', '"c"', 'b', '"b"', 'string'),