diff --git a/lib/Doctrine/ORM/Tools/Setup.php b/lib/Doctrine/ORM/Tools/Setup.php index 11992a96e..79d4670ad 100644 --- a/lib/Doctrine/ORM/Tools/Setup.php +++ b/lib/Doctrine/ORM/Tools/Setup.php @@ -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); diff --git a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php index 3a6055f1e..20ad5ee0a 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php @@ -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()); + } }