Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2c7c4bd

Browse files
committed
Fixed tests
1 parent b8968d4 commit 2c7c4bd

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Doctrine\Common\Annotations\AnnotationReader;
66
use Doctrine\Common\Annotations\CachedReader;
7+
use Doctrine\Common\Annotations\PsrCachedReader;
78
use Doctrine\Common\Annotations\Reader;
89
use PHPUnit\Framework\MockObject\MockObject;
910
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
@@ -42,10 +43,13 @@ public function testAnnotationsCacheWarmerWithDebugDisabled()
4243
$this->assertFileExists($cacheFile);
4344

4445
// 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+
4953
$refClass = new \ReflectionClass($this);
5054
$reader->getClassAnnotations($refClass);
5155
$reader->getMethodAnnotations($refClass->getMethod(__FUNCTION__));
@@ -60,12 +64,15 @@ public function testAnnotationsCacheWarmerWithDebugEnabled()
6064
$warmer = new AnnotationsCacheWarmer($reader, $cacheFile, null, true);
6165
$warmer->warmUp($this->cacheDir);
6266
$this->assertFileExists($cacheFile);
67+
6368
// 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+
6976
$refClass = new \ReflectionClass($this);
7077
$reader->getClassAnnotations($refClass);
7178
$reader->getMethodAnnotations($refClass->getMethod(__FUNCTION__));

0 commit comments

Comments
 (0)