Code Duplication    Length = 65-65 lines in 2 locations

Tests/Validator/Constraints/CNPJValidatorTest.php 1 location

@@ 10-74 (lines=65) @@
7
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
8
use Symfony\Component\Validator\Validation;
9
10
class CNPJValidatorTest extends AbstractConstraintValidatorTest
11
{
12
    protected function getApiVersion()
13
    {
14
        return Validation::API_VERSION_2_5;
15
    }
16
17
    protected function createValidator()
18
    {
19
        return new CNPJValidator();
20
    }
21
22
    public function testNullIsValid()
23
    {
24
        $this->validator->validate(null, new CNPJ());
25
        $this->assertNoViolation();
26
    }
27
28
    public function testEmptyStringIsValid()
29
    {
30
        $this->validator->validate('', new CNPJ());
31
        $this->assertNoViolation();
32
    }
33
34
    public function getInvalidCNPJs()
35
    {
36
        return array(
37
            array('11.111.111/1111-11'),
38
            array('22.222.222/2222-22'),
39
            array('66.121.538/0001-00'),
40
        );
41
    }
42
43
    /**
44
     * @dataProvider getInvalidCNPJs
45
     */
46
    public function testInvalidCNPJs($cnpj)
47
    {
48
        $constraint = new CNPJ(array(
49
            'message' => 'testMessage',
50
        ));
51
        $this->validator->validate($cnpj, $constraint);
52
        $this->buildViolation('testMessage')
53
            ->setParameter('{{ value }}', '"'.$cnpj.'"')
54
            ->assertRaised();
55
    }
56
57
    public function getValidCNPJs()
58
    {
59
        return array(
60
            array('06.785.165/0001-00'),
61
            array('66.121.538/0001-62'),
62
            array('32.771.783/0001-01'),
63
        );
64
    }
65
66
    /**
67
     * @dataProvider getValidCNPJs
68
     */
69
    public function testValidCNPJs($cnpj)
70
    {
71
        $this->validator->validate($cnpj, new CNPJ());
72
        $this->assertNoViolation();
73
    }
74
}
75

Tests/Validator/Constraints/CPFValidatorTest.php 1 location

@@ 12-76 (lines=65) @@
9
10
/**
11
 */
12
class CPFValidatorTest extends AbstractConstraintValidatorTest
13
{
14
    protected function getApiVersion()
15
    {
16
        return Validation::API_VERSION_2_5;
17
    }
18
19
    protected function createValidator()
20
    {
21
        return new CPFValidator();
22
    }
23
24
    public function testNullIsValid()
25
    {
26
        $this->validator->validate(null, new CPF());
27
        $this->assertNoViolation();
28
    }
29
30
    public function testEmptyStringIsValid()
31
    {
32
        $this->validator->validate('', new CPF());
33
        $this->assertNoViolation();
34
    }
35
36
    public function getInvalidCPFs()
37
    {
38
        return array(
39
            array('111.111.111-11'),
40
            array('222.222.222-22'),
41
            array('398.682.528-23'),
42
        );
43
    }
44
45
    /**
46
     * @dataProvider getInvalidCPFs
47
     */
48
    public function testInvalidCPFs($cpf)
49
    {
50
        $constraint = new CPF(array(
51
            'message' => 'testMessage',
52
        ));
53
        $this->validator->validate($cpf, $constraint);
54
        $this->buildViolation('testMessage')
55
            ->setParameter('{{ value }}', '"'.$cpf.'"')
56
            ->assertRaised();
57
    }
58
59
    public function getValidCPFs()
60
    {
61
        return array(
62
            array('398.682.528-22'),
63
            array('534.005.933-20'),
64
            array('235.515.623-93'),
65
        );
66
    }
67
68
    /**
69
     * @dataProvider getValidCPFs
70
     */
71
    public function testValidCPFs($cpf)
72
    {
73
        $this->validator->validate($cpf, new CPF());
74
        $this->assertNoViolation();
75
    }
76
}
77