Skip to content

Commit

Permalink
Merge pull request #9007 from derrabus/test/query-get-cache
Browse files Browse the repository at this point in the history
Add tests for Query::getQueryCacheDriver()
  • Loading branch information
greg0ire authored Sep 13, 2021
2 parents d1cd804 + 85488d6 commit 71f1fdb
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 71f1fdb

Please sign in to comment.