You are here

protected function MigrateUpgradeTestBase::getCredentials in Drupal 9

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

3 calls to MigrateUpgradeTestBase::getCredentials()
CredentialFormTest::testCredentialFrom in core/modules/migrate_drupal_ui/tests/src/Functional/CredentialFormTest.php
Test the credential form.
DoubleSlashTest::testMigrateUpgradeExecute in core/modules/migrate_drupal_ui/tests/src/Functional/d7/DoubleSlashTest.php
Executes all steps of migrations upgrade.
MigrateUpgradeTestBase::submitCredentialForm in core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php
Navigates to the credential form and submits valid credentials.

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;
}