diff --git a/src/Codeception/Module/Db.php b/src/Codeception/Module/Db.php index 6c116b60..df41c702 100644 --- a/src/Codeception/Module/Db.php +++ b/src/Codeception/Module/Db.php @@ -532,18 +532,24 @@ private function readSql($databaseKey = null, $databaseConfig = null): void * @return bool|null|string|string[] * @throws ModuleConfigException */ - private function readSqlFile(string $filePath): ?string + private function readSqlFile(string $configPath): ?string { - if (!file_exists(Configuration::projectDir() . $filePath)) { + if(file_exists($configPath)) { + $dumpFile = $configPath; + }elseif (file_exists(Configuration::projectDir().$configPath)){ + $dumpFile = Configuration::projectDir().$configPath; + }else { throw new ModuleConfigException( __CLASS__, - "\nFile with dump doesn't exist.\n" - . "Please, check path for sql file: " - . $filePath + sprintf( + "Could not find dump file from config value.\nTried:\n%s\nand\n%s", + $configPath, + Configuration::projectDir().$configPath + ) ); } - - $sql = file_get_contents(Configuration::projectDir() . $filePath); + + $sql = file_get_contents($dumpFile); // remove C-style comments (except MySQL directives) return preg_replace('#/\*(?!!\d+).*?\*/#s', '', $sql);