diff --git a/tests/integration/Core/Tester.php b/tests/integration/Core/Tester.php index d3d56923b6..605a11ae50 100644 --- a/tests/integration/Core/Tester.php +++ b/tests/integration/Core/Tester.php @@ -191,6 +191,7 @@ class Tester } //remove and copy Espo files + Utils::checkCreateDatabase($configData['database']); Utils::dropTables($configData['database']); $fileManager->removeInDir($this->installPath); $tt = $fileManager->copy($latestEspo, $this->installPath, true); diff --git a/tests/integration/Core/Utils.php b/tests/integration/Core/Utils.php index 87f16d8b43..3eafb40e40 100644 --- a/tests/integration/Core/Utils.php +++ b/tests/integration/Core/Utils.php @@ -124,6 +124,19 @@ class Utils } /*END: SET UNDEFINED VARIABLES*/ } + public static function checkCreateDatabase(array $options) + { + if (!isset($options['dbname'])) { + throw new \Espo\Core\Exceptions\Error('Option "dbname" is not found.'); + } + + $dbname = $options['dbname']; + unset($options['dbname']); + + $pdo = static::createPdoConnection($options); + $pdo->query("CREATE DATABASE IF NOT EXISTS `". $dbname ."`"); + } + public static function dropTables(array $options) { $pdo = static::createPdoConnection($options); @@ -145,4 +158,4 @@ class Utils return $dbh; } -} \ No newline at end of file +}