2

I've tried running Magento's built-in integration testing using MySQL:5.7 docker container on a different port.

php bin/magento dev:tests:run integration

Question is, how can I use a different port?

The following is my dev/tests/integration/etc/install-config-mysql.php

/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
return [
 'db-host' => 'localhost',
 'db-port' => '33060', // <-- this is not working
 'db-user' => 'root',
 'db-password' => '',
 'db-name' => 'magento_integration_tests',
 'db-prefix' => '',
 'backend-frontname' => 'backend',
 'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME,
 'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD,
 'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL,
 'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME,
 'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME,
 ];

I also tried removing 'db-port' => '33060', and replaced 'db-host' => 'localhost', with 'db-host' => 'localhost:33060', and still it doesn't recognize the host.

Also, I can succesfully connect to the MySQL server using Workbench.

Anyone know how to change the port reference?

Fabian Schmengler
66.2k25 gold badges191 silver badges422 bronze badges
asked Jun 29, 2017 at 2:56

1 Answer 1

1

Seems to be impossible as of Magento 2.1.

The database connection \Magento\TestFramework\Db\Mysql gets instantiated based on the configuration in \Magento\TestFramework\Application::getDbInstance(). The parameters are:

$host,
$user,
$password,
$dbName,
$this->getTempDir(),
$this->_shell

and that DB class does not use a port parameter anywhere.

So currently the only way around it is to forward the port to the default 3306

Good news is, there is a merged pull request: https://github.com/magento/magento2/pull/4275

So with Magento 2.2 you will be able to use 'db-host' => 'localhost:33060',

answered Jun 30, 2017 at 13:52
1
  • Thanks fab, that's what I've done. forward the port to the default 3306. Cheers! Commented Jul 2, 2017 at 3:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.