set namespace in setup only on CacheProvider instances
This commit is contained in:
parent
d98b4a5124
commit
ee5f465a2f
@ -21,6 +21,7 @@ namespace Doctrine\ORM\Tools;
|
||||
|
||||
use Doctrine\Common\ClassLoader;
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Common\Cache\CacheProvider;
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Doctrine\ORM\Configuration;
|
||||
use Doctrine\ORM\Mapping\Driver\XmlDriver;
|
||||
@ -144,7 +145,9 @@ class Setup
|
||||
$cache = new ArrayCache();
|
||||
}
|
||||
|
||||
$cache->setNamespace("dc2_" . md5($proxyDir) . "_"); // to avoid collisions
|
||||
if ($cache instanceof CacheProvider) {
|
||||
$cache->setNamespace("dc2_" . md5($proxyDir) . "_"); // to avoid collisions
|
||||
}
|
||||
|
||||
$config = new Configuration();
|
||||
$config->setMetadataCacheImpl($cache);
|
||||
|
@ -89,4 +89,19 @@ class SetupTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertSame($cache, $config->getMetadataCacheImpl());
|
||||
$this->assertSame($cache, $config->getQueryCacheImpl());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-3190
|
||||
*/
|
||||
public function testConfigureCacheCustomInstance()
|
||||
{
|
||||
$cache = $this->getMock('Doctrine\Common\Cache\Cache');
|
||||
$cache->expects($this->never())->method('setNamespace');
|
||||
|
||||
$config = Setup::createConfiguration(array(), true, $cache);
|
||||
|
||||
$this->assertSame($cache, $config->getResultCacheImpl());
|
||||
$this->assertSame($cache, $config->getMetadataCacheImpl());
|
||||
$this->assertSame($cache, $config->getQueryCacheImpl());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user