bintzwing/tst/privatebinWithDb.php

53 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2016-07-21 15:09:48 +00:00
use PrivateBin\data\db;
use PrivateBin\privatebin;
use PrivateBin\serversalt;
use PrivateBin\trafficlimiter;
2016-07-11 09:58:15 +00:00
require_once 'privatebin.php';
2016-07-11 09:58:15 +00:00
class privatebinWithDbTest extends privatebinTest
{
private $_options = array(
'usr' => null,
'pwd' => null,
'opt' => array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_PERSISTENT => true
),
);
private $_path;
public function setUp()
{
/* Setup Routine */
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
if(!is_dir($this->_path)) mkdir($this->_path);
$this->_options['dsn'] = 'sqlite:' . $this->_path . DIRECTORY_SEPARATOR . 'tst.sq3';
2016-07-21 15:09:48 +00:00
$this->_model = db::getInstance($this->_options);
$this->reset();
}
public function tearDown()
{
/* Tear Down Routine */
parent::tearDown();
helper::rmdir($this->_path);
}
public function reset()
{
parent::reset();
// but then inject a db config
$options = parse_ini_file(CONF, true);
$options['model'] = array(
2016-07-11 09:58:15 +00:00
'class' => 'privatebin_db',
);
$options['model_options'] = $this->_options;
helper::confBackup();
helper::createIniFile(CONF, $options);
}
2016-07-11 12:15:20 +00:00
}