Code style fixes.
This commit is contained in:
parent
0990d64756
commit
c973d8df1a
3 changed files with 43 additions and 11 deletions
|
@ -385,11 +385,14 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
|||
throw ORMException::queryCacheNotConfigured();
|
||||
}
|
||||
|
||||
if ( ! $this->getMetadataCacheImpl()) {
|
||||
$metadataCacheImpl = $this->getMetadataCacheImpl();
|
||||
|
||||
if ( ! $metadataCacheImpl) {
|
||||
throw ORMException::metadataCacheNotConfigured();
|
||||
}
|
||||
if ($this->getMetadataCacheImpl() instanceof ArrayCache) {
|
||||
throw ORMException::metadataCacheUsesArrayCache();
|
||||
|
||||
if ($metadataCacheImpl instanceof ArrayCache) {
|
||||
throw ORMException::metadataCacheUsesNonPersistentCache($metadataCacheImpl);
|
||||
}
|
||||
|
||||
if ($this->getAutoGenerateProxyClasses()) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
namespace Doctrine\ORM;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
|
@ -233,11 +234,13 @@ class ORMException extends Exception
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Cache $cache
|
||||
*
|
||||
* @return ORMException
|
||||
*/
|
||||
public static function metadataCacheUsesArrayCache()
|
||||
public static function metadataCacheUsesNonPersistentCache(Cache $cache)
|
||||
{
|
||||
return new self('Metadata Cache uses ArrayCache.');
|
||||
return new self('Metadata Cache uses a non-persistent cache driver, ' . get_class($cache) . '.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Doctrine\Tests\ORM;
|
||||
|
||||
use Doctrine\Common\Proxy\AbstractProxyFactory;
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Doctrine\ORM\Mapping as AnnotationNamespace;
|
||||
use Doctrine\ORM\Configuration;
|
||||
|
@ -137,15 +138,22 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
|||
$this->configuration->getNamedQuery('NonExistingQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures $this->configuration to use production settings.
|
||||
*
|
||||
* @param boolean $skipCache Do not configure a cache of this type, either "query" or "metadata".
|
||||
*/
|
||||
protected function setProductionSettings($skipCache = false)
|
||||
{
|
||||
$this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_NEVER);
|
||||
|
||||
$cache = $this->getMock('Doctrine\Common\Cache\Cache');
|
||||
|
||||
$this->configuration->setAutoGenerateProxyClasses(false);
|
||||
if ($skipCache !== 'query') {
|
||||
if ('query' !== $skipCache) {
|
||||
$this->configuration->setQueryCacheImpl($cache);
|
||||
}
|
||||
if ($skipCache !== 'metadata') {
|
||||
|
||||
if ('metadata' !== $skipCache) {
|
||||
$this->configuration->setMetadataCacheImpl($cache);
|
||||
}
|
||||
}
|
||||
|
@ -174,14 +182,32 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
$this->setProductionSettings();
|
||||
$this->configuration->setMetadataCacheImpl(new ArrayCache());
|
||||
$this->setExpectedException('Doctrine\ORM\ORMException', 'Metadata Cache uses ArrayCache.');
|
||||
$this->setExpectedException(
|
||||
'Doctrine\ORM\ORMException',
|
||||
'Metadata Cache uses a non-persistent cache driver, Doctrine\Common\Cache\ArrayCache.');
|
||||
$this->configuration->ensureProductionSettings();
|
||||
}
|
||||
|
||||
public function testEnsureProductionSettingsAutoGenerateProxyClasses()
|
||||
public function testEnsureProductionSettingsAutoGenerateProxyClassesAlways()
|
||||
{
|
||||
$this->setProductionSettings();
|
||||
$this->configuration->setAutoGenerateProxyClasses(true);
|
||||
$this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_ALWAYS);
|
||||
$this->setExpectedException('Doctrine\ORM\ORMException', 'Proxy Classes are always regenerating.');
|
||||
$this->configuration->ensureProductionSettings();
|
||||
}
|
||||
|
||||
public function testEnsureProductionSettingsAutoGenerateProxyClassesFileNotExists()
|
||||
{
|
||||
$this->setProductionSettings();
|
||||
$this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS);
|
||||
$this->setExpectedException('Doctrine\ORM\ORMException', 'Proxy Classes are always regenerating.');
|
||||
$this->configuration->ensureProductionSettings();
|
||||
}
|
||||
|
||||
public function testEnsureProductionSettingsAutoGenerateProxyClassesEval()
|
||||
{
|
||||
$this->setProductionSettings();
|
||||
$this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_EVAL);
|
||||
$this->setExpectedException('Doctrine\ORM\ORMException', 'Proxy Classes are always regenerating.');
|
||||
$this->configuration->ensureProductionSettings();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue