From 85488d69e203fa69653819042ae7ff27ef88ea9a Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 13 Sep 2021 10:06:55 +0200 Subject: [PATCH] Add tests for Query::getQueryCacheDriver() Signed-off-by: Alexander M. Turek --- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index edcfb6971e9..49d4c0feee5 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -6,6 +6,7 @@ use DateTime; use DateTimeImmutable; +use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\Psr6\DoctrineProvider; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\DBAL\Types\Type; @@ -533,4 +534,25 @@ public function testGetParameterColonNormalize(): void self::assertSame('Benjamin', $query->getParameter(':name')->getValue()); self::assertSame('Benjamin', $query->getParameter('name')->getValue()); } + + public function testGetQueryCacheDriverWithDefaults(): void + { + $cache = $this->createMock(Cache::class); + + $this->entityManager->getConfiguration()->setQueryCacheImpl($cache); + $query = $this->entityManager->createQuery('select u from ' . CmsUser::class . ' u'); + + self::assertSame($cache, $query->getQueryCacheDriver()); + } + + public function testGetQueryCacheDriverWithCacheExplicitlySet(): void + { + $cache = $this->createMock(Cache::class); + + $query = $this->entityManager + ->createQuery('select u from ' . CmsUser::class . ' u') + ->setQueryCacheDriver($cache); + + self::assertSame($cache, $query->getQueryCacheDriver()); + } }