Skip to content

Commit b844887

Browse files
Merge commit 'refs/pull/4275/head' of https://github.com/magento/magento2 into MAGETWO-52981
2 parents c29f3e7 + 9f99d7b commit b844887

File tree

1 file changed

+24
-5
lines changed
  • dev/tests/integration/framework/Magento/TestFramework/Db

1 file changed

+24
-5
lines changed

dev/tests/integration/framework/Magento/TestFramework/Db/Mysql.php

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313

1414
class Mysql extends \Magento\TestFramework\Db\AbstractDb
1515
{
16+
/**
17+
* Default port
18+
*/
19+
const DEFAULT_PORT = 3306;
20+
1621
/**
1722
* Defaults extra file name
1823
*/
@@ -32,12 +37,25 @@ class Mysql extends \Magento\TestFramework\Db\AbstractDb
3237
*/
3338
private $_defaultsExtraFile;
3439

40+
/**
41+
* Port number for connection
42+
*
43+
* @var integer
44+
*/
45+
private $_port;
46+
3547
/**
3648
* {@inheritdoc}
3749
*/
3850
public function __construct($host, $user, $password, $schema, $varPath, \Magento\Framework\Shell $shell)
3951
{
4052
parent::__construct($host, $user, $password, $schema, $varPath, $shell);
53+
$this->_port = self::DEFAULT_PORT;
54+
if (strpos($this->_host, ':') !== false) {
55+
list($host, $port) = explode(':', $this->_host);
56+
$this->_host = $host;
57+
$this->_port = (int) $port;
58+
}
4159
$this->_dbDumpFile = $this->_varPath . '/setup_dump_' . $this->_schema . '.sql';
4260
$this->_defaultsExtraFile = rtrim($this->_varPath, '\\/') . '/' . self::DEFAULTS_EXTRA_FILE_NAME;
4361
}
@@ -49,10 +67,11 @@ public function cleanup()
4967
{
5068
$this->ensureDefaultsExtraFile();
5169
$this->_shell->execute(
52-
'mysql --defaults-file=%s --host=%s %s -e %s',
70+
'mysql --defaults-file=%s --host=%s --port=%s %s -e %s',
5371
[
5472
$this->_defaultsExtraFile,
5573
$this->_host,
74+
$this->_port,
5675
$this->_schema,
5776
"DROP DATABASE `{$this->_schema}`; CREATE DATABASE `{$this->_schema}`"
5877
]
@@ -86,8 +105,8 @@ public function storeDbDump()
86105
{
87106
$this->ensureDefaultsExtraFile();
88107
$this->_shell->execute(
89-
'mysqldump --defaults-file=%s --host=%s %s > %s',
90-
[$this->_defaultsExtraFile, $this->_host, $this->_schema, $this->getSetupDbDumpFilename()]
108+
'mysqldump --defaults-file=%s --host=%s --port=%s %s > %s',
109+
[$this->_defaultsExtraFile, $this->_host, $this->_port, $this->_schema, $this->getSetupDbDumpFilename()]
91110
);
92111
}
93112

@@ -102,8 +121,8 @@ public function restoreFromDbDump()
102121
throw new \LogicException("DB dump file does not exist: " . $this->getSetupDbDumpFilename());
103122
}
104123
$this->_shell->execute(
105-
'mysql --defaults-file=%s --host=%s %s < %s',
106-
[$this->_defaultsExtraFile, $this->_host, $this->_schema, $this->getSetupDbDumpFilename()]
124+
'mysql --defaults-file=%s --host=%s --port=%s %s < %s',
125+
[$this->_defaultsExtraFile, $this->_host, $this->_port, $this->_schema, $this->getSetupDbDumpFilename()]
107126
);
108127
}
109128

0 commit comments

Comments
 (0)