Jarves\Configuration\SystemConfig::setCache PHP Method

setCache() public method

public setCache ( Cache $cache = null )
$cache Cache
    public function setCache(Cache $cache = null)
    {
        $this->cache = $cache;
    }

Usage Example

Example #1
0
    public function testSystemConfigCache()
    {
        $xml = '<config>
  <cache service="vendor.other.cache">
    <options>
      <option key="servers">
        <option>127.0.0.1</option>
        <option>192.168.0.1</option>
      </option>
      <option key="compression">true</option>
      <option key="foo">bar</option>
    </options>
  </cache>
</config>';
        $config5 = new SystemConfig();
        $cache = new Cache();
        $cache->setService('vendor.other.cache');
        $cache->setOption('servers', array('127.0.0.1', '192.168.0.1'));
        $cache->setOption('compression', 'true');
        $cache->setOption('foo', 'bar');
        $config5->setCache($cache);
        $this->assertEquals(array('127.0.0.1', '192.168.0.1'), $config5->getCache()->getOption('servers'));
        $this->assertEquals($xml, $config5->toXml());
        $reverse = new SystemConfig($xml);
        $this->assertEquals(array('127.0.0.1', '192.168.0.1'), $reverse->getCache()->getOption('servers'));
        $this->assertEquals('true', $reverse->getCache()->getOption('compression'));
        $this->assertEquals($xml, $reverse->toXml());
    }