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 ;
@@ -42,10 +43,13 @@ public function testAnnotationsCacheWarmerWithDebugDisabled()
42
43
$ this ->assertFileExists ($ cacheFile );
43
44
44
45
// Assert cache is valid
45
- $ reader = new CachedReader (
46
- $ this ->getReadOnlyReader (),
47
- new DoctrineProvider (new PhpArrayAdapter ($ cacheFile , new NullAdapter ()))
48
- );
46
+ $ psr6Cache = new PhpArrayAdapter ($ cacheFile , new NullAdapter ());
47
+ if (class_exists (PsrCachedReader::class)) {
48
+ $ reader = new PsrCachedReader ($ this ->getReadOnlyReader (), $ psr6Cache );
49
+ } else {
50
+ $ reader = new CachedReader ($ this ->getReadOnlyReader (), new DoctrineProvider ($ psr6Cache ));
51
+ }
52
+
49
53
$ refClass = new \ReflectionClass ($ this );
50
54
$ reader ->getClassAnnotations ($ refClass );
51
55
$ reader ->getMethodAnnotations ($ refClass ->getMethod (__FUNCTION__ ));
@@ -60,12 +64,15 @@ public function testAnnotationsCacheWarmerWithDebugEnabled()
60
64
$ warmer = new AnnotationsCacheWarmer ($ reader , $ cacheFile , null , true );
61
65
$ warmer ->warmUp ($ this ->cacheDir );
62
66
$ this ->assertFileExists ($ cacheFile );
67
+
63
68
// Assert cache is valid
64
- $ reader = new CachedReader (
65
- $ this ->getReadOnlyReader (),
66
- new DoctrineProvider (new PhpArrayAdapter ($ cacheFile , new NullAdapter ())),
67
- true
68
- );
69
+ $ psr6Cache = new PhpArrayAdapter ($ cacheFile , new NullAdapter ());
70
+ if (class_exists (PsrCachedReader::class)) {
71
+ $ reader = new PsrCachedReader ($ this ->getReadOnlyReader (), $ psr6Cache );
72
+ } else {
73
+ $ reader = new CachedReader ($ this ->getReadOnlyReader (), new DoctrineProvider ($ psr6Cache ));
74
+ }
75
+
69
76
$ refClass = new \ReflectionClass ($ this );
70
77
$ reader ->getClassAnnotations ($ refClass );
71
78
$ reader ->getMethodAnnotations ($ refClass ->getMethod (__FUNCTION__ ));
0 commit comments