Failed Conditions
Push — issue#774 ( 057f04...ee9377 )
by Guilherme
05:15
created

E164PhoneNumberValidatorTest::getContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\ValidationBundle\Tests\Validator\Constraints;
12
13
use LoginCidadao\ValidationBundle\Validator\Constraints\E164PhoneNumber;
14
use LoginCidadao\ValidationBundle\Validator\Constraints\E164PhoneNumberValidator;
15
use Symfony\Component\Validator\Context\ExecutionContextInterface;
16
17
class E164PhoneNumberValidatorTest extends \PHPUnit_Framework_TestCase
18
{
19
    public function testValidationSuccess()
20
    {
21
        $validator = new E164PhoneNumberValidator();
22
        $validator->initialize($this->getContext($this->never()));
23
        $validator->validate('+1-541-754-3010', new E164PhoneNumber());
24
        $validator->validate('+55 51 3333-3333', new E164PhoneNumber());
25
    }
26
27
    public function testValidationError()
28
    {
29
        $validator = new E164PhoneNumberValidator();
30
        $validator->initialize($this->getContext($this->once()));
31
        $validator->validate('0123456789012345', new E164PhoneNumber());
32
    }
33
34
    /**
35
     * @return ExecutionContextInterface|\PHPUnit_Framework_MockObject_MockObject
36
     */
37
    private function getContext($violations)
38
    {
39
        $context = $this->getMock('Symfony\Component\Validator\Context\ExecutionContextInterface');
40
        $context->expects($violations)->method('addViolation');
41
42
        return $context;
43
    }
44
}
45