You are here

protected function MigrateUpgradeCommandsTest::convertDbSpecUrl in Migrate Upgrade 8.3

Convert DB spec into a DB URL.

Parameters

array $db_spec: The DB spec.

Return value

string The DB URL.

1 call to MigrateUpgradeCommandsTest::convertDbSpecUrl()
MigrateUpgradeCommandsTest::executeMigrateUpgrade in tests/src/Functional/MigrateUpgradeCommandsTest.php
Execute Drush migrate:upgrade command.

File

tests/src/Functional/MigrateUpgradeCommandsTest.php, line 140

Class

MigrateUpgradeCommandsTest
Execute drush on fully functional website.

Namespace

Drupal\Tests\migrate_upgrade\Functional

Code

protected function convertDbSpecUrl(array $db_spec) : string {

  // If it's a sqlite database, pick the database path and we're done.
  if ($db_spec['driver'] === 'sqlite') {
    return 'sqlite://' . $db_spec['database'];
  }

  // Ex. mysql://username:password@localhost:3306/databasename#table_prefix.
  $url = $db_spec['driver'] . '://' . $db_spec['username'] . ':' . $db_spec['password'] . '@' . $db_spec['host'];
  if (isset($db_spec['port'])) {
    $url .= ':' . $db_spec['port'];
  }
  return $url . '/' . $db_spec['database'];
}