Ensure metadata cache is not ArrayCache in production
This commit is contained in:
parent
76e1a469ef
commit
0990d64756
@ -388,6 +388,9 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
if ( ! $this->getMetadataCacheImpl()) {
|
||||
throw ORMException::metadataCacheNotConfigured();
|
||||
}
|
||||
if ($this->getMetadataCacheImpl() instanceof ArrayCache) {
|
||||
throw ORMException::metadataCacheUsesArrayCache();
|
||||
}
|
||||
|
||||
if ($this->getAutoGenerateProxyClasses()) {
|
||||
throw ORMException::proxyClassesAlwaysRegenerating();
|
||||
|
@ -232,6 +232,14 @@ class ORMException extends Exception
|
||||
return new self('Class Metadata Cache is not configured.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ORMException
|
||||
*/
|
||||
public static function metadataCacheUsesArrayCache()
|
||||
{
|
||||
return new self('Metadata Cache uses ArrayCache.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ORMException
|
||||
*/
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Doctrine\Tests\ORM;
|
||||
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Doctrine\ORM\Mapping as AnnotationNamespace;
|
||||
use Doctrine\ORM\Configuration;
|
||||
use Doctrine\ORM\ORMException;
|
||||
@ -136,31 +137,52 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
$this->configuration->getNamedQuery('NonExistingQuery');
|
||||
}
|
||||
|
||||
public function ensureProductionSettings()
|
||||
protected function setProductionSettings($skipCache = false)
|
||||
{
|
||||
$cache = $this->getMock('Doctrine\Common\Cache\Cache');
|
||||
$this->configuration->setAutoGenerateProxyClasses(true);
|
||||
|
||||
try {
|
||||
$this->configuration->ensureProductionSettings();
|
||||
$this->fail('Didn\'t check all production settings');
|
||||
} catch (ORMException $e) {}
|
||||
|
||||
$this->configuration->setQueryCacheImpl($cache);
|
||||
|
||||
try {
|
||||
$this->configuration->ensureProductionSettings();
|
||||
$this->fail('Didn\'t check all production settings');
|
||||
} catch (ORMException $e) {}
|
||||
|
||||
$this->configuration->setMetadataCacheImpl($cache);
|
||||
|
||||
try {
|
||||
$this->configuration->ensureProductionSettings();
|
||||
$this->fail('Didn\'t check all production settings');
|
||||
} catch (ORMException $e) {}
|
||||
|
||||
$this->configuration->setAutoGenerateProxyClasses(false);
|
||||
if ($skipCache !== 'query') {
|
||||
$this->configuration->setQueryCacheImpl($cache);
|
||||
}
|
||||
if ($skipCache !== 'metadata') {
|
||||
$this->configuration->setMetadataCacheImpl($cache);
|
||||
}
|
||||
}
|
||||
|
||||
public function testEnsureProductionSettings()
|
||||
{
|
||||
$this->setProductionSettings();
|
||||
$this->configuration->ensureProductionSettings();
|
||||
}
|
||||
|
||||
public function testEnsureProductionSettingsQueryCache()
|
||||
{
|
||||
$this->setProductionSettings('query');
|
||||
$this->setExpectedException('Doctrine\ORM\ORMException', 'Query Cache is not configured.');
|
||||
$this->configuration->ensureProductionSettings();
|
||||
}
|
||||
|
||||
public function testEnsureProductionSettingsMetadataCache()
|
||||
{
|
||||
$this->setProductionSettings('metadata');
|
||||
$this->setExpectedException('Doctrine\ORM\ORMException', 'Metadata Cache is not configured.');
|
||||
$this->configuration->ensureProductionSettings();
|
||||
}
|
||||
|
||||
public function testEnsureProductionSettingsMetadataArrayCache()
|
||||
{
|
||||
$this->setProductionSettings();
|
||||
$this->configuration->setMetadataCacheImpl(new ArrayCache());
|
||||
$this->setExpectedException('Doctrine\ORM\ORMException', 'Metadata Cache uses ArrayCache.');
|
||||
$this->configuration->ensureProductionSettings();
|
||||
}
|
||||
|
||||
public function testEnsureProductionSettingsAutoGenerateProxyClasses()
|
||||
{
|
||||
$this->setProductionSettings();
|
||||
$this->configuration->setAutoGenerateProxyClasses(true);
|
||||
$this->setExpectedException('Doctrine\ORM\ORMException', 'Proxy Classes are always regenerating.');
|
||||
$this->configuration->ensureProductionSettings();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user