2015-10-03 09:52:37 -04:00
|
|
|
<?php
|
2016-07-21 11:09:48 -04:00
|
|
|
|
2016-08-09 05:54:42 -04:00
|
|
|
use PrivateBin\Data\Database;
|
2016-07-21 11:09:48 -04:00
|
|
|
|
2016-08-09 05:54:42 -04:00
|
|
|
require_once 'PrivateBinTest.php';
|
2015-10-03 09:52:37 -04:00
|
|
|
|
2016-08-09 05:54:42 -04:00
|
|
|
class PrivateBinWithDbTest extends PrivateBinTest
|
2015-10-03 09:52:37 -04:00
|
|
|
{
|
|
|
|
private $_options = array(
|
|
|
|
'usr' => null,
|
|
|
|
'pwd' => null,
|
|
|
|
'opt' => array(
|
2016-10-29 04:24:08 -04:00
|
|
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
|
|
PDO::ATTR_PERSISTENT => true,
|
2015-10-03 09:52:37 -04:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
/* Setup Routine */
|
2016-07-15 11:02:59 -04:00
|
|
|
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
2016-07-26 02:19:35 -04:00
|
|
|
if (!is_dir($this->_path)) {
|
|
|
|
mkdir($this->_path);
|
|
|
|
}
|
2016-07-18 08:47:32 -04:00
|
|
|
$this->_options['dsn'] = 'sqlite:' . $this->_path . DIRECTORY_SEPARATOR . 'tst.sq3';
|
2016-10-29 04:24:08 -04:00
|
|
|
$this->_model = Database::getInstance($this->_options);
|
2015-10-03 09:52:37 -04:00
|
|
|
$this->reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function reset()
|
|
|
|
{
|
|
|
|
parent::reset();
|
|
|
|
// but then inject a db config
|
2016-10-29 04:24:08 -04:00
|
|
|
$options = parse_ini_file(CONF, true);
|
2015-10-03 09:52:37 -04:00
|
|
|
$options['model'] = array(
|
2016-08-09 05:54:42 -04:00
|
|
|
'class' => 'Database',
|
2015-10-03 09:52:37 -04:00
|
|
|
);
|
2016-10-29 04:24:08 -04:00
|
|
|
$options['model_options'] = $this->_options;
|
2016-08-09 05:54:42 -04:00
|
|
|
Helper::createIniFile(CONF, $options);
|
2015-10-03 09:52:37 -04:00
|
|
|
}
|
2016-07-11 08:15:20 -04:00
|
|
|
}
|