ConstraintValidatorFactoryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 44
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A tearDown() 0 4 1
A testRegisterValidator() 0 19 1
1
<?php
2
3
namespace Toa\Component\Validator\Tests;
4
5
use Symfony\Component\Validator\Validation;
6
use Toa\Component\Validator\ConstraintValidatorFactory;
7
8
/**
9
 * ConstraintValidatorFactoryTest
10
 *
11
 * @author Enrico Thies <[email protected]>
12
 */
13
class ConstraintValidatorFactoryTest extends \PHPUnit_Framework_TestCase
14
{
15
    /** @var ValidatorBuilder */
16
    protected $builder;
17
18
    /**
19
     * {@inheritdoc}
20
     */
21
    protected function setUp()
22
    {
23
        $this->builder = Validation::createValidatorBuilder();
0 ignored issues
show
Documentation Bug introduced by
It seems like \Symfony\Component\Valid...reateValidatorBuilder() of type object<Symfony\Component...idatorBuilderInterface> is incompatible with the declared type object<Toa\Component\Val...Tests\ValidatorBuilder> of property $builder.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    protected function tearDown()
30
    {
31
        $this->builder = null;
32
    }
33
34
    /**
35
     * @test
36
     */
37
    public function testRegisterValidator()
38
    {
39
        $constraintMock = $this->getMockForAbstractClass(
40
            'Symfony\Component\Validator\Constraint',
41
            array(),
42
            'MockConstraint'
43
        );
44
45
        $validatorMock = $this->getMockForAbstractClass(
46
            'Symfony\Component\Validator\ConstraintValidator',
47
            array(),
48
            'MockConstraintValidator'
49
        );
50
51
        $validatorFactory = new ConstraintValidatorFactory();
52
        $validatorFactory->registerValidator($validatorMock);
53
54
        $this->assertTrue($validatorMock === $validatorFactory->getInstance($constraintMock));
55
    }
56
}
57