1
0
mirror of synced 2025-02-02 21:41:45 +03:00

Merge pull request #6441 from sensorario/remove-loosely-comparison

Verify that the `fileLockRegionDirectory` passed to the `DefaultCacheFactory` cannot be empty
This commit is contained in:
Marco Pivetta 2017-08-18 04:38:20 +02:00 committed by GitHub
commit 94640aca88
2 changed files with 22 additions and 1 deletions

View File

@ -209,7 +209,10 @@ class DefaultCacheFactory implements CacheFactory
if ($cache['usage'] === ClassMetadata::CACHE_USAGE_READ_WRITE) {
if ( ! $this->fileLockRegionDirectory) {
if (
'' === $this->fileLockRegionDirectory ||
null === $this->fileLockRegionDirectory
) {
throw new \LogicException(
'If you want to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" is required, ' .
'The default implementation provided by doctrine is "Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory, DefaultCacheFactory#setFileLockRegionDirectory(). '

View File

@ -275,6 +275,24 @@ class DefaultCacheFactoryTest extends OrmTestCase
);
}
/**
* @expectedException LogicException
* @expectedExceptionMessage If you want to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" is required, The default implementation provided by doctrine is "Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory
*/
public function testInvalidFileLockRegionDirectoryExceptionWithEmptyString()
{
$factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl());
$factory->setFileLockRegionDirectory('');
$factory->getRegion(
[
'usage' => ClassMetadata::CACHE_USAGE_READ_WRITE,
'region' => 'foo'
]
);
}
public function testBuildsNewNamespacedCacheInstancePerRegionInstance()
{
$factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl());