1
0
mirror of synced 2025-01-19 23:11:41 +03:00

Merge pull request #1071 from VasekPurchart/fix-setup-cache

Setup::createConfiguration breaks Cache interface contract
This commit is contained in:
Marco Pivetta 2014-06-26 02:15:54 +02:00
commit 22d71de2c3
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\ClassLoader;
use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\CacheProvider;
use Doctrine\Common\Cache\ArrayCache; use Doctrine\Common\Cache\ArrayCache;
use Doctrine\ORM\Configuration; use Doctrine\ORM\Configuration;
use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver;
@ -144,7 +145,9 @@ class Setup
$cache = new ArrayCache(); $cache = new ArrayCache();
} }
if ($cache instanceof CacheProvider) {
$cache->setNamespace("dc2_" . md5($proxyDir) . "_"); // to avoid collisions $cache->setNamespace("dc2_" . md5($proxyDir) . "_"); // to avoid collisions
}
$config = new Configuration(); $config = new Configuration();
$config->setMetadataCacheImpl($cache); $config->setMetadataCacheImpl($cache);

View File

@ -89,4 +89,19 @@ class SetupTest extends \Doctrine\Tests\OrmTestCase
$this->assertSame($cache, $config->getMetadataCacheImpl()); $this->assertSame($cache, $config->getMetadataCacheImpl());
$this->assertSame($cache, $config->getQueryCacheImpl()); $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());
}
} }