13
13
14
14
use Symfony \Component \Cache \Adapter \ArrayAdapter ;
15
15
use Symfony \Component \Serializer \Mapping \ClassMetadata ;
16
+ use Symfony \Component \Serializer \Mapping \Factory \ClassMetadataFactoryInterface ;
16
17
use Symfony \Component \Serializer \Mapping \Factory \CacheClassMetadataFactory ;
18
+ use Symfony \Component \Serializer \Tests \Fixtures \Dummy ;
17
19
18
20
/**
19
21
* @author Kévin Dunglas <[email protected] >
@@ -22,9 +24,9 @@ class CacheMetadataFactoryTest extends \PHPUnit_Framework_TestCase
22
24
{
23
25
public function testGetMetadataFor ()
24
26
{
25
- $ metadata = new ClassMetadata (' Symfony\Component\Serializer\Tests\Fixtures\ Dummy' );
27
+ $ metadata = new ClassMetadata (Dummy::class );
26
28
27
- $ decorated = $ this ->getMock (' Symfony\Component\Serializer\Mapping\Factory\ ClassMetadataFactoryInterface' );
29
+ $ decorated = $ this ->getMock (ClassMetadataFactoryInterface::class );
28
30
$ decorated
29
31
->expects ($ this ->once ())
30
32
->method ('getMetadataFor ' )
@@ -33,14 +35,14 @@ public function testGetMetadataFor()
33
35
34
36
$ factory = new CacheClassMetadataFactory ($ decorated , new ArrayAdapter ());
35
37
36
- $ this ->assertEquals ($ metadata , $ factory ->getMetadataFor (' Symfony\Component\Serializer\Tests\Fixtures\ Dummy' ));
38
+ $ this ->assertEquals ($ metadata , $ factory ->getMetadataFor (Dummy::class ));
37
39
// The second call should retrieve the value from the cache
38
- $ this ->assertEquals ($ metadata , $ factory ->getMetadataFor (' Symfony\Component\Serializer\Tests\Fixtures\ Dummy' ));
40
+ $ this ->assertEquals ($ metadata , $ factory ->getMetadataFor (Dummy::class ));
39
41
}
40
42
41
43
public function testHasMetadataFor ()
42
44
{
43
- $ decorated = $ this ->getMock (' Symfony\Component\Serializer\Mapping\Factory\ ClassMetadataFactoryInterface' );
45
+ $ decorated = $ this ->getMock (ClassMetadataFactoryInterface::class );
44
46
$ decorated
45
47
->expects ($ this ->once ())
46
48
->method ('hasMetadataFor ' )
@@ -49,15 +51,15 @@ public function testHasMetadataFor()
49
51
50
52
$ factory = new CacheClassMetadataFactory ($ decorated , new ArrayAdapter ());
51
53
52
- $ this ->assertTrue ($ factory ->hasMetadataFor (' Symfony\Component\Serializer\Tests\Fixtures\ Dummy' ));
54
+ $ this ->assertTrue ($ factory ->hasMetadataFor (Dummy::class ));
53
55
}
54
56
55
57
/**
56
58
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
57
59
*/
58
60
public function testInvalidClassThrowsException ()
59
61
{
60
- $ decorated = $ this ->getMock (' Symfony\Component\Serializer\Mapping\Factory\ ClassMetadataFactoryInterface' );
62
+ $ decorated = $ this ->getMock (ClassMetadataFactoryInterface::class );
61
63
$ factory = new CacheClassMetadataFactory ($ decorated , new ArrayAdapter ());
62
64
63
65
$ factory ->getMetadataFor ('Not\Exist ' );
0 commit comments