function MultilingualReviewPageTestBase::prepare

Same name and namespace in other branches
  1. 11.x core/modules/migrate_drupal_ui/tests/src/Functional/MultilingualReviewPageTestBase.php \Drupal\Tests\migrate_drupal_ui\Functional\MultilingualReviewPageTestBase::prepare()
  2. 10 core/modules/migrate_drupal_ui/tests/src/Functional/MultilingualReviewPageTestBase.php \Drupal\Tests\migrate_drupal_ui\Functional\MultilingualReviewPageTestBase::prepare()
  3. 9 core/modules/migrate_drupal_ui/tests/src/Functional/MultilingualReviewPageTestBase.php \Drupal\Tests\migrate_drupal_ui\Functional\MultilingualReviewPageTestBase::prepare()

Performs preparation for the form tests.

This is not done in setup because setup executes before the source database is loaded.

File

core/modules/migrate_drupal_ui/tests/src/Functional/MultilingualReviewPageTestBase.php, line 100

Class

MultilingualReviewPageTestBase
Provides a base class for testing the review step of the Upgrade form.

Namespace

Drupal\Tests\migrate_drupal_ui\Functional

Code

public function prepare() {
  $connection_options = $this->sourceDatabase
    ->getConnectionOptions();
  $driver = $connection_options['driver'];
  $connection_options['prefix'] = $connection_options['prefix']['default'];
  // 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']);
  $version = $this->getLegacyDrupalVersion($this->sourceDatabase);
  $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();
  }
  if (count($drivers) !== 1) {
    $edit['driver'] = $driver;
  }
  $this->edits = $this->translatePostValues($edit);
  // Enable all modules in the source except test and example modules, but
  // include simpletest.
  /** @var \Drupal\Core\Database\Query\SelectInterface $update */
  $update = $this->sourceDatabase
    ->update('system')
    ->fields([
    'status' => 1,
  ])
    ->condition('type', 'module');
  $and = $update->andConditionGroup()
    ->condition('name', '%test%', 'NOT LIKE')
    ->condition('name', '%example%', 'NOT LIKE');
  $conditions = $update->orConditionGroup();
  $conditions->condition($and);
  $conditions->condition('name', 'simpletest');
  $update->condition($conditions);
  $update->execute();
  // Create entries for D8 test modules.
  $insert = $this->sourceDatabase
    ->insert('system')
    ->fields([
    'filename' => 'migrate_status_active_test',
    'name' => 'migrate_status_active_test',
    'type' => 'module',
    'status' => 1,
  ]);
  $insert->execute();
}

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