/**
  * @dataProvider getProvider
  *
  * @param mixed $cachedData
  * @param array $resultExpected
  * @param bool  $fetchExpected
  * @param array $fetchedResult
  * @param bool  $isException
  */
 public function testGet($cachedData, $resultExpected, $fetchExpected, $fetchedResult = [], $isException = false)
 {
     $this->cache->expects($this->once())->method('fetch')->with($this->equalTo(TranslationStatisticProvider::CACHE_KEY))->will($this->returnValue($cachedData));
     if ($fetchExpected) {
         if ($isException) {
             $this->adapter->expects($this->once())->method('fetchStatistic')->will($this->throwException($fetchedResult));
         } else {
             $this->adapter->expects($this->once())->method('fetchStatistic')->will($this->returnValue($fetchedResult));
         }
         $this->cache->expects($this->once())->method('save')->with($this->equalTo(TranslationStatisticProvider::CACHE_KEY));
     } else {
         $this->adapter->expects($this->never())->method('fetchStatistic');
     }
     $result = $this->provider->get();
     $this->assertSame($resultExpected, $result);
 }
 public function testClearDeletesAllIfFlushableAndClearable()
 {
     $this->cache = $this->getMock('Webmozart\\KeyValueStore\\Tests\\Fixtures\\TestClearableFlushableCache');
     $this->decorator = new CachingDecorator($this->innerStore, $this->cache);
     $this->innerStore->expects($this->once())->method('clear');
     $this->cache->expects($this->once())->method('deleteAll');
     $this->decorator->clear();
 }
Esempio n. 3
0
 /**
  * @group assignCacheIdToTag
  */
 public function testAssignCacheIdToTagWithDuplicatedCacheId()
 {
     $this->mockCache->expects($this->once())->method('fetch')->with('__advcache_tag[tag1]')->will($this->returnValue(array('testcacheid2', 'testcacheid1')));
     $this->mockCache->expects($this->once())->method('save')->with('__advcache_tag[tag1]', array('testcacheid2', 'testcacheid1'));
     $this->getTestObject()->assignCacheIdToTag('testcacheid2', 'tag1');
 }
Esempio n. 4
0
 public function testOffsetUnset()
 {
     $this->cache->expects($this->once())->method('delete')->with($this->identicalTo($offset = 'foo'));
     unset($this->doctrineCacheStorage[$offset]);
 }