paste.chapril.org-privatebin/tst/ControllerWithDbTest.php

43 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2016-07-21 17:09:48 +02:00
use PHPUnit\Framework\TestCase;
use PrivateBin\Data\Database;
2016-07-21 17:09:48 +02:00
2018-07-29 15:17:35 +02:00
require_once 'ControllerTest.php';
2018-07-29 15:17:35 +02:00
class ControllerWithDbTest extends ControllerTest
{
private $_options = array(
'usr' => null,
'pwd' => null,
'opt' => array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_PERSISTENT => true,
),
);
public function setUp(): void
{
/* 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';
$this->_data = Database::getInstance($this->_options);
$this->reset();
}
public function reset()
{
parent::reset();
// but then inject a db config
$options = parse_ini_file(CONF, true);
$options['model'] = array(
'class' => 'Database',
);
2017-11-13 22:05:29 +01:00
$options['model_options'] = $this->_options;
Helper::createIniFile(CONF, $options);
}
2016-07-11 14:15:20 +02:00
}