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