|
| 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\PositiveOrZero; |
| 15 | + |
| 16 | +/** |
| 17 | + * @author Jan Schädlich <jan.schaedlich@sensiolabs.de> |
| 18 | + */ |
| 19 | +class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest extends GreaterThanOrEqualValidatorTest |
| 20 | +{ |
| 21 | + protected function createConstraint(array $options = null) |
| 22 | + { |
| 23 | + return new PositiveOrZero(); |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * {@inheritdoc} |
| 28 | + */ |
| 29 | + public function provideValidComparisons() |
| 30 | + { |
| 31 | + return array( |
| 32 | + array(0, 0), |
| 33 | + array(1, 0), |
| 34 | + array(2, 0), |
| 35 | + array(2.5, 0), |
| 36 | + array('0', '0'), |
| 37 | + array('333', '0'), |
| 38 | + array(null, 0), |
| 39 | + ); |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * {@inheritdoc} |
| 44 | + */ |
| 45 | + public function provideInvalidComparisons() |
| 46 | + { |
| 47 | + return array( |
| 48 | + array(-1, '-1', 0, '0', 'integer'), |
| 49 | + array(-2, '-2', 0, '0', 'integer'), |
| 50 | + array(-2.5, '-2.5', 0, '0', 'integer'), |
| 51 | + ); |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException |
| 56 | + * @expectedExceptionMessage The "Symfony\Component\Validator\Constraints\PositiveOrZero" constraint can not be configured via options. |
| 57 | + */ |
| 58 | + public function testThrowsConstraintDefinitionExceptionIfConfiguredViaOptions() |
| 59 | + { |
| 60 | + new PositiveOrZero(array('value' => 1)); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * @dataProvider provideInvalidConstraintOptions |
| 65 | + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException |
| 66 | + * @expectedExceptionMessage requires either the "value" or "propertyPath" option to be set. |
| 67 | + */ |
| 68 | + public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options) |
| 69 | + { |
| 70 | + $this->markTestSkipped('Value property always set for PositiveOrZero constraint'); |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException |
| 75 | + * @expectedExceptionMessage requires only one of the "value" or "propertyPath" options to be set, not both. |
| 76 | + */ |
| 77 | + public function testThrowsConstraintExceptionIfBothValueAndPropertyPath() |
| 78 | + { |
| 79 | + $this->markTestSkipped('Value property is set for PositiveOrZero constraint automatically'); |
| 80 | + } |
| 81 | + |
| 82 | + public function testInvalidValuePath() |
| 83 | + { |
| 84 | + $this->markTestSkipped('PropertyPath property is not used in PositiveOrZero constraint'); |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * @dataProvider provideValidComparisonsToPropertyPath |
| 89 | + */ |
| 90 | + public function testValidComparisonToPropertyPath($comparedValue) |
| 91 | + { |
| 92 | + $this->markTestSkipped('PropertyPath property is not used in PositiveOrZero constraint'); |
| 93 | + } |
| 94 | + |
| 95 | + /** |
| 96 | + * @dataProvider provideValidComparisonsToPropertyPath |
| 97 | + */ |
| 98 | + public function testValidComparisonToPropertyPathOnArray($comparedValue) |
| 99 | + { |
| 100 | + $this->markTestSkipped('PropertyPath property is not used in Positive constraint'); |
| 101 | + } |
| 102 | +} |
0 commit comments