GreaterThanOrEqualValidatorTest.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Validator\Tests\Constraints;
  11. use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
  12. use Symfony\Component\Validator\Constraints\GreaterThanOrEqualValidator;
  13. use Symfony\Component\Validator\Validation;
  14. /**
  15. * @author Daniel Holmes <daniel@danielholmes.org>
  16. */
  17. class GreaterThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase
  18. {
  19. protected function getApiVersion()
  20. {
  21. return Validation::API_VERSION_2_5;
  22. }
  23. protected function createValidator()
  24. {
  25. return new GreaterThanOrEqualValidator();
  26. }
  27. protected function createConstraint(array $options = null)
  28. {
  29. return new GreaterThanOrEqual($options);
  30. }
  31. protected function getErrorCode()
  32. {
  33. return GreaterThanOrEqual::TOO_LOW_ERROR;
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function provideValidComparisons()
  39. {
  40. return array(
  41. array(3, 2),
  42. array(1, 1),
  43. array(new \DateTime('2010/01/01'), new \DateTime('2000/01/01')),
  44. array(new \DateTime('2000/01/01'), new \DateTime('2000/01/01')),
  45. array(new \DateTime('2010/01/01'), '2000/01/01'),
  46. array(new \DateTime('2000/01/01'), '2000/01/01'),
  47. array(new \DateTime('2010/01/01 UTC'), '2000/01/01 UTC'),
  48. array(new \DateTime('2000/01/01 UTC'), '2000/01/01 UTC'),
  49. array('a', 'a'),
  50. array('z', 'a'),
  51. array(null, 1),
  52. );
  53. }
  54. /**
  55. * {@inheritdoc}
  56. */
  57. public function provideInvalidComparisons()
  58. {
  59. return array(
  60. array(1, '1', 2, '2', 'integer'),
  61. array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'),
  62. array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', '2005/01/01', 'Jan 1, 2005, 12:00 AM', 'DateTime'),
  63. array(new \DateTime('2000/01/01 UTC'), 'Jan 1, 2000, 12:00 AM', '2005/01/01 UTC', 'Jan 1, 2005, 12:00 AM', 'DateTime'),
  64. array('b', '"b"', 'c', '"c"', 'string'),
  65. );
  66. }
  67. }