/** * Constructor * * Loads filters based on provided IDS_Init settings. * * @param object $init IDS_Init instance * * @throws \InvalidArgumentException if unsupported filter type is given * @return void */ public final function __construct(Init $init) { if ($init->config) { $caching = isset($init->config['Caching']['caching']) ? $init->config['Caching']['caching'] : 'none'; $type = $init->config['General']['filter_type']; $this->source = $init->getBasePath() . $init->config['General']['filter_path']; if ($caching && $caching !== 'none') { $this->cacheSettings = $init->config['Caching']; $this->cache = CacheFactory::factory($init, 'storage'); } switch ($type) { case 'xml': return $this->getFilterFromXML(); case 'json': return $this->getFilterFromJson(); default: throw new \InvalidArgumentException('Unsupported filter type.'); } } }
public function testCachingSessionGetCacheDestroyed() { $this->init->config['Caching']['caching'] = 'session'; $cache = CacheFactory::factory($this->init, 'storage'); $cache = $cache->setCache(array(1, 2, 3, 4)); $_SESSION['PHPIDS']['storage'] = null; $this->assertFalse($cache->getCache()); }