[Config] Fix checking cache for non existing meta file

This commit is contained in:
Martin Hasoň 2016-12-09 11:59:21 +01:00
parent 04595dc707
commit 17f02e0dc4
2 changed files with 12 additions and 5 deletions

View File

@ -72,11 +72,6 @@ class ResourceCheckerConfigCache implements ConfigCacheInterface
return true; // shortcut - if we don't have any checkers we don't need to bother with the meta file at all
}
$metadata = $this->getMetaFile();
if (!is_file($metadata)) {
return true;
}
$metadata = $this->getMetaFile();
if (!is_file($metadata)) {
return false;

View File

@ -128,4 +128,16 @@ class ResourceCheckerConfigCacheTest extends \PHPUnit_Framework_TestCase
$this->assertSame('FOOBAR', file_get_contents($cache->getPath()));
}
public function testCacheIsNotFreshIfNotExistsMetaFile()
{
$checker = $this->getMock('\Symfony\Component\Config\ResourceCheckerInterface');
$cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker));
$cache->write('foo', array(new FileResource(__FILE__)));
$metaFile = "{$this->cacheFile}.meta";
unlink($metaFile);
$this->assertFalse($cache->isFresh());
}
}