44
55use Doctrine \Common \Annotations \AnnotationReader ;
66use Doctrine \Common \Annotations \CachedReader ;
7+ use Doctrine \Common \Annotations \PsrCachedReader ;
78use Doctrine \Common \Annotations \Reader ;
89use PHPUnit \Framework \MockObject \MockObject ;
910use Symfony \Bundle \FrameworkBundle \CacheWarmer \AnnotationsCacheWarmer ;
@@ -43,10 +44,16 @@ public function testAnnotationsCacheWarmerWithDebugDisabled()
4344 $ this ->assertFileExists ($ cacheFile );
4445
4546 // 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+ ;
5057 $ refClass = new \ReflectionClass ($ this );
5158 $ reader ->getClassAnnotations ($ refClass );
5259 $ reader ->getMethodAnnotations ($ refClass ->getMethod (__FUNCTION__ ));
@@ -61,12 +68,21 @@ public function testAnnotationsCacheWarmerWithDebugEnabled()
6168 $ warmer = new AnnotationsCacheWarmer ($ reader , $ cacheFile , null , true );
6269 $ warmer ->warmUp ($ this ->cacheDir );
6370 $ this ->assertFileExists ($ cacheFile );
71+
6472 // 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+ ;
7086 $ refClass = new \ReflectionClass ($ this );
7187 $ reader ->getClassAnnotations ($ refClass );
7288 $ reader ->getMethodAnnotations ($ refClass ->getMethod (__FUNCTION__ ));
0 commit comments