Skip to content

Commit

Permalink
Test\Databases: Don't attempt to setup databases if there are none
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed Mar 12, 2024
1 parent bf8483e commit fe9903e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Test/Databases.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ protected function setUpDatabases(): void
{
if (method_exists($this, 'dataName') && method_exists($this, 'getProvidedData')) {
// A small performance improvement. Though, it relies on internal methods, hence the check.
$this->createSchema($this->getProvidedData()[0], $this->dataName());
$providedData = $this->getProvidedData();
if (! empty($providedData)) {
$this->createSchema($providedData[0], $this->dataName());
}
} else {
$this->createSchema($this->createConnection('mysql'), 'mysql');
$this->createSchema($this->createConnection('pgsql'), 'pgsql');
Expand All @@ -133,7 +136,10 @@ protected function tearDownDatabases(): void
{
if (method_exists($this, 'dataName') && method_exists($this, 'getProvidedData')) {
// A small performance improvement. Though, it relies on internal methods, hence the check.
$this->dropSchema($this->getProvidedData()[0], $this->dataName());
$providedData = $this->getProvidedData();
if (! empty($providedData)) {
$this->dropSchema($providedData[0], $this->dataName());
}
} else {
$this->dropSchema($this->createConnection('mysql'), 'mysql');
$this->dropSchema($this->createConnection('pgsql'), 'pgsql');
Expand Down

0 comments on commit fe9903e

Please sign in to comment.