Skip to content

A free open source IT asset/license management system

Updated CanSkipTests to allow sqlite and sqlite_testing

snipe8a42b62188fc
diff --git a/tests/Support/CanSkipTests.php b/tests/Support/CanSkipTests.php
index b29fdf88cd..9aea1574e3 100644
--- a/tests/Support/CanSkipTests.php
+++ b/tests/Support/CanSkipTests.php
@@ -6,15 +6,30 @@ trait CanSkipTests
{
public function markIncompleteIfMySQL($message = 'Test skipped due to database driver being MySQL.')
{
- if (config('database.default') === 'mysql') {
+ if ($this->currentDatabaseDriver() === 'mysql') {
$this->markTestIncomplete($message);
}
}
public function markIncompleteIfSqlite($message = 'Test skipped due to database driver being sqlite.')
{
- if (config('database.default') === 'sqlite') {
+ if ($this->currentDatabaseDriver() === 'sqlite') {
$this->markTestIncomplete($message);
}
}
+
+ /**
+ * Resolve the driver of the current default database connection.
+ * The default connection can be named anything (sqlite, sqlite_testing,
+ * mysql, mysql_ci, etc.), so keying off the connection NAME misses
+ * anything that isn't the canonical name. Reading the driver via the
+ * connections config makes the skip helpers work regardless of what
+ * .env.testing calls the connection.
+ */
+ private function currentDatabaseDriver(): ?string
+ {
+ $default = config('database.default');
+
+ return config("database.connections.$default.driver");
+ }
}