Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore functional cache tests #8981

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

namespace Doctrine\Tests\ORM\Cache;

use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
use Doctrine\ORM\Cache\Region;
use Doctrine\Tests\Mocks\CacheEntryMock;
@@ -19,7 +20,7 @@ abstract class AbstractRegionTest extends OrmFunctionalTestCase
/** @var Region */
protected $region;

/** @var ArrayCache */
/** @var Cache */
protected $cache;

protected function setUp(): void
147 changes: 69 additions & 78 deletions tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php
Original file line number Diff line number Diff line change
@@ -6,17 +6,17 @@

use BadMethodCallException;
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\CacheProvider;
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
use Doctrine\ORM\Cache\CollectionCacheEntry;
use Doctrine\ORM\Cache\Region;
use Doctrine\ORM\Cache\Region\DefaultRegion;
use Doctrine\Tests\Mocks\CacheEntryMock;
use Doctrine\Tests\Mocks\CacheKeyMock;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

use function assert;
use function class_exists;

/**
* @group DDC-2183
@@ -36,15 +36,11 @@ public function testGetters(): void

public function testSharedRegion(): void
{
if (! class_exists(ArrayCache::class)) {
$this->markTestSkipped('Test only applies with doctrine/cache 1.x');
}

$cache = new SharedArrayCache();
$key = new CacheKeyMock('key');
$entry = new CacheEntryMock(['value' => 'foo']);
$region1 = new DefaultRegion('region1', $cache->createChild());
$region2 = new DefaultRegion('region2', $cache->createChild());
$region1 = new DefaultRegion('region1', DoctrineProvider::wrap($cache->createChild()));
$region2 = new DefaultRegion('region2', DoctrineProvider::wrap($cache->createChild()));

$this->assertFalse($region1->contains($key));
$this->assertFalse($region2->contains($key));
@@ -135,76 +131,71 @@ public function corruptedDataDoesNotLeakIntoApplicationWhenGettingMultipleEntrie
}
}

if (class_exists(ArrayCache::class)) {
/**
* Cache provider that offers child cache items (sharing the same array)
*
* Declared as a different class for readability purposes and kept in this file
* to keep its monstrosity contained.
*
* @internal
*/
final class SharedArrayCache extends ArrayCache
/**
* Cache provider that offers child cache items (sharing the same array)
*
* Declared as a different class for readability purposes and kept in this file
* to keep its monstrosity contained.
*
* @internal
*/
final class SharedArrayCache extends ArrayAdapter
{
public function createChild(): CacheItemPoolInterface
{
public function createChild(): Cache
{
return new class ($this) extends CacheProvider {
/** @var ArrayCache */
private $parent;

public function __construct(ArrayCache $parent)
{
$this->parent = $parent;
}

/**
* {@inheritDoc}
*/
protected function doFetch($id)
{
return $this->parent->doFetch($id);
}

/**
* {@inheritDoc}
*/
protected function doContains($id)
{
return $this->parent->doContains($id);
}

/**
* {@inheritDoc}
*/
protected function doSave($id, $data, $lifeTime = 0)
{
return $this->parent->doSave($id, $data, $lifeTime);
}

/**
* {@inheritDoc}
*/
protected function doDelete($id)
{
return $this->parent->doDelete($id);
}

/**
* {@inheritDoc}
*/
protected function doFlush()
{
return $this->parent->doFlush();
}

/**
* {@inheritDoc}
*/
protected function doGetStats()
{
return $this->parent->doGetStats();
}
};
}
return new class ($this) implements CacheItemPoolInterface {
/** @var CacheItemPoolInterface */
private $parent;

public function __construct(CacheItemPoolInterface $parent)
{
$this->parent = $parent;
}

public function getItem($key): CacheItemInterface
{
return $this->parent->getItem($key);
}

public function getItems(array $keys = []): iterable
{
return $this->parent->getItems($keys);
}

public function hasItem($key): bool
{
return $this->parent->hasItem($key);
}

public function clear(): bool
{
return $this->parent->clear();
}

public function deleteItem($key): bool
{
return $this->parent->deleteItem($key);
}

public function deleteItems(array $keys): bool
{
return $this->parent->deleteItems($keys);
}

public function save(CacheItemInterface $item): bool
{
return $this->parent->save($item);
}

public function saveDeferred(CacheItemInterface $item): bool
{
return $this->parent->saveDeferred($item);
}

public function commit(): bool
{
return $this->parent->commit();
}
};
}
}
81 changes: 33 additions & 48 deletions tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php
Original file line number Diff line number Diff line change
@@ -4,113 +4,98 @@

namespace Doctrine\Tests\ORM\Functional;

use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\CacheProvider;
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\Exec\AbstractSqlExecutor;
use Doctrine\ORM\Query\ParserResult;
use Doctrine\Tests\OrmFunctionalTestCase;
use ReflectionProperty;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

use function class_exists;
use function assert;
use function count;

/**
* QueryCacheTest
*/
class QueryCacheTest extends OrmFunctionalTestCase
{
/** @var ReflectionProperty */
private $cacheDataReflection;

protected function setUp(): void
{
if (! class_exists(ArrayCache::class)) {
$this->markTestSkipped('Test only applies with doctrine/cache 1.x');
}

$this->cacheDataReflection = new ReflectionProperty(ArrayCache::class, 'data');
$this->cacheDataReflection->setAccessible(true);

$this->useModelSet('cms');

parent::setUp();
}

private function getCacheSize(ArrayCache $cache): int
{
return count($this->cacheDataReflection->getValue($cache));
}

public function testQueryCacheDependsOnHints(): Query
public function testQueryCacheDependsOnHints(): array
{
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');

$cache = new ArrayCache();
$query->setQueryCacheDriver($cache);
$cache = new ArrayAdapter();
$query->setQueryCacheDriver(DoctrineProvider::wrap($cache));

$query->getResult();
$this->assertEquals(1, $this->getCacheSize($cache));
self::assertCount(2, $cache->getValues());

$query->setHint('foo', 'bar');

$query->getResult();
$this->assertEquals(2, $this->getCacheSize($cache));
self::assertCount(3, $cache->getValues());

return $query;
return [$query, $cache];
}

/**
* @param <type> $query
*
* @depends testQueryCacheDependsOnHints
*/
public function testQueryCacheDependsOnFirstResult($query): void
public function testQueryCacheDependsOnFirstResult(array $previous): void
{
$cache = $query->getQueryCacheDriver();
$cacheCount = $this->getCacheSize($cache);
[$query, $cache] = $previous;
assert($query instanceof Query);
assert($cache instanceof ArrayAdapter);

$cacheCount = count($cache->getValues());

$query->setFirstResult(10);
$query->setMaxResults(9999);

$query->getResult();
$this->assertEquals($cacheCount + 1, $this->getCacheSize($cache));
self::assertCount($cacheCount + 1, $cache->getValues());
}

/**
* @param <type> $query
*
* @depends testQueryCacheDependsOnHints
*/
public function testQueryCacheDependsOnMaxResults($query): void
public function testQueryCacheDependsOnMaxResults(array $previous): void
{
$cache = $query->getQueryCacheDriver();
$cacheCount = $this->getCacheSize($cache);
[$query, $cache] = $previous;
assert($query instanceof Query);
assert($cache instanceof ArrayAdapter);

$cacheCount = count($cache->getValues());

$query->setMaxResults(10);

$query->getResult();
$this->assertEquals($cacheCount + 1, $this->getCacheSize($cache));
self::assertCount($cacheCount + 1, $cache->getValues());
}

/**
* @param <type> $query
*
* @depends testQueryCacheDependsOnHints
*/
public function testQueryCacheDependsOnHydrationMode($query): void
public function testQueryCacheDependsOnHydrationMode(array $previous): void
{
$cache = $query->getQueryCacheDriver();
$cacheCount = $this->getCacheSize($cache);
[$query, $cache] = $previous;
assert($query instanceof Query);
assert($cache instanceof ArrayAdapter);

$cacheCount = count($cache->getValues());

$query->getArrayResult();
$this->assertEquals($cacheCount + 1, $this->getCacheSize($cache));
self::assertCount($cacheCount + 1, $cache->getValues());
}

public function testQueryCacheNoHitSaveParserResult(): void
{
$this->_em->getConfiguration()->setQueryCacheImpl(new ArrayCache());
$this->_em->getConfiguration()->setQueryCacheImpl($this->createMock(Cache::class));

$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');

@@ -128,7 +113,7 @@ public function testQueryCacheNoHitSaveParserResult(): void

public function testQueryCacheHitDoesNotSaveParserResult(): void
{
$this->_em->getConfiguration()->setQueryCacheImpl(new ArrayCache());
$this->_em->getConfiguration()->setQueryCacheImpl($this->createMock(Cache::class));

$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');

@@ -167,6 +152,6 @@ public function testQueryCacheHitDoesNotSaveParserResult(): void

$query->setQueryCacheDriver($cache);

$users = $query->getResult();
$query->getResult();
}
}
121 changes: 58 additions & 63 deletions tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php
Original file line number Diff line number Diff line change
@@ -2,42 +2,27 @@

namespace Doctrine\Tests\ORM\Functional;

use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
use Doctrine\ORM\NativeQuery;
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Tests\Models\CMS\CmsArticle;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\OrmFunctionalTestCase;
use ReflectionProperty;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

use function class_exists;
use function assert;
use function count;
use function iterator_to_array;

/**
* ResultCacheTest
*/
class ResultCacheTest extends OrmFunctionalTestCase
{
/** @var ReflectionProperty */
private $cacheDataReflection;

protected function setUp(): void
{
if (! class_exists(ArrayCache::class)) {
$this->markTestSkipped('Test only applies with doctrine/cache 1.x');
}

$this->cacheDataReflection = new ReflectionProperty(ArrayCache::class, 'data');
$this->cacheDataReflection->setAccessible(true);
$this->useModelSet('cms');
parent::setUp();
}

private function getCacheSize(ArrayCache $cache): int
{
return count($this->cacheDataReflection->getValue($cache));
parent::setUp();
}

public function testResultCache(): void
@@ -53,7 +38,7 @@ public function testResultCache(): void

$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');

$cache = new ArrayCache();
$cache = DoctrineProvider::wrap(new ArrayAdapter());

$query->setResultCacheDriver($cache)->setResultCacheId('my_cache_id');

@@ -62,7 +47,7 @@ public function testResultCache(): void
$users = $query->getResult();

$this->assertTrue($cache->contains('my_cache_id'));
$this->assertEquals(1, count($users));
$this->assertCount(1, $users);
$this->assertEquals('Roman', $users[0]->name);

$this->_em->clear();
@@ -73,43 +58,43 @@ public function testResultCache(): void
$users = $query2->getResult();

$this->assertTrue($cache->contains('my_cache_id'));
$this->assertEquals(1, count($users));
$this->assertCount(1, $users);
$this->assertEquals('Roman', $users[0]->name);
}

public function testSetResultCacheId(): void
{
$cache = new ArrayCache();
$cache = DoctrineProvider::wrap(new ArrayAdapter());
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');

$query->setResultCacheDriver($cache);
$query->setResultCacheId('testing_result_cache_id');

$this->assertFalse($cache->contains('testing_result_cache_id'));

$users = $query->getResult();
$query->getResult();

$this->assertTrue($cache->contains('testing_result_cache_id'));
}

public function testUseResultCacheTrue(): void
{
$cache = new ArrayCache();
$cache = DoctrineProvider::wrap(new ArrayAdapter());
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');

$query->useResultCache(true);
$query->setResultCacheDriver($cache);
$query->setResultCacheId('testing_result_cache_id');
$users = $query->getResult();
$query->getResult();

$this->assertTrue($cache->contains('testing_result_cache_id'));

$this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache());
$this->_em->getConfiguration()->setResultCacheImpl($this->createMock(Cache::class));
}

public function testUseResultCacheFalse(): void
{
$cache = new ArrayCache();
$cache = DoctrineProvider::wrap(new ArrayAdapter());
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');

$query->setResultCacheDriver($cache);
@@ -119,15 +104,15 @@ public function testUseResultCacheFalse(): void

$this->assertFalse($cache->contains('testing_result_cache_id'));

$this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache());
$this->_em->getConfiguration()->setResultCacheImpl($this->createMock(Cache::class));
}

/**
* @group DDC-1026
*/
public function testUseResultCacheParams(): void
{
$cache = new ArrayCache();
$cache = DoctrineProvider::wrap(new ArrayAdapter());
$sqlCount = count($this->_sqlLoggerStack->queries);
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux WHERE ux.id = ?1');

@@ -161,7 +146,7 @@ public function testUseResultCacheParams(): void

public function testEnableResultCache(): void
{
$cache = new ArrayCache();
$cache = DoctrineProvider::wrap(new ArrayAdapter());
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');

$query->enableResultCache();
@@ -171,12 +156,12 @@ public function testEnableResultCache(): void

$this->assertTrue($cache->contains('testing_result_cache_id'));

$this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache());
$this->_em->getConfiguration()->setResultCacheImpl($this->createMock(Cache::class));
}

public function testEnableResultCacheWithIterable(): void
{
$cache = new ArrayCache();
$cache = DoctrineProvider::wrap(new ArrayAdapter());
$expectedSQLCount = count($this->_sqlLoggerStack->queries) + 1;

$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');
@@ -205,15 +190,15 @@ public function testEnableResultCacheWithIterable(): void
'Expected query to be cached'
);

$this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache());
$this->_em->getConfiguration()->setResultCacheImpl($this->createMock(Cache::class));
}

/**
* @group DDC-1026
*/
public function testEnableResultCacheParams(): void
{
$cache = new ArrayCache();
$cache = DoctrineProvider::wrap(new ArrayAdapter());
$sqlCount = count($this->_sqlLoggerStack->queries);
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux WHERE ux.id = ?1');

@@ -247,7 +232,7 @@ public function testEnableResultCacheParams(): void

public function testDisableResultCache(): void
{
$cache = new ArrayCache();
$cache = DoctrineProvider::wrap(new ArrayAdapter());
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');

$query->setResultCacheDriver($cache);
@@ -257,13 +242,14 @@ public function testDisableResultCache(): void

$this->assertFalse($cache->contains('testing_result_cache_id'));

$this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache());
$this->_em->getConfiguration()->setResultCacheImpl($this->createMock(Cache::class));
}

public function testNativeQueryResultCaching(): NativeQuery
public function testNativeQueryResultCaching(): array
{
$cache = new ArrayCache();
$rsm = new ResultSetMapping();
$adapter = new ArrayAdapter();
$cache = DoctrineProvider::wrap($adapter);
$rsm = new ResultSetMapping();

$rsm->addScalarResult('id', 'u', 'integer');

@@ -272,55 +258,64 @@ public function testNativeQueryResultCaching(): NativeQuery
$query->setParameter(1, 10);
$query->setResultCacheDriver($cache)->enableResultCache();

$this->assertEquals(0, $this->getCacheSize($cache));
$this->assertCount(0, $adapter->getValues());

$query->getResult();

$this->assertEquals(1, $this->getCacheSize($cache));
$this->assertCount(2, $adapter->getValues());

return $query;
return [$query, $adapter];
}

/**
* @depends testNativeQueryResultCaching
*/
public function testResultCacheNotDependsOnQueryHints(NativeQuery $query): void
public function testResultCacheNotDependsOnQueryHints(array $previous): void
{
$cache = $query->getResultCacheDriver();
$cacheCount = $this->getCacheSize($cache);
[$query, $adapter] = $previous;
assert($query instanceof NativeQuery);
assert($adapter instanceof ArrayAdapter);

$cacheCount = count($adapter->getValues());

$query->setHint('foo', 'bar');
$query->getResult();

$this->assertEquals($cacheCount, $this->getCacheSize($cache));
$this->assertCount($cacheCount, $adapter->getValues());
}

/**
* @depends testNativeQueryResultCaching
*/
public function testResultCacheDependsOnParameters(NativeQuery $query): void
public function testResultCacheDependsOnParameters(array $previous): void
{
$cache = $query->getResultCacheDriver();
$cacheCount = $this->getCacheSize($cache);
[$query, $adapter] = $previous;
assert($query instanceof NativeQuery);
assert($adapter instanceof ArrayAdapter);

$cacheCount = count($adapter->getValues());

$query->setParameter(1, 50);
$query->getResult();

$this->assertEquals($cacheCount + 1, $this->getCacheSize($cache));
$this->assertCount($cacheCount + 1, $adapter->getValues());
}

/**
* @depends testNativeQueryResultCaching
*/
public function testResultCacheNotDependsOnHydrationMode(NativeQuery $query): void
public function testResultCacheNotDependsOnHydrationMode(array $previous): void
{
$cache = $query->getResultCacheDriver();
$cacheCount = $this->getCacheSize($cache);
[$query, $adapter] = $previous;
assert($query instanceof NativeQuery);
assert($adapter instanceof ArrayAdapter);

$cacheCount = count($adapter->getValues());

$this->assertNotEquals(Query::HYDRATE_ARRAY, $query->getHydrationMode());
$query->getArrayResult();

$this->assertEquals($cacheCount, $this->getCacheSize($cache));
$this->assertCount($cacheCount, $adapter->getValues());
}

/**
@@ -351,34 +346,34 @@ public function testResultCacheWithObjectParameter(): void
$query = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = ?1');
$query->setParameter(1, $user1);

$cache = new ArrayCache();
$cache = new ArrayAdapter();

$query->setResultCacheDriver($cache)->enableResultCache();
$query->setResultCacheDriver(DoctrineProvider::wrap($cache))->enableResultCache();

$articles = $query->getResult();

$this->assertEquals(1, count($articles));
$this->assertCount(1, $articles);
$this->assertEquals('baz', $articles[0]->topic);

$this->_em->clear();

$query2 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = ?1');
$query2->setParameter(1, $user1);

$query2->setResultCacheDriver($cache)->enableResultCache();
$query2->setResultCacheDriver(DoctrineProvider::wrap($cache))->enableResultCache();

$articles = $query2->getResult();

$this->assertEquals(1, count($articles));
$this->assertCount(1, $articles);
$this->assertEquals('baz', $articles[0]->topic);

$query3 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = ?1');
$query3->setParameter(1, $user2);

$query3->setResultCacheDriver($cache)->enableResultCache();
$query3->setResultCacheDriver(DoctrineProvider::wrap($cache))->enableResultCache();

$articles = $query3->getResult();

$this->assertEquals(0, count($articles));
$this->assertCount(0, $articles);
}
}
24 changes: 8 additions & 16 deletions tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

namespace Doctrine\Tests\ORM\Functional;

use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Configuration;
@@ -30,9 +30,8 @@
use Doctrine\Tests\OrmFunctionalTestCase;
use InvalidArgumentException;
use ReflectionMethod;
use ReflectionProperty;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

use function class_exists;
use function count;
use function in_array;
use function serialize;
@@ -397,31 +396,24 @@ public function testSQLFilterToString(): void

public function testQueryCacheDependsOnFilters(): void
{
if (! class_exists(ArrayCache::class)) {
$this->markTestSkipped('Test only applies with doctrine/cache 1.x');
}

$cacheDataReflection = new ReflectionProperty(ArrayCache::class, 'data');
$cacheDataReflection->setAccessible(true);

$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');

$cache = new ArrayCache();
$query->setQueryCacheDriver($cache);
$cache = new ArrayAdapter();
$query->setQueryCacheDriver(DoctrineProvider::wrap($cache));

$query->getResult();
$this->assertEquals(1, count($cacheDataReflection->getValue($cache)));
$this->assertCount(2, $cache->getValues());

$conf = $this->_em->getConfiguration();
$conf->addFilter('locale', '\Doctrine\Tests\ORM\Functional\MyLocaleFilter');
$conf->addFilter('locale', MyLocaleFilter::class);
$this->_em->getFilters()->enable('locale');

$query->getResult();
$this->assertEquals(2, count($cacheDataReflection->getValue($cache)));
$this->assertCount(3, $cache->getValues());

// Another time doesn't add another cache entry
$query->getResult();
$this->assertEquals(2, count($cacheDataReflection->getValue($cache)));
$this->assertCount(3, $cache->getValues());
}

public function testQueryGenerationDependsOnFilters(): void
14 changes: 2 additions & 12 deletions tests/Doctrine/Tests/ORM/Tools/SetupTest.php
Original file line number Diff line number Diff line change
@@ -12,11 +12,9 @@
use Doctrine\ORM\Mapping\Driver\XmlDriver;
use Doctrine\ORM\Mapping\Driver\YamlDriver;
use Doctrine\ORM\Tools\Setup;
use Doctrine\Tests\Common\Cache\ArrayCache;
use Doctrine\Tests\OrmTestCase;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

use function class_exists;
use function count;
use function get_include_path;
use function method_exists;
@@ -93,11 +91,7 @@ public function testYAMLConfiguration(): void
*/
public function testCacheNamespaceShouldBeGeneratedWhenCacheIsGivenButHasNoNamespace(): void
{
if (! class_exists(ArrayCache::class)) {
$this->markTestSkipped('Only applies when using doctrine/cache directly');
}

$config = Setup::createConfiguration(false, '/foo', new ArrayCache());
$config = Setup::createConfiguration(false, '/foo', DoctrineProvider::wrap(new ArrayAdapter()));
$cache = $config->getMetadataCacheImpl();

self::assertSame('dc2_1effb2475fcfba4f9e8b8a1dbc8f3caf_', $cache->getNamespace());
@@ -108,11 +102,7 @@ public function testCacheNamespaceShouldBeGeneratedWhenCacheIsGivenButHasNoNames
*/
public function testConfiguredCacheNamespaceShouldBeUsedAsPrefixOfGeneratedNamespace(): void
{
if (! class_exists(ArrayCache::class)) {
$this->markTestSkipped('Only applies when using doctrine/cache directly');
}

$originalCache = new ArrayCache();
$originalCache = DoctrineProvider::wrap(new ArrayAdapter());
$originalCache->setNamespace('foo');

$config = Setup::createConfiguration(false, '/foo', $originalCache);