Created
January 8, 2015 15:20
-
-
Save withremote/7b7c8fed47f39524c0ba to your computer and use it in GitHub Desktop.
Session library override if running tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MY_Session extends CI_Session { | |
protected $cliTestingDriver = 'codeception'; | |
public function __construct(array $params = array()) | |
{ | |
parent::__construct($params); | |
/** alow for sessions ot be saved if in CLI mode and running tests */ | |
if (is_cli() && defined('CODECEPTION_TEST')) { | |
$this->valid_drivers = array_merge($this->valid_drivers, array($this->cliTestingDriver)); | |
// Save a copy of parameters in case drivers need access | |
$this->params = $params; | |
// Load driver and get array reference | |
$this->load_driver($this->cliTestingDriver); | |
// Delete 'old' flashdata (from last request) | |
$this->_flashdata_sweep(); | |
// Mark all new flashdata as old (data will be deleted before next request) | |
$this->_flashdata_mark(); | |
// Delete expired tempdata | |
$this->_tempdata_sweep(); | |
log_message('debug', 'MY_Session routines successfully run with Testing driver "'.$this->cliTestingDriver.'"'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment