public function testCache() { $cacheProvider = $this->getMockBuilder('Doctrine\\Common\\Cache\\CacheProvider')->disableOriginalConstructor()->setMethods(array('fetch', 'save', 'delete', 'deleteAll'))->getMockForAbstractClass(); $modelCacheProvider = $this->getMockBuilder('Doctrine\\Common\\Cache\\CacheProvider')->disableOriginalConstructor()->setMethods(array('fetch', 'save', 'delete', 'deleteAll'))->getMockForAbstractClass(); $className = 'testClass'; $scope = 'testScope'; $configId = new EntityConfigId($className, $scope); $config = new Config($configId); $configCache = new ConfigCache($cacheProvider, $modelCacheProvider); $cacheProvider->expects($this->once())->method('save')->will($this->returnValue(true)); $this->assertTrue($configCache->putConfigInCache($config)); $cacheProvider->expects($this->once())->method('delete')->will($this->returnValue(true)); $this->assertTrue($configCache->removeConfigFromCache($configId)); $cacheProvider->expects($this->once())->method('deleteAll')->will($this->returnValue(true)); $this->assertTrue($configCache->removeAll()); $cacheProvider->expects($this->once())->method('fetch')->will($this->returnValue(serialize($config))); $this->assertEquals($config, $configCache->loadConfigFromCache($configId)); $value = 'testValue'; $modelCacheProvider->expects($this->once())->method('save')->will($this->returnValue(true)); $this->assertTrue($configCache->setConfigurable($value, $className)); $modelCacheProvider->expects($this->once())->method('fetch')->will($this->returnValue($value)); $this->assertEquals($value, $configCache->getConfigurable($className)); $modelCacheProvider->expects($this->once())->method('deleteAll')->will($this->returnValue(true)); $this->assertTrue($configCache->removeAllConfigurable()); }
/** * Clears entity config cache * * @param ConfigIdInterface|null $configId */ public function clearCache(ConfigIdInterface $configId = null) { if ($configId) { if ($this->cache) { $this->cache->removeConfigFromCache($configId); } unset($this->localCache[$this->buildConfigKey($configId)]); } else { if ($this->cache) { $this->cache->removeAll(); } $this->localCache = []; } }
/** * Remove All cache */ public function clearCacheAll() { if ($this->cache) { $this->cache->removeAll(); } }
public function testRemoveAll() { $configCache = new ConfigCache($this->cacheProvider, $this->modelCacheProvider); $this->cacheProvider->expects($this->once())->method('deleteAll')->will($this->returnValue(true)); $this->assertTrue($configCache->removeAll()); }