/** * Checks if the cache is still fresh. * * This implementation always returns true when debug is off and the * cache file exists. * * @return bool true if the cache is fresh, false otherwise */ public function isFresh() { if (!$this->debug && is_file($this->getPath())) { return true; } return parent::isFresh(); }
public function testIsNotFreshWithchecker() { $checker = $this->getMock('\\Symfony\\Component\\Config\\ResourceCheckerInterface'); $checker->expects($this->once())->method('supports')->willReturn(true); $checker->expects($this->once())->method('isFresh')->willReturn(false); $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); $cache->write('', array(new ResourceStub())); $this->assertFalse($cache->isFresh()); }
public function testCacheIsNotFreshWhenUnserializeFails() { $checker = $this->getMockBuilder('\\Symfony\\Component\\Config\\ResourceCheckerInterface')->getMock(); $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); $cache->write('foo', array(new FileResource(__FILE__))); $metaFile = "{$this->cacheFile}.meta"; file_put_contents($metaFile, str_replace('FileResource', 'ClassNotHere', file_get_contents($metaFile))); $this->assertFalse($cache->isFresh()); }