diff --git a/lib/Doctrine/ORM/Tools/Setup.php b/lib/Doctrine/ORM/Tools/Setup.php index 33bdbf53a..ddfc552e8 100644 --- a/lib/Doctrine/ORM/Tools/Setup.php +++ b/lib/Doctrine/ORM/Tools/Setup.php @@ -115,7 +115,7 @@ class Setup */ static public function createAnnotationMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null) { - $config = self::createConfiguration($isDevMode, $cache, $proxyDir); + $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths)); return $config; } @@ -131,7 +131,7 @@ class Setup */ static public function createXMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null) { - $config = self::createConfiguration($isDevMode, $cache, $proxyDir); + $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl(new XmlDriver($paths)); return $config; } @@ -147,7 +147,7 @@ class Setup */ static public function createYAMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null) { - $config = self::createConfiguration($isDevMode, $cache, $proxyDir); + $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl(new YamlDriver($paths)); return $config; } @@ -162,6 +162,7 @@ class Setup */ static public function createConfiguration($isDevMode = false, $proxyDir = null, Cache $cache = null) { + $proxyDir = $proxyDir ?: sys_get_temp_dir(); if ($isDevMode === false && $cache === null) { if (extension_loaded('apc')) { $cache = new \Doctrine\Common\Cache\ApcCache; @@ -175,16 +176,16 @@ class Setup } else { $cache = new ArrayCache; } - $cache->setNamespace("dc2_"); // to avoid collisions } else if ($cache === null) { $cache = new ArrayCache; } + $cache->setNamespace("dc2_" . md5($proxyDir) . "_"); // to avoid collisions $config = new Configuration(); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); $config->setResultCacheImpl($cache); - $config->setProxyDir( $proxyDir ?: sys_get_temp_dir() ); + $config->setProxyDir( $proxyDir ); $config->setProxyNamespace('DoctrineProxies'); $config->setAutoGenerateProxyClasses($isDevMode); diff --git a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php index 27a1f413c..643464df0 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\ORM\Tools; use Doctrine\ORM\Tools\Setup; +use Doctrine\Common\Cache\ArrayCache; require_once __DIR__ . '/../../TestInit.php'; @@ -69,6 +70,28 @@ class SetupTest extends \Doctrine\Tests\OrmTestCase $this->assertInstanceOf('Doctrine\ORM\Configuration', $config); $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\YamlDriver', $config->getMetadataDriverImpl()); } + + /** + * @group DDC-1350 + */ + public function testConfigureProxyDir() + { + $config = Setup::createAnnotationMetadataConfiguration(array(), true, "/foo"); + $this->assertEquals('/foo', $config->getProxyDir()); + } + + /** + * @group DDC-1350 + */ + public function testConfigureCache() + { + $cache = new ArrayCache(); + $config = Setup::createAnnotationMetadataConfiguration(array(), true, null, $cache); + + $this->assertSame($cache, $config->getResultCacheImpl()); + $this->assertSame($cache, $config->getMetadataCacheImpl()); + $this->assertSame($cache, $config->getQueryCacheImpl()); + } public function tearDown() {