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\LessThan;
15 use Symfony\Component\Validator\Constraints\LessThanValidator;
18 * @author Daniel Holmes <daniel@danielholmes.org>
20 class LessThanValidatorTest extends AbstractComparisonValidatorTestCase
22 protected function createValidator()
24 return new LessThanValidator();
27 protected function createConstraint(array $options = null)
29 return new LessThan($options);
32 protected function getErrorCode()
34 return LessThan::TOO_HIGH_ERROR;
40 public function provideValidComparisons()
44 array(new \DateTime('2000-01-01'), new \DateTime('2010-01-01')),
45 array(new \DateTime('2000-01-01'), '2010-01-01'),
46 array(new \DateTime('2000-01-01 UTC'), '2010-01-01 UTC'),
47 array(new ComparisonTest_Class(4), new ComparisonTest_Class(5)),
56 public function provideValidComparisonsToPropertyPath()
66 public function provideInvalidComparisons()
69 array(3, '3', 2, '2', 'integer'),
70 array(2, '2', 2, '2', 'integer'),
71 array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
72 array(new \DateTime('2000-01-01'), 'Jan 1, 2000, 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('2000-01-01'), 'Jan 1, 2000, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
75 array(new \DateTime('2010-01-01 UTC'), 'Jan 1, 2010, 12:00 AM', '2000-01-01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
76 array(new \DateTime('2000-01-01 UTC'), 'Jan 1, 2000, 12:00 AM', '2000-01-01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
77 array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'),
78 array(new ComparisonTest_Class(6), '6', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'),
79 array('333', '"333"', '22', '"22"', 'string'),