Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/PHPUnit/Fixtures/SqlDump.php')
-rw-r--r--tests/PHPUnit/Fixtures/SqlDump.php16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/PHPUnit/Fixtures/SqlDump.php b/tests/PHPUnit/Fixtures/SqlDump.php
index 94cddf0bc5..abfcb31338 100644
--- a/tests/PHPUnit/Fixtures/SqlDump.php
+++ b/tests/PHPUnit/Fixtures/SqlDump.php
@@ -63,7 +63,9 @@ class SqlDump extends Fixture
$host = Config::getInstance()->database['host'];
Config::getInstance()->database['tables_prefix'] = $this->tablesPrefix;
- $cmd = "mysql -h \"$host\" -u \"$user\" \"--password=$password\" {$this->dbName} < \"" . $deflatedDumpPath . "\" 2>&1";
+ $defaultsFile = $this->makeMysqlDefaultsFile($user, $password);
+
+ $cmd = "mysql --defaults-extra-file=\"$defaultsFile\" -h \"$host\" {$this->dbName} < \"" . $deflatedDumpPath . "\" 2>&1";
exec($cmd, $output, $return);
if ($return !== 0) {
throw new Exception("Failed to load sql dump: " . implode("\n", $output));
@@ -105,4 +107,16 @@ class SqlDump extends Fixture
fclose($outfile);
return $bytesRead;
}
+
+ private function makeMysqlDefaultsFile($user, $password)
+ {
+ $contents = "[client]
+user=$user
+password=$password\n";
+
+ $path = PIWIK_INCLUDE_PATH . '/mysqldefaults.conf';
+ file_put_contents($path, $contents);
+
+ return $path;
+ }
} \ No newline at end of file