X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2FDatabaseTest.php;h=2cb76dcad9ab39a013987026d6c4248bbe2afa56;hb=5e2cbce9b6efce2baaed69b6aad1537a51bdae9d;hp=12150932c9dba2a6da019514d2284da17f53f010;hpb=b02cdc8a7f84a4931e80027de42a80daa58581e1;p=friendica.git diff --git a/tests/DatabaseTest.php b/tests/DatabaseTest.php index 12150932c9..2cb76dcad9 100644 --- a/tests/DatabaseTest.php +++ b/tests/DatabaseTest.php @@ -5,19 +5,18 @@ namespace Friendica\Test; -use dba; -use Friendica\Database\DBStructure; -use PHPUnit_Extensions_Database_DB_IDatabaseConnection; +use Friendica\Database\DBA; use PHPUnit\DbUnit\DataSet\YamlDataSet; use PHPUnit\DbUnit\TestCaseTrait; -use PHPUnit\Framework\TestCase; +use PHPUnit_Extensions_Database_DB_IDatabaseConnection; + +require_once __DIR__ . '/../boot.php'; /** * Abstract class used by tests that need a database. */ -abstract class DatabaseTest extends TestCase +abstract class DatabaseTest extends MockedTest { - use TestCaseTrait; /** @@ -33,22 +32,20 @@ abstract class DatabaseTest extends TestCase */ protected function getConnection() { - if (!dba::$connected) { - dba::connect('localhost', getenv('USER'), getenv('PASS'), getenv('DB')); - - if (dba::$connected) { - $app = get_app(); - // We need to do this in order to disable logging - $app->module = 'install'; - - // Create database structure - DBStructure::update(false, true, true); - } else { - $this->markTestSkipped('Could not connect to the database.'); - } + if (!getenv('MYSQL_DATABASE')) { + $this->markTestSkipped('Please set the MYSQL_* environment variables to your test database credentials.'); + } + + DBA::connect(getenv('MYSQL_HOST'), + getenv('MYSQL_USERNAME'), + getenv('MYSQL_PASSWORD'), + getenv('MYSQL_DATABASE')); + + if (!DBA::connected()) { + $this->markTestSkipped('Could not connect to the database.'); } - return $this->createDefaultDBConnection(dba::get_db(), getenv('DB')); + return $this->createDefaultDBConnection(DBA::getConnection(), getenv('MYSQL_DATABASE')); } /**