Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0:feat(multi-application): allow absolute path in dump files #38

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/Codeception/Module/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was it necessary to rename parameter?

{
if (!file_exists(Configuration::projectDir() . $filePath)) {
if(file_exists($configPath)) {
$dumpFile = $configPath;
}elseif (file_exists(Configuration::projectDir().$configPath)){
$dumpFile = Configuration::projectDir().$configPath;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check Configuration::projectDir() . $configPath first for better backwards compatibility.

}else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting. Please put space after if and before elseif and else keywords.

Please put spaces on both sides of concatenation operator.

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And delete spaces in empty line.

$sql = file_get_contents($dumpFile);

// remove C-style comments (except MySQL directives)
return preg_replace('#/\*(?!!\d+).*?\*/#s', '', $sql);
Expand Down