Beispiel #1
0
 protected function setUp()
 {
     parent::setUp();
     $this->_fpc = Mage::getSingleton('fpc/fpc');
     $this->_fpc->clean();
     // disable all caches expected fpc
     $this->_cache = Mage::app()->getCacheInstance();
     $this->_cacheOptions = Mage::getResourceSingleton('core/cache')->getAllOptions();
     $cacheOptions = $this->_cacheOptions;
     foreach (array_keys($cacheOptions) as $cache) {
         $cacheOptions[$cache] = $cache == 'fpc' ? 1 : 0;
     }
     if (!array_key_exists('fpc', $cacheOptions)) {
         $cacheOptions['fpc'] = 1;
     }
     $this->_cache->saveOptions($cacheOptions);
     $cacheReflector = new ReflectionClass('Mage_Core_Model_Cache');
     $initOptionsMethod = $cacheReflector->getMethod('_initOptions');
     $initOptionsMethod->setAccessible(true);
     $initOptionsMethod->invokeArgs($this->_cache, array());
 }
Beispiel #2
0
 /**
  * @test
  * @loadFixture save_load_clean.yaml
  */
 public function saveLoadClean()
 {
     $data = 'fpc_data';
     $id = 'fpc_id';
     $tag = 'tag1';
     // check if tag tag1 (clean without array)
     $this->_fpc->save($data, $id, array($tag));
     $this->assertEquals($data, $this->_fpc->load($id));
     $this->_fpc->clean($tag);
     $this->assertFalse($this->_fpc->load($id));
     // check global tag FPC (clean with array)
     $this->_fpc->save($data, $id, array($tag));
     $this->assertEquals($data, $this->_fpc->load($id));
     $this->_fpc->clean(array(Lesti_Fpc_Model_Fpc::CACHE_TAG));
     $this->assertFalse($this->_fpc->load($id));
     // (global clean)
     $this->_fpc->save($data, $id, array($tag));
     $this->assertEquals($data, $this->_fpc->load($id));
     $this->_fpc->clean();
     $this->assertFalse($this->_fpc->load($id));
     // check timeout
     $this->_fpc->save($data, $id, array($tag), 2);
     $this->assertEquals($data, $this->_fpc->load($id));
     sleep(3);
     $this->assertFalse($this->_fpc->load($id));
 }