/**
  * Create the default Cache object, in case no Cache argument has been passed to __construct()
  *
  * @return zibo\library\cache\Cache a Cache object configured with a FileCacheIO at the path application/data/cache/config
  */
 private function createCache()
 {
     $cacheAge = $this->getConfigValue(self::CONFIG_CACHE_AGE);
     $cacheTimes = $this->getConfigValue(self::CONFIG_CACHE_TIMES);
     $isCacheEnabled = $this->getConfigValue(self::CONFIG_CACHE_ENABLED, false);
     $cachePath = new File(self::CACHE_PATH);
     $cacheIO = new FileCacheIO($cachePath);
     $this->setIsCacheEnabled($isCacheEnabled);
     $cache = new ExtendedCache($cacheIO);
     $cache->setCleanUpAge($cacheAge);
     $cache->setCleanUpTimes($cacheTimes);
     Zibo::getInstance()->registerEventListener(Zibo::EVENT_CLEAR_CACHE, array($this, 'clearCache'));
     return $cache;
 }
 public function testSetExistingValue()
 {
     $type = 'type';
     $id = 'id';
     $oldValue = 'old';
     $value = 'value';
     $object = new CacheObject($type, $id, $oldValue);
     $IOMock = $this->getMock('zibo\\library\\cache\\io\\CacheIO', array('readFromCache', 'clearCache', 'writeToCache'));
     $IOMock->expects($this->once())->method('readFromCache')->with($this->equalTo($type), $this->equalTo($id))->will($this->returnValue($object));
     $cache = new ExtendedCache($IOMock);
     $cache->set($type, $id, $value);
     $this->assertEquals($value, $object->getData());
     $this->assertEquals(0, $object->getTimesAccessed());
 }