Yaffs site version 1.1
[yaffs-website] / vendor / symfony / validator / Tests / Constraints / GreaterThanValidatorTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Validator\Tests\Constraints;
13
14 use Symfony\Component\Validator\Constraints\GreaterThan;
15 use Symfony\Component\Validator\Constraints\GreaterThanValidator;
16 use Symfony\Component\Validator\Validation;
17
18 /**
19  * @author Daniel Holmes <daniel@danielholmes.org>
20  */
21 class GreaterThanValidatorTest extends AbstractComparisonValidatorTestCase
22 {
23     protected function getApiVersion()
24     {
25         return Validation::API_VERSION_2_5;
26     }
27
28     protected function createValidator()
29     {
30         return new GreaterThanValidator();
31     }
32
33     protected function createConstraint(array $options)
34     {
35         return new GreaterThan($options);
36     }
37
38     protected function getErrorCode()
39     {
40         return GreaterThan::TOO_LOW_ERROR;
41     }
42
43     /**
44      * {@inheritdoc}
45      */
46     public function provideValidComparisons()
47     {
48         return array(
49             array(2, 1),
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)),
54             array('333', '22'),
55             array(null, 1),
56         );
57     }
58
59     /**
60      * {@inheritdoc}
61      */
62     public function provideInvalidComparisons()
63     {
64         return array(
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'),
77         );
78     }
79 }