| @@ 12-88 (lines=77) @@ | ||
| 9 | /** |
|
| 10 | * @author JM Leroux <[email protected]> |
|
| 11 | */ |
|
| 12 | class CronHourFormatValidatorTest extends AbstractConstraintValidatorTest |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * {@inheritdoc} |
|
| 16 | */ |
|
| 17 | protected function createValidator() |
|
| 18 | { |
|
| 19 | return new CronHourFormatValidator(); |
|
| 20 | } |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @return array |
|
| 24 | */ |
|
| 25 | public function getValidValues() |
|
| 26 | { |
|
| 27 | return [ |
|
| 28 | [0], |
|
| 29 | [1], |
|
| 30 | [23], |
|
| 31 | ['5,15'], |
|
| 32 | ['5-15'], |
|
| 33 | ['11-15,16-20'], |
|
| 34 | ['5,15-20,23'], |
|
| 35 | ['*/15'], |
|
| 36 | ['*'], |
|
| 37 | ['*,7,*/15'], |
|
| 38 | ]; |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @dataProvider getValidValues |
|
| 43 | * |
|
| 44 | * @param string $value |
|
| 45 | */ |
|
| 46 | public function testValidValue($value) |
|
| 47 | { |
|
| 48 | $constraint = new CronHourFormat(); |
|
| 49 | $this->validator->validate($value, $constraint); |
|
| 50 | $this->assertNoViolation(); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return array |
|
| 55 | */ |
|
| 56 | public function getInvalidValues() |
|
| 57 | { |
|
| 58 | return [ |
|
| 59 | [-1], |
|
| 60 | [24], |
|
| 61 | ['5,30'], |
|
| 62 | ['32,9'], |
|
| 63 | ['24-50'], |
|
| 64 | ['-1'], |
|
| 65 | ['1-'], |
|
| 66 | ['22,23-70'], |
|
| 67 | ['10-20,45'], |
|
| 68 | ['10-20,50-65'], |
|
| 69 | ['20/*'], |
|
| 70 | ['2-3,20/*'], |
|
| 71 | ['**'], |
|
| 72 | ]; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @dataProvider getInvalidValues |
|
| 77 | * |
|
| 78 | * @param string $value |
|
| 79 | */ |
|
| 80 | public function testInvalidValues($value) |
|
| 81 | { |
|
| 82 | $constraint = new CronHourFormat(); |
|
| 83 | $this->validator->validate($value, $constraint); |
|
| 84 | $this->buildViolation($constraint->message) |
|
| 85 | ->setParameter('%string%', $value) |
|
| 86 | ->assertRaised(); |
|
| 87 | } |
|
| 88 | } |
|
| 89 | ||
| @@ 12-89 (lines=78) @@ | ||
| 9 | /** |
|
| 10 | * @author JM Leroux <[email protected]> |
|
| 11 | */ |
|
| 12 | class CronMonthFormatValidatorTest extends AbstractConstraintValidatorTest |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * {@inheritdoc} |
|
| 16 | */ |
|
| 17 | protected function createValidator() |
|
| 18 | { |
|
| 19 | return new CronMonthFormatValidator(); |
|
| 20 | } |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @return array |
|
| 24 | */ |
|
| 25 | public function getValidValues() |
|
| 26 | { |
|
| 27 | return [ |
|
| 28 | [5], |
|
| 29 | [1], |
|
| 30 | [12], |
|
| 31 | ['5,11'], |
|
| 32 | ['3-10'], |
|
| 33 | ['1-5,6-10'], |
|
| 34 | ['5,6-9,11'], |
|
| 35 | ['*/15'], |
|
| 36 | ['*'], |
|
| 37 | ['*,7,*/15'], |
|
| 38 | ]; |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @dataProvider getValidValues |
|
| 43 | * |
|
| 44 | * @param string $value |
|
| 45 | */ |
|
| 46 | public function testValidValue($value) |
|
| 47 | { |
|
| 48 | $constraint = new CronMonthFormat(); |
|
| 49 | $this->validator->validate($value, $constraint); |
|
| 50 | $this->assertNoViolation(); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return array |
|
| 55 | */ |
|
| 56 | public function getInvalidValues() |
|
| 57 | { |
|
| 58 | return [ |
|
| 59 | [-1], |
|
| 60 | [0], |
|
| 61 | [13], |
|
| 62 | ['5,15'], |
|
| 63 | ['17,9'], |
|
| 64 | ['4-15'], |
|
| 65 | ['-1'], |
|
| 66 | ['1-'], |
|
| 67 | ['3,4-14'], |
|
| 68 | ['2-10,15'], |
|
| 69 | ['1-5,6-15'], |
|
| 70 | ['5/*'], |
|
| 71 | ['2-3,5/*'], |
|
| 72 | ['**'], |
|
| 73 | ]; |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * @dataProvider getInvalidValues |
|
| 78 | * |
|
| 79 | * @param string $value |
|
| 80 | */ |
|
| 81 | public function testInvalidValues($value) |
|
| 82 | { |
|
| 83 | $constraint = new CronMonthFormat(); |
|
| 84 | $this->validator->validate($value, $constraint); |
|
| 85 | $this->buildViolation($constraint->message) |
|
| 86 | ->setParameter('%string%', $value) |
|
| 87 | ->assertRaised(); |
|
| 88 | } |
|
| 89 | } |
|
| 90 | ||