Skip to content

Commit

Permalink
Add tests for Query::getQueryCacheDriver()
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander M. Turek <[email protected]>
  • Loading branch information
derrabus committed Sep 13, 2021
1 parent d1cd804 commit 85488d6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Doctrine/Tests/ORM/Query/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}

0 comments on commit 85488d6

Please sign in to comment.