Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Session library override if running tests
<?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
You can’t perform that action at this time.