public function testExceptionArray()
 {
     try {
         SessionHandler::excludeKeys('stringvalue is not scalar array');
         $this->expectException('PHPUnit_Framework_Error');
     } catch (\Throwable $e) {
         // echo '~~~~As expected PHP7 throws Throwable.';
     } catch (\Exception $e) {
         // echo '~~~~As expected PHP5 throws Exception.';
     }
 }
Beispiel #2
0
 /**
  * Parses conf.php files and sets parameters for this object
  *
  * @param array $config
  * @throws \Exception min params not set
  * @return true
  */
 private function parseConfig(array $config)
 {
     $this->config = $config;
     $this->min_cache_file_size = intval($this->config['min_cache_file_size']);
     if (isset($this->config['enable_log']) && $this->isBool($this->config['enable_log'])) {
         $this->enable_log = $this->config['enable_log'];
     }
     if (isset($this->config['expiration'])) {
         if ($this->config['expiration'] < 0) {
             throw new \Exception('PageCache config: invalid expiration value, < 0.');
         }
         $this->cache_expire = intval($this->config['expiration']);
     }
     //path to store cache files
     if (isset($this->config['cache_path'])) {
         // @codeCoverageIgnoreStart
         if (substr($this->config['cache_path'], -1) != '/') {
             throw new \Exception('PageCache config: / trailing slash is expected at the end of cache_path.');
         }
         //path writable?
         if (empty($this->config['cache_path']) || !is_writable($this->config['cache_path'])) {
             throw new \Exception('PageCache config: cache path not writable or empty');
         }
         $this->cache_path = $this->config['cache_path'];
         // @codeCoverageIgnoreEnd
     }
     //log file path
     if (isset($this->config['log_file_path']) && !empty($this->config['log_file_path'])) {
         $this->log_file_path = $this->config['log_file_path'];
     }
     //use $_SESSION while caching or not
     if (isset($this->config['use_session']) && $this->isBool($this->config['use_session'])) {
         SessionHandler::setStatus($this->config['use_session']);
     }
     //session exclude key
     if (isset($this->config['session_exclude_keys']) && !empty($this->config['session_exclude_keys'])) {
         // @codeCoverageIgnoreStart
         SessionHandler::excludeKeys($this->config['session_exclude_keys']);
         // @codeCoverageIgnoreEnd
     }
     //File Locking
     if (isset($this->config['file_lock']) && !empty($this->config['file_lock'])) {
         $this->file_lock = $this->config['file_lock'];
     }
     return true;
 }