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\GreaterThan;
15 use Symfony\Component\Validator\Constraints\GreaterThanValidator;
16 use Symfony\Component\Validator\Validation;
19 * @author Daniel Holmes <daniel@danielholmes.org>
21 class GreaterThanValidatorTest extends AbstractComparisonValidatorTestCase
23 protected function getApiVersion()
25 return Validation::API_VERSION_2_5;
28 protected function createValidator()
30 return new GreaterThanValidator();
33 protected function createConstraint(array $options)
35 return new GreaterThan($options);
38 protected function getErrorCode()
40 return GreaterThan::TOO_LOW_ERROR;
46 public function provideValidComparisons()
50 array(new \DateTime('2005/01/01'), new \DateTime('2001/01/01')),
51 array(new \DateTime('2005/01/01'), '2001/01/01'),
52 array(new \DateTime('2005/01/01 UTC'), '2001/01/01 UTC'),
53 array(new ComparisonTest_Class(5), new ComparisonTest_Class(4)),
62 public function provideInvalidComparisons()
65 array(1, '1', 2, '2', 'integer'),
66 array(2, '2', 2, '2', 'integer'),
67 array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'),
68 array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
69 array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', '2005/01/01', 'Jan 1, 2005, 12:00 AM', 'DateTime'),
70 array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', '2000/01/01', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
71 array(new \DateTime('2000/01/01 UTC'), 'Jan 1, 2000, 12:00 AM', '2005/01/01 UTC', 'Jan 1, 2005, 12:00 AM', 'DateTime'),
72 array(new \DateTime('2000/01/01 UTC'), 'Jan 1, 2000, 12:00 AM', '2000/01/01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'),
73 array(new ComparisonTest_Class(4), '4', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'),
74 array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'),
75 array('22', '"22"', '333', '"333"', 'string'),
76 array('22', '"22"', '22', '"22"', 'string'),