Merge pull request #1071 from VasekPurchart/fix-setup-cache
Setup::createConfiguration breaks Cache interface contract
This commit is contained in:
commit
22d71de2c3
@ -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);
|
||||||
|
@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user