X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2FDatabaseTest.php;h=fec31b05af6f69aa49deee5c16a9c957a445b5c7;hb=e0b1f4f2519c6a5e02f98423f34648f21aa5c879;hp=88cc2d84bac1f43371e440e243bfb096e4662745;hpb=2d0a749734bb33be00b9674cb34582c602ff0d74;p=friendica.git diff --git a/tests/DatabaseTest.php b/tests/DatabaseTest.php index 88cc2d84ba..fec31b05af 100644 --- a/tests/DatabaseTest.php +++ b/tests/DatabaseTest.php @@ -5,18 +5,23 @@ namespace Friendica\Test; +use Friendica\App; use Friendica\Database\DBA; +use Friendica\Factory; +use Friendica\Util\BasePath; +use Friendica\Util\Config\ConfigFileLoader; +use Friendica\Util\Profiler; 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,6 +37,26 @@ 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.'); + } + + $basePath = BasePath::create(dirname(__DIR__)); + $mode = new App\Mode($basePath); + $configLoader = new ConfigFileLoader($basePath, $mode); + $config = Factory\ConfigFactory::createCache($configLoader); + + $profiler = \Mockery::mock(Profiler::class); + + DBA::connect( + $basePath, + $config, + $profiler, + getenv('MYSQL_HOST'), + getenv('MYSQL_USERNAME'), + getenv('MYSQL_PASSWORD'), + getenv('MYSQL_DATABASE')); + if (!DBA::connected()) { $this->markTestSkipped('Could not connect to the database.'); }