Code Duplication    Length = 59-60 lines in 5 locations

tests/Validator/Constraints/CronDayOfMonthFormatValidatorTest.php 1 location

@@ 12-70 (lines=59) @@
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
        ];
31
    }
32
33
    /**
34
     * @dataProvider getValidValues
35
     *
36
     * @param string $value
37
     */
38
    public function testValidValue($value)
39
    {
40
        $constraint = new CronDayOfMonthFormat();
41
        $this->validator->validate($value, $constraint);
42
        $this->assertNoViolation();
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    public function getInvalidValues()
49
    {
50
        return [
51
            [-1],
52
            [0],
53
            [32],
54
        ];
55
    }
56
57
    /**
58
     * @dataProvider getInvalidValues
59
     *
60
     * @param string $value
61
     */
62
    public function testInvalidValues($value)
63
    {
64
        $constraint = new CronDayOfMonthFormat();
65
        $this->validator->validate($value, $constraint);
66
        $this->buildViolation($constraint->message)
67
            ->setParameter('%string%', $value)
68
            ->assertRaised();
69
    }
70
}
71

tests/Validator/Constraints/CronDayOfWeekFormatValidatorTest.php 1 location

@@ 12-70 (lines=59) @@
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
        ];
32
    }
33
34
    /**
35
     * @dataProvider getValidValues
36
     *
37
     * @param string $value
38
     */
39
    public function testValidValue($value)
40
    {
41
        $constraint = new CronDayOfWeekFormat();
42
        $this->validator->validate($value, $constraint);
43
        $this->assertNoViolation();
44
    }
45
46
    /**
47
     * @return array
48
     */
49
    public function getInvalidValues()
50
    {
51
        return [
52
            [-1],
53
            [8],
54
        ];
55
    }
56
57
    /**
58
     * @dataProvider getInvalidValues
59
     *
60
     * @param string $value
61
     */
62
    public function testInvalidValues($value)
63
    {
64
        $constraint = new CronDayOfWeekFormat();
65
        $this->validator->validate($value, $constraint);
66
        $this->buildViolation($constraint->message)
67
            ->setParameter('%string%', $value)
68
            ->assertRaised();
69
    }
70
}
71

tests/Validator/Constraints/CronHourFormatValidatorTest.php 1 location

@@ 12-70 (lines=59) @@
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
        ];
32
    }
33
34
    /**
35
     * @dataProvider getValidValues
36
     *
37
     * @param string $value
38
     */
39
    public function testValidValue($value)
40
    {
41
        $constraint = new CronHourFormat();
42
        $this->validator->validate($value, $constraint);
43
        $this->assertNoViolation();
44
    }
45
46
    /**
47
     * @return array
48
     */
49
    public function getInvalidValues()
50
    {
51
        return [
52
            [-1],
53
            [24],
54
        ];
55
    }
56
57
    /**
58
     * @dataProvider getInvalidValues
59
     *
60
     * @param string $value
61
     */
62
    public function testInvalidValues($value)
63
    {
64
        $constraint = new CronHourFormat();
65
        $this->validator->validate($value, $constraint);
66
        $this->buildViolation($constraint->message)
67
            ->setParameter('%string%', $value)
68
            ->assertRaised();
69
    }
70
}
71

tests/Validator/Constraints/CronMinuteFormatValidatorTest.php 1 location

@@ 12-70 (lines=59) @@
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
        ];
32
    }
33
34
    /**
35
     * @dataProvider getValidValues
36
     *
37
     * @param string $value
38
     */
39
    public function testValidValue($value)
40
    {
41
        $constraint = new CronMinuteFormat();
42
        $this->validator->validate($value, $constraint);
43
        $this->assertNoViolation();
44
    }
45
46
    /**
47
     * @return array
48
     */
49
    public function getInvalidValues()
50
    {
51
        return [
52
            [-1],
53
            [61],
54
        ];
55
    }
56
57
    /**
58
     * @dataProvider getInvalidValues
59
     *
60
     * @param string $value
61
     */
62
    public function testInvalidValues($value)
63
    {
64
        $constraint = new CronMinuteFormat();
65
        $this->validator->validate($value, $constraint);
66
        $this->buildViolation($constraint->message)
67
            ->setParameter('%string%', $value)
68
            ->assertRaised();
69
    }
70
}
71

tests/Validator/Constraints/CronMonthFormatValidatorTest.php 1 location

@@ 12-71 (lines=60) @@
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
        ];
32
    }
33
34
    /**
35
     * @dataProvider getValidValues
36
     *
37
     * @param string $value
38
     */
39
    public function testValidValue($value)
40
    {
41
        $constraint = new CronMonthFormat();
42
        $this->validator->validate($value, $constraint);
43
        $this->assertNoViolation();
44
    }
45
46
    /**
47
     * @return array
48
     */
49
    public function getInvalidValues()
50
    {
51
        return [
52
            [-1],
53
            [0],
54
            [13],
55
        ];
56
    }
57
58
    /**
59
     * @dataProvider getInvalidValues
60
     *
61
     * @param string $value
62
     */
63
    public function testInvalidValues($value)
64
    {
65
        $constraint = new CronMonthFormat();
66
        $this->validator->validate($value, $constraint);
67
        $this->buildViolation($constraint->message)
68
            ->setParameter('%string%', $value)
69
            ->assertRaised();
70
    }
71
}
72