4
4
5
5
use Doctrine \Common \Annotations \AnnotationReader ;
6
6
use Doctrine \Common \Annotations \CachedReader ;
7
+ use Doctrine \Common \Annotations \PsrCachedReader ;
7
8
use Doctrine \Common \Annotations \Reader ;
8
9
use PHPUnit \Framework \MockObject \MockObject ;
9
10
use Symfony \Bundle \FrameworkBundle \CacheWarmer \AnnotationsCacheWarmer ;
@@ -43,10 +44,16 @@ public function testAnnotationsCacheWarmerWithDebugDisabled()
43
44
$ this ->assertFileExists ($ cacheFile );
44
45
45
46
// Assert cache is valid
46
- $ reader = new CachedReader (
47
- $ this ->getReadOnlyReader (),
48
- new DoctrineProvider (new PhpArrayAdapter ($ cacheFile , new NullAdapter ()))
49
- );
47
+ $ reader = class_exists (PsrCachedReader::class)
48
+ ? new PsrCachedReader (
49
+ $ this ->getReadOnlyReader (),
50
+ new PhpArrayAdapter ($ cacheFile , new NullAdapter ())
51
+ )
52
+ : new CachedReader (
53
+ $ this ->getReadOnlyReader (),
54
+ new DoctrineProvider (new PhpArrayAdapter ($ cacheFile , new NullAdapter ()))
55
+ )
56
+ ;
50
57
$ refClass = new \ReflectionClass ($ this );
51
58
$ reader ->getClassAnnotations ($ refClass );
52
59
$ reader ->getMethodAnnotations ($ refClass ->getMethod (__FUNCTION__ ));
@@ -61,12 +68,21 @@ public function testAnnotationsCacheWarmerWithDebugEnabled()
61
68
$ warmer = new AnnotationsCacheWarmer ($ reader , $ cacheFile , null , true );
62
69
$ warmer ->warmUp ($ this ->cacheDir );
63
70
$ this ->assertFileExists ($ cacheFile );
71
+
64
72
// Assert cache is valid
65
- $ reader = new CachedReader (
66
- $ this ->getReadOnlyReader (),
67
- new DoctrineProvider (new PhpArrayAdapter ($ cacheFile , new NullAdapter ())),
68
- true
69
- );
73
+ $ phpArrayAdapter = new PhpArrayAdapter ($ cacheFile , new NullAdapter ());
74
+ $ reader = class_exists (PsrCachedReader::class)
75
+ ? new PsrCachedReader (
76
+ $ this ->getReadOnlyReader (),
77
+ $ phpArrayAdapter ,
78
+ true
79
+ )
80
+ : new CachedReader (
81
+ $ this ->getReadOnlyReader (),
82
+ new DoctrineProvider ($ phpArrayAdapter ),
83
+ true
84
+ )
85
+ ;
70
86
$ refClass = new \ReflectionClass ($ this );
71
87
$ reader ->getClassAnnotations ($ refClass );
72
88
$ reader ->getMethodAnnotations ($ refClass ->getMethod (__FUNCTION__ ));
0 commit comments