From fe9903eef4a8769318b86ad32e647e6ecb3057ac Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 12 Mar 2024 16:58:13 +0100 Subject: [PATCH] Test\Databases: Don't attempt to setup databases if there are none --- src/Test/Databases.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Test/Databases.php b/src/Test/Databases.php index e137868..315ed77 100644 --- a/src/Test/Databases.php +++ b/src/Test/Databases.php @@ -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'); @@ -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');