mirror of
https://github.com/snipe/snipe-it.git
synced 2026-08-18 11:15:42 +00:00
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Support;
|
|
|
|
trait CanSkipTests
|
|
{
|
|
public function markIncompleteIfMySQL($message = 'Test skipped due to database driver being MySQL.')
|
|
{
|
|
if ($this->currentDatabaseDriver() === 'mysql') {
|
|
$this->markTestIncomplete($message);
|
|
}
|
|
}
|
|
|
|
public function markIncompleteIfSqlite($message = 'Test skipped due to database driver being 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");
|
|
}
|
|
}
|