1
0
mirror of synced 2024-12-05 03:06:05 +03:00

set namespace in setup only on CacheProvider instances

This commit is contained in:
Vasek Purchart 2014-06-26 00:32:02 +02:00
parent d98b4a5124
commit ee5f465a2f
2 changed files with 19 additions and 1 deletions

View File

@ -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);

View File

@ -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());
}
}