diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index 77a773a53..bfc6aa29a 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -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(). ' diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index 1ca213b20..54fd59e37 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -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());