Skip to content

Commit

Permalink
Configure mock so as to support psr/cache 1
Browse files Browse the repository at this point in the history
psr/cache 1 does not use native return types, and phpdoc is not enough
to obtain a mock that has typed methods.
  • Loading branch information
greg0ire committed Oct 8, 2023
1 parent e0de79e commit aca515e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/Doctrine/Tests/ORM/Query/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,13 @@ public function testGetParameterColonNormalize(): void

public function testGetQueryCacheDriverWithDefaults(): void
{
$cache = $this->createMock(CacheItemPoolInterface::class);
$cache = $this->createMock(CacheItemPoolInterface::class);
$cacheItemMock = $this->createMock(CacheItemInterface::class);
$cacheItemMock->method('set')->willReturnSelf();
$cache
->expects(self::atLeastOnce())
->method('getItem')
->willReturn($this->createMock(CacheItemInterface::class));
->willReturn($cacheItemMock);

$this->entityManager->getConfiguration()->setQueryCache($cache);
$this->entityManager
Expand All @@ -528,11 +530,13 @@ public function testGetQueryCacheDriverWithDefaults(): void

public function testGetQueryCacheDriverWithCacheExplicitlySet(): void
{
$cache = $this->createMock(CacheItemPoolInterface::class);
$cache = $this->createMock(CacheItemPoolInterface::class);
$cacheItemMock = $this->createMock(CacheItemInterface::class);
$cacheItemMock->method('set')->willReturnSelf();
$cache
->expects(self::atLeastOnce())
->method('getItem')
->willReturn($this->createMock(CacheItemInterface::class));
->willReturn($cacheItemMock);

$this->entityManager
->createQuery('select u from ' . CmsUser::class . ' u')
Expand Down

0 comments on commit aca515e

Please sign in to comment.