2015-10-03 15:52:37 +02:00
|
|
|
<?php
|
2016-07-11 11:58:15 +02:00
|
|
|
require_once 'privatebin.php';
|
2015-10-03 15:52:37 +02:00
|
|
|
|
2016-07-11 11:58:15 +02:00
|
|
|
class privatebinWithDbTest extends privatebinTest
|
2015-10-03 15:52:37 +02:00
|
|
|
{
|
|
|
|
private $_options = array(
|
|
|
|
'usr' => null,
|
|
|
|
'pwd' => null,
|
|
|
|
'opt' => array(
|
|
|
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
|
|
PDO::ATTR_PERSISTENT => true
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2016-07-15 17:02:59 +02:00
|
|
|
private $_path;
|
|
|
|
|
2015-10-03 15:52:37 +02:00
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
/* Setup Routine */
|
2016-07-15 17:02:59 +02:00
|
|
|
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
|
|
|
if(!is_dir($this->_path)) mkdir($this->_path);
|
2016-07-18 14:47:32 +02:00
|
|
|
$this->_options['dsn'] = 'sqlite:' . $this->_path . DIRECTORY_SEPARATOR . 'tst.sq3';
|
2016-07-11 11:58:15 +02:00
|
|
|
$this->_model = privatebin_db::getInstance($this->_options);
|
2015-10-03 15:52:37 +02:00
|
|
|
$this->reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tearDown()
|
|
|
|
{
|
|
|
|
/* Tear Down Routine */
|
|
|
|
parent::tearDown();
|
2016-07-15 17:02:59 +02:00
|
|
|
helper::rmdir($this->_path);
|
2015-10-03 15:52:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function reset()
|
|
|
|
{
|
|
|
|
parent::reset();
|
|
|
|
// but then inject a db config
|
|
|
|
$options = parse_ini_file(CONF, true);
|
|
|
|
$options['model'] = array(
|
2016-07-11 11:58:15 +02:00
|
|
|
'class' => 'privatebin_db',
|
2015-10-03 15:52:37 +02:00
|
|
|
);
|
|
|
|
$options['model_options'] = $this->_options;
|
|
|
|
helper::confBackup();
|
|
|
|
helper::createIniFile(CONF, $options);
|
|
|
|
}
|
2016-07-11 14:15:20 +02:00
|
|
|
}
|