2
2
3
3
namespace Markup \AddressingBundle \Tests \Validator ;
4
4
5
+ use Markup \AddressingBundle \Validator \LocalizedPostalCodeValidatorClosureProvider ;
5
6
use Markup \AddressingBundle \Validator \PostalCodeValidator ;
7
+ use Symfony \Component \Validator \Constraint ;
8
+ use Symfony \Component \Validator \ConstraintValidatorInterface ;
6
9
7
10
/**
8
11
* A test for a postal code validator that can perform localized postal code validation where available.
@@ -11,24 +14,20 @@ class PostalCodeValidatorTest extends \PHPUnit_Framework_TestCase
11
14
{
12
15
public function setUp ()
13
16
{
14
- $ this ->validatorProvider = $ this ->getMockBuilder ('Markup\AddressingBundle\Validator\LocalizedPostalCodeValidatorClosureProvider ' )
15
- ->disableOriginalConstructor ()
16
- ->getMock ();
17
+ $ this ->validatorProvider = $ this ->createMock (LocalizedPostalCodeValidatorClosureProvider::class);
17
18
$ this ->validator = new PostalCodeValidator ($ this ->validatorProvider );
18
19
}
19
20
20
21
public function testIsValidator ()
21
22
{
22
- $ this ->assertInstanceOf (' Symfony\Component\Validator\ ConstraintValidatorInterface' , $ this ->validator );
23
+ $ this ->assertInstanceOf (ConstraintValidatorInterface::class , $ this ->validator );
23
24
}
24
25
25
26
public function testPassingNonObjectThrowsInvalidArgumentException ()
26
27
{
27
- $ constraint = $ this ->getMockBuilder ('Symfony\Component\Validator\Constraint ' )
28
- ->disableOriginalConstructor ()
29
- ->getMock ();
28
+ $ constraint = $ this ->createMock (Constraint::class);
30
29
$ value = 'POSTCODE ' ;
31
- $ this ->setExpectedException ( ' InvalidArgumentException ' );
30
+ $ this ->expectException (\ InvalidArgumentException::class );
32
31
$ this ->validator ->validate ($ value , $ constraint );
33
32
}
34
33
}
0 commit comments