protected function setUp()
 {
     $environment = $this->getMock('zibo\\core\\environment\\Environment');
     // environment needs to return a name, otherwise an error occurs in the cache library
     $environment->expects($this->any())->method('getName')->will($this->returnValue(CachedConfigIOTest::ENVIRONMENT_NAME));
     $this->innerIO = new ConfigIOMock();
     $this->innerIO->setValues('file', array('key' => 'value'));
     $this->innerIO->setValues('only_in_config', array('foo' => 'bar'));
     $this->cache = new ExtendedCache(new CacheIOMock());
     $this->cache->set(CachedConfigIOTest::ENVIRONMENT_NAME, 'file', array('another_key' => 'another_value'));
     $this->cache->set(CachedConfigIOTest::ENVIRONMENT_NAME, 'only_in_cache', array('test' => '123'));
     $this->io = new CachedConfigIO($environment, $this->innerIO, $this->cache);
 }
 /**
  * Read a section from the configuration
  * @param string $section
  * @return array Hierarchic array with each configuration token as a key
  */
 public function read($section)
 {
     if (!$this->isCacheEnabled()) {
         return $this->configIO->read($section);
     }
     $cached = $this->cache->get($this->cacheType, $section);
     if ($cached !== null) {
         return $cached;
     }
     $values = $this->configIO->read($section);
     if ($section !== self::SECTION_CONFIG) {
         $this->cache->set($this->cacheType, $section, $values);
     }
     return $values;
 }
 /**
  * Sets a translation for the provided locale
  * @param string $localeCode Code of the locale
  * @param string $key Key of the translation
  * @param string $translation
  * @return null
  */
 public function setTranslation($localeCode, $key, $translation)
 {
     $this->io->setTranslation($localeCode, $key, $translation);
     $this->cache->set(self::CACHE_TYPE, $localeCode, null);
 }