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
12namespace Symfony\Component\Validator\Tests\Constraints;
13
14use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
15use Symfony\Component\Validator\Constraints\GreaterThanOrEqualValidator;
16
17/**
18 * @author Daniel Holmes <daniel@danielholmes.org>
19 */
20class GreaterThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase
21{
22    protected function createValidator()
23    {
24        return new GreaterThanOrEqualValidator();
25    }
26
27    protected function createConstraint(array $options = null)
28    {
29        return new GreaterThanOrEqual($options);
30    }
31
32    protected function getErrorCode()
33    {
34        return GreaterThanOrEqual::TOO_LOW_ERROR;
35    }
36
37    /**
38     * {@inheritdoc}
39     */
40    public function provideValidComparisons()
41    {
42        return [
43            [3, 2],
44            [1, 1],
45            [new \DateTime('2010/01/01'), new \DateTime('2000/01/01')],
46            [new \DateTime('2000/01/01'), new \DateTime('2000/01/01')],
47            [new \DateTime('2010/01/01'), '2000/01/01'],
48            [new \DateTime('2000/01/01'), '2000/01/01'],
49            [new \DateTime('2010/01/01 UTC'), '2000/01/01 UTC'],
50            [new \DateTime('2000/01/01 UTC'), '2000/01/01 UTC'],
51            ['a', 'a'],
52            ['z', 'a'],
53            [null, 1],
54        ];
55    }
56
57    /**
58     * {@inheritdoc}
59     */
60    public function provideValidComparisonsToPropertyPath()
61    {
62        return [
63            [5],
64            [6],
65        ];
66    }
67
68    /**
69     * {@inheritdoc}
70     */
71    public function provideInvalidComparisons()
72    {
73        return [
74            [1, '1', 2, '2', 'integer'],
75            [new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'],
76            [new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', '2005/01/01', 'Jan 1, 2005, 12:00 AM', 'DateTime'],
77            [new \DateTime('2000/01/01 UTC'), 'Jan 1, 2000, 12:00 AM', '2005/01/01 UTC', 'Jan 1, 2005, 12:00 AM', 'DateTime'],
78            ['b', '"b"', 'c', '"c"', 'string'],
79        ];
80    }
81
82    public function provideComparisonsToNullValueAtPropertyPath()
83    {
84        return [
85            [5, '5', true],
86        ];
87    }
88}
89