You are here

protected function MigrateUpgradeTestBase::getCredentials in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php \Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeTestBase::getCredentials()

Creates an array of credentials for the Credential form.

Before submitting to the Credential form the array must be processed by BrowserTestBase::translatePostValues() before submitting.

Return value

array An array of values suitable for BrowserTestBase::translatePostValues().

See also

\Drupal\migrate_drupal_ui\Form\CredentialForm

File

core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php, line 294

Class

MigrateUpgradeTestBase
Provides a base class for testing migration upgrades in the UI.

Namespace

Drupal\Tests\migrate_drupal_ui\Functional

Code

protected function getCredentials() {
  $connection_options = $this->sourceDatabase
    ->getConnectionOptions();
  $version = $this
    ->getLegacyDrupalVersion($this->sourceDatabase);
  $driver = $connection_options['driver'];

  // Use the driver connection form to get the correct options out of the
  // database settings. This supports all of the databases we test against.
  $drivers = drupal_get_database_types();
  $form = $drivers[$driver]
    ->getFormOptions($connection_options);
  $connection_options = array_intersect_key($connection_options, $form + $form['advanced_options']);
  $edit = [
    $driver => $connection_options,
    'source_private_file_path' => $this
      ->getSourceBasePath(),
    'version' => $version,
  ];
  if ($version == 6) {
    $edit['d6_source_base_path'] = $this
      ->getSourceBasePath();
  }
  else {
    $edit['source_base_path'] = $this
      ->getSourceBasePath();
    $edit['source_private_file_path'] = $this
      ->getSourcePrivateBasePath();
  }
  if (count($drivers) !== 1) {
    $edit['driver'] = $driver;
  }
  return $edit;
}