|
| 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\DivisibleBy; |
| 15 | +use Symfony\Component\Validator\Constraints\DivisibleByValidator; |
| 16 | + |
| 17 | +/** |
| 18 | + * @author Colin O'Dell <colinodell@gmail.com> |
| 19 | + */ |
| 20 | +class DivisibleByValidatorTest extends AbstractComparisonValidatorTestCase |
| 21 | +{ |
| 22 | + protected function createValidator() |
| 23 | + { |
| 24 | + return new DivisibleByValidator(); |
| 25 | + } |
| 26 | + |
| 27 | + protected function createConstraint(array $options = null) |
| 28 | + { |
| 29 | + return new DivisibleBy($options); |
| 30 | + } |
| 31 | + |
| 32 | + protected function getErrorCode() |
| 33 | + { |
| 34 | + return DivisibleBy::NOT_DIVISIBLE_BY; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * {@inheritdoc} |
| 39 | + */ |
| 40 | + public function provideValidComparisons() |
| 41 | + { |
| 42 | + return array( |
| 43 | + array(-7, 1), |
| 44 | + array(0, 3.1415), |
| 45 | + array(42, 42), |
| 46 | + array(42, 21), |
| 47 | + array(3.25, 0.25), |
| 48 | + array('100', '10'), |
| 49 | + ); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * {@inheritdoc} |
| 54 | + */ |
| 55 | + public function provideValidComparisonsToPropertyPath() |
| 56 | + { |
| 57 | + return array( |
| 58 | + array(25), |
| 59 | + ); |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * {@inheritdoc} |
| 64 | + */ |
| 65 | + public function provideInvalidComparisons() |
| 66 | + { |
| 67 | + return array( |
| 68 | + array(1, '1', 2, '2', 'integer'), |
| 69 | + array(10, '10', 3, '3', 'integer'), |
| 70 | + array(10, '10', 0, '0', 'integer'), |
| 71 | + array(42, '42', INF, 'INF', 'double'), |
| 72 | + array('22', '"22"', '10', '"10"', 'string'), |
| 73 | + ); |
| 74 | + } |
| 75 | +} |
0 commit comments