]> git.mxchange.org Git - friendica.git/blobdiff - tests/DatabaseTest.php
Replace rogue instance of "contacts" by "contact" (#5891)
[friendica.git] / tests / DatabaseTest.php
index eb9399ab808a76f5c0b6366f3c2c0b71057bb2b4..2cb76dcad9ab39a013987026d6c4248bbe2afa56 100644 (file)
@@ -8,15 +8,15 @@ namespace Friendica\Test;
 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;
 
        /**
@@ -32,11 +32,20 @@ abstract class DatabaseTest extends TestCase
         */
        protected function getConnection()
        {
+               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('MYSQL_DATABASE'));
+               return $this->createDefaultDBConnection(DBA::getConnection(), getenv('MYSQL_DATABASE'));
        }
 
        /**