Skip to content

Commit

Permalink
Merge pull request #6441 from sensorario/remove-loosely-comparison
Browse files Browse the repository at this point in the history
Verify that the `fileLockRegionDirectory` passed to the `DefaultCacheFactory` cannot be empty
  • Loading branch information
Ocramius committed Aug 18, 2017
2 parents fda7707 + 4bf2e89 commit 94640ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Doctrine/ORM/Cache/DefaultCacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ public function getRegion(array $cache)

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(). '
Expand Down
18 changes: 18 additions & 0 deletions tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,24 @@ public function testInvalidFileLockRegionDirectoryException()
);
}

/**
* @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());
Expand Down

0 comments on commit 94640ac

Please sign in to comment.