From b87162d4f1a945fcde384bc9cfc5869e5a39b063 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Wed, 20 Nov 2024 00:31:13 +0500 Subject: [PATCH] WIP --- tests/Support/TestTrait.php | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/tests/Support/TestTrait.php b/tests/Support/TestTrait.php index 0915fe6d..ab576d1c 100644 --- a/tests/Support/TestTrait.php +++ b/tests/Support/TestTrait.php @@ -78,26 +78,51 @@ private function getDriver(): PdoDriverInterface private static function getDatabaseName(): string { - return getenv('YII_MYSQL_DATABASE'); + if (self::isMariadb()) { + return getenv('YII_MARIADB_DATABASE') ?: ''; + } + + return getenv('YII_MYSQL_DATABASE') ?: ''; } private static function getHost(): string { - return getenv('YII_MYSQL_HOST'); + if (self::isMariadb()) { + return getenv('YII_MARIADB_HOST') ?: ''; + } + + return getenv('YII_MYSQL_HOST') ?: ''; } private static function getPort(): string { - return getenv('YII_MYSQL_PORT'); + if (self::isMariadb()) { + return getenv('YII_MARIADB_PORT') ?: ''; + } + + return getenv('YII_MYSQL_PORT') ?: ''; } private static function getUsername(): string { - return getenv('YII_MYSQL_USER'); + if (self::isMariadb()) { + return getenv('YII_MARIADB_USER') ?: ''; + } + + return getenv('YII_MYSQL_USER') ?: ''; } private static function getPassword(): string { - return getenv('YII_MYSQL_PASSWORD'); + if (self::isMariadb()) { + return getenv('YII_MARIADB_PASSWORD') ?: ''; + } + + return getenv('YII_MYSQL_PASSWORD') ?: ''; + } + + private static function isMariadb(): bool + { + return getenv('YII_MYSQL_TYPE') === 'mariadb'; } }