ulogger-server/.tests/lib/UloggerDatabaseTestCase.php

39 lines
982 B
PHP
Raw Normal View History

2017-09-05 09:36:10 +02:00
<?php
use PHPUnit\Framework\TestCase;
require_once("BaseDatabaseTestCase.php");
require_once(__DIR__ . "/../../helpers/db.php");
class UloggerDatabaseTestCase extends BaseDatabaseTestCase {
static private $udb = null;
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
if (file_exists(__DIR__ . '/../.env')) {
2019-02-28 11:03:41 +01:00
$dotenv = Dotenv\Dotenv::create(__DIR__ . '/..');
2017-09-05 09:36:10 +02:00
$dotenv->load();
2019-01-24 19:07:41 +01:00
$dotenv->required(['DB_DSN', 'DB_USER', 'DB_PASS']);
2017-09-05 09:36:10 +02:00
}
2019-01-24 19:07:41 +01:00
$db_dsn = getenv('DB_DSN');
2017-09-05 09:36:10 +02:00
$db_user = getenv('DB_USER');
$db_pass = getenv('DB_PASS');
// uDb connection
if (self::$udb == null) {
self::$udb = new ReflectionClass("uDb");
$dbInstance = self::$udb->getProperty('instance');
$dbInstance->setAccessible(true);
2019-01-24 19:07:41 +01:00
$dbInstance->setValue(new uDb($db_dsn, $db_user, $db_pass));
2017-09-05 09:36:10 +02:00
}
}
public static function tearDownAfterClass() {
parent::tearDownAfterClass();
self::$udb = null;
}
}
?>