DDC-1350 - Bugfixes in Doctrine\ORM\Tools\Setup
This commit is contained in:
parent
7ba656f815
commit
8b38e68e23
@ -115,7 +115,7 @@ class Setup
|
|||||||
*/
|
*/
|
||||||
static public function createAnnotationMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null)
|
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));
|
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths));
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ class Setup
|
|||||||
*/
|
*/
|
||||||
static public function createXMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null)
|
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));
|
$config->setMetadataDriverImpl(new XmlDriver($paths));
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ class Setup
|
|||||||
*/
|
*/
|
||||||
static public function createYAMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null)
|
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));
|
$config->setMetadataDriverImpl(new YamlDriver($paths));
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
@ -162,6 +162,7 @@ class Setup
|
|||||||
*/
|
*/
|
||||||
static public function createConfiguration($isDevMode = false, $proxyDir = null, Cache $cache = null)
|
static public function createConfiguration($isDevMode = false, $proxyDir = null, Cache $cache = null)
|
||||||
{
|
{
|
||||||
|
$proxyDir = $proxyDir ?: sys_get_temp_dir();
|
||||||
if ($isDevMode === false && $cache === null) {
|
if ($isDevMode === false && $cache === null) {
|
||||||
if (extension_loaded('apc')) {
|
if (extension_loaded('apc')) {
|
||||||
$cache = new \Doctrine\Common\Cache\ApcCache;
|
$cache = new \Doctrine\Common\Cache\ApcCache;
|
||||||
@ -175,16 +176,16 @@ class Setup
|
|||||||
} else {
|
} else {
|
||||||
$cache = new ArrayCache;
|
$cache = new ArrayCache;
|
||||||
}
|
}
|
||||||
$cache->setNamespace("dc2_"); // to avoid collisions
|
|
||||||
} else if ($cache === null) {
|
} else if ($cache === null) {
|
||||||
$cache = new ArrayCache;
|
$cache = new ArrayCache;
|
||||||
}
|
}
|
||||||
|
$cache->setNamespace("dc2_" . md5($proxyDir) . "_"); // to avoid collisions
|
||||||
|
|
||||||
$config = new Configuration();
|
$config = new Configuration();
|
||||||
$config->setMetadataCacheImpl($cache);
|
$config->setMetadataCacheImpl($cache);
|
||||||
$config->setQueryCacheImpl($cache);
|
$config->setQueryCacheImpl($cache);
|
||||||
$config->setResultCacheImpl($cache);
|
$config->setResultCacheImpl($cache);
|
||||||
$config->setProxyDir( $proxyDir ?: sys_get_temp_dir() );
|
$config->setProxyDir( $proxyDir );
|
||||||
$config->setProxyNamespace('DoctrineProxies');
|
$config->setProxyNamespace('DoctrineProxies');
|
||||||
$config->setAutoGenerateProxyClasses($isDevMode);
|
$config->setAutoGenerateProxyClasses($isDevMode);
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace Doctrine\Tests\ORM\Tools;
|
namespace Doctrine\Tests\ORM\Tools;
|
||||||
|
|
||||||
use Doctrine\ORM\Tools\Setup;
|
use Doctrine\ORM\Tools\Setup;
|
||||||
|
use Doctrine\Common\Cache\ArrayCache;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../TestInit.php';
|
require_once __DIR__ . '/../../TestInit.php';
|
||||||
|
|
||||||
@ -70,6 +71,28 @@ class SetupTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\YamlDriver', $config->getMetadataDriverImpl());
|
$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()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
set_include_path($this->originalIncludePath);
|
set_include_path($this->originalIncludePath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user