GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( da7376...acbc08 )
by Grzegorz
11:18
created

RegonValidatorTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 92
Duplicated Lines 13.04 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 5
dl 12
loc 92
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A testNullIsValid() 0 6 1
A testEmptyStringIsValid() 0 6 1
A testExpectsStringCompatibleType() 0 4 1
A testValidRegon() 0 6 1
A testInvalidRegon() 12 12 1
A getValidRegonNumbers() 0 7 1
A getInvalidRegonNumbers() 0 14 1
A createValidator() 0 4 1
A getApiVersion() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/*
4
 * This file is part of the Polish Validator Bundle package.
5
 *
6
 * (c) Grzegorz Koziński
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Kiczort\PolishValidatorBundle\Tests\Constraints;
13
14
use Kiczort\PolishValidatorBundle\Validator\Constraints\Regon;
15
use Kiczort\PolishValidatorBundle\Validator\Constraints\RegonValidator;
16
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
17
use Symfony\Component\Validator\Validation;
18
19
/**
20
 * @author Grzegorz Koziński <[email protected]>
21
 */
22
class RegonValidatorTest extends AbstractConstraintValidatorTest
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Component\Valida...ConstraintValidatorTest has been deprecated with message: Since Symfony 3.2, use ConstraintValidatorTestCase instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
23
{
24
    public function testNullIsValid()
25
    {
26
        $this->validator->validate(null, new Regon());
27
28
        $this->assertNoViolation();
29
    }
30
31
    public function testEmptyStringIsValid()
32
    {
33
        $this->validator->validate('', new Regon());
34
35
        $this->assertNoViolation();
36
    }
37
38
    /**
39
     * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
40
     */
41
    public function testExpectsStringCompatibleType()
42
    {
43
        $this->validator->validate(new \stdClass(), new Regon());
44
    }
45
46
    /**
47
     * @dataProvider getValidRegonNumbers
48
     */
49
    public function testValidRegon($regon)
50
    {
51
        $this->validator->validate($regon, new Regon());
52
53
        $this->assertNoViolation();
54
    }
55
56
    /**
57
     * @dataProvider getInvalidRegonNumbers
58
     */
59 View Code Duplication
    public function testInvalidRegon($regon)
0 ignored issues
show
Duplication introduced by
This method 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...
60
    {
61
        $constraint = new Regon(array(
62
            'message' => 'myMessage',
63
        ));
64
65
        $this->validator->validate($regon, $constraint);
66
67
        $this->buildViolation('myMessage')
68
            ->setParameter('{{ value }}', '"' . $regon . '"')
69
            ->assertRaised();
70
    }
71
72
    /**
73
     * @return array
74
     */
75
    public function getValidRegonNumbers()
76
    {
77
        return array(
78
            array('123456785'),
79
            array('12345678512347'),
80
        );
81
    }
82
83
    /**
84
     * @return array
85
     */
86
    public function getInvalidRegonNumbers()
87
    {
88
        return array(
89
            array('12345678512346'),
90
            array('123456786'),
91
            array('12345678a'),
92
            array('1234567890123'),
93
            array('123456789012'),
94
            array('12345678901'),
95
            array('1234567890'),
96
            array('123456789012345'),
97
            array('12345678'),
98
        );
99
    }
100
101
    /**
102
     * @return RegonValidator
103
     */
104
    protected function createValidator()
105
    {
106
        return new RegonValidator();
107
    }
108
109
    protected function getApiVersion()
110
    {
111
        return Validation::API_VERSION_2_5_BC;
112
    }
113
}
114