/** * Initializes the `$i18n`, `$cache`, `$page`, and `$tpl` objects * for use with the controller in testing handlers. */ public static function setUpBeforeClass() { require_once 'lib/Functions.php'; require_once 'lib/DB.php'; error_reporting(E_ALL & ~E_NOTICE); if (!defined('ELEFANT_ENV')) { define('ELEFANT_ENV', 'config'); } $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en'; $_SERVER['REQUEST_URI'] = '/'; global $conf, $i18n, $cache, $page, $tpl; // Set up the database connection to be in memory $conf = parse_ini_file('conf/config.php', TRUE); $conf['Database'] = array('master' => array('driver' => 'sqlite', 'file' => ':memory:')); // Initializes PDO connection automatically foreach (sql_split(file_get_contents('conf/install_sqlite.sql')) as $sql) { if (!DB::execute($sql)) { die('SQL failed: ' . $sql); } } // Create default admin and member users $date = gmdate('Y-m-d H:i:s'); DB::execute("insert into `user` (id, email, password, session_id, expires, name, type, signed_up, updated, userdata) values (1, ?, ?, null, ?, 'Admin User', 'admin', ?, ?, ?)", '*****@*****.**', User::encrypt_pass('testing'), $date, $date, $date, json_encode(array())); DB::execute("insert into `user` (id, email, password, session_id, expires, name, type, signed_up, updated, userdata) values (2, ?, ?, null, ?, 'Joe Member', 'member', ?, ?, ?)", '*****@*****.**', User::encrypt_pass('testing'), $date, $date, $date, json_encode(array())); $i18n = new I18n('lang', array('negotiation_method' => 'http')); $page = new Page(); self::$c = new Controller(); $tpl = new Template('utf-8', self::$c); $cache = Cache::init(array()); self::$c->template($tpl); self::$c->cache($cache); self::$c->page($page); self::$c->i18n($i18n); }