Completed
Push — develop ( dc8379...716e11 )
by Alexandr
9s
created

testValidValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Tests\FOA\CronBundle\Validator\Constraints;
4
5
use FOA\CronBundle\Validator\Constraints\CronDayOfMonthFormat;
6
use FOA\CronBundle\Validator\Constraints\CronDayOfMonthFormatValidator;
7
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
8
9
/**
10
 * @author JM Leroux <[email protected]>
11
 */
12 View Code Duplication
class CronDayOfMonthFormatValidatorTest extends AbstractConstraintValidatorTest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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