function CredentialFormTest::getDestinationSiteCredentials

Same name and namespace in other branches
  1. 11.x core/modules/migrate_drupal_ui/tests/src/Functional/CredentialFormTest.php \Drupal\Tests\migrate_drupal_ui\Functional\CredentialFormTest::getDestinationSiteCredentials()

Creates an array of destination site 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

1 call to CredentialFormTest::getDestinationSiteCredentials()
CredentialFormTest::testCredentialFrom in core/modules/migrate_drupal_ui/tests/src/Functional/CredentialFormTest.php
Test the credential form.

File

core/modules/migrate_drupal_ui/tests/src/Functional/CredentialFormTest.php, line 149

Class

CredentialFormTest
Test the credential form for both Drupal 6 and Drupal 7 sources.

Namespace

Drupal\Tests\migrate_drupal_ui\Functional

Code

protected function getDestinationSiteCredentials() {
  $connection_options = \Drupal::database()->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 = Database::getDriverList()->getInstallableList();
  $form = $drivers[$driver]->getInstallTasks()
    ->getFormOptions($connection_options);
  $connection_options = array_intersect_key($connection_options, $form + $form['advanced_options']);
  // Remove isolation_level since that option is not configurable in the UI.
  unset($connection_options['isolation_level']);
  $edit = [
    $driver => $connection_options,
    'version' => $version,
  ];
  if (count($drivers) !== 1) {
    $edit['driver'] = $driver;
  }
  return $edit;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.