protected function MigrateUiParagraphsTestBase::assertMigrateUpgradeViaUi

Executes the upgrade process by the UI and asserts basic expectations.

1 call to MigrateUiParagraphsTestBase::assertMigrateUpgradeViaUi()
MigrateUiParagraphsTest::testParagraphsMigrate in paragraphs/tests/src/Functional/Migrate/MigrateUiParagraphsTest.php
Tests the result of the paragraphs migration.

File

paragraphs/tests/src/Functional/Migrate/MigrateUiParagraphsTestBase.php, line 402

Class

MigrateUiParagraphsTestBase
Provides a base class for testing Paragraphs migration via the UI.

Namespace

Drupal\Tests\paragraphs\Functional\Migrate

Code

protected function assertMigrateUpgradeViaUi() {
  $connection_options = $this->sourceDatabase
    ->getConnectionOptions();
  $this
    ->drupalGet('/upgrade');
  $session = $this
    ->assertSession();
  $session
    ->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal');
  $this
    ->submitForm([], $this
    ->t('Continue'));
  $session
    ->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
  $driver = $connection_options['driver'];
  if (floatval(\Drupal::VERSION) < 9.300000000000001) {
    $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.
  if (method_exists(Database::class, 'getDriverList')) {
    $drivers = Database::getDriverList()
      ->getInstallableList();
    $form = $drivers[$driver]
      ->getInstallTasks()
      ->getFormOptions($connection_options);
  }
  else {
    $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
      ->getSourcePrivateFilesPath(),
    'version' => $version,
    'source_base_path' => $this
      ->getSourceBasePath(),
  ];
  if (count($drivers) !== 1) {
    $edit['driver'] = $driver;
  }
  $edits = $this
    ->translatePostValues($edit);
  $this
    ->submitForm($edits, $this
    ->t('Review upgrade'));
  $session
    ->pageTextNotContains('Resolve all issues below to continue the upgrade.');

  // ID conflict form.
  $session
    ->buttonExists($this
    ->t('I acknowledge I may lose data. Continue anyway.'));
  $this
    ->submitForm([], $this
    ->t('I acknowledge I may lose data. Continue anyway.'));
  $session
    ->statusCodeEquals(200);

  // Perform the upgrade.
  $this
    ->submitForm([], $this
    ->t('Perform upgrade'));
  $session
    ->pageTextContains($this
    ->t('Congratulations, you upgraded Drupal!'));

  // Have to reset all the statics after migration to ensure entities are
  // loadable.
  $this
    ->resetAll();
}