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;
16 use Symfony\Component\Validator\Validation;
19 * @author Daniel Holmes <daniel@danielholmes.org>
21 class LessThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase
23 protected function getApiVersion()
25 return Validation::API_VERSION_2_5;
28 protected function createValidator()
30 return new LessThanOrEqualValidator();
33 protected function createConstraint(array $options)
35 return new LessThanOrEqual($options);
38 protected function getErrorCode()
40 return LessThanOrEqual::TOO_HIGH_ERROR;
46 public function provideValidComparisons()
51 array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01')),
52 array(new \DateTime('2000-01-01'), new \DateTime('2020-01-01')),
53 array(new \DateTime('2000-01-01'), '2000-01-01'),
54 array(new \DateTime('2000-01-01'), '2020-01-01'),
55 array(new \DateTime('2000-01-01 UTC'), '2000-01-01 UTC'),
56 array(new \DateTime('2000-01-01 UTC'), '2020-01-01 UTC'),
57 array(new ComparisonTest_Class(4), new ComparisonTest_Class(5)),
58 array(new ComparisonTest_Class(5), new ComparisonTest_Class(5)),
68 public function provideInvalidComparisons()
71 array(2, '2', 1, '1', 'integer'),
72 array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
73 array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
74 array(new \DateTime('2010-01-01 UTC'), 'Jan 1, 2010, 12:00 AM', '2000-01-01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
75 array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(4), '4', __NAMESPACE__.'\ComparisonTest_Class'),
76 array('c', '"c"', 'b', '"b"', 'string'),