You are here

abstract class MigrateUpgradeExecuteTestBase in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php \Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeExecuteTestBase
  2. 9 core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php \Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeExecuteTestBase

Provides a base class for testing a complete upgrade via the UI.

Hierarchy

Expanded class hierarchy of MigrateUpgradeExecuteTestBase

6 files declare their use of MigrateUpgradeExecuteTestBase
DoubleSlashTest.php in core/modules/migrate_drupal_ui/tests/src/Functional/d7/DoubleSlashTest.php
IdConflictTest.php in core/modules/migrate_drupal_ui/tests/src/Functional/d6/IdConflictTest.php
IdConflictTest.php in core/modules/migrate_drupal_ui/tests/src/Functional/d7/IdConflictTest.php
NodeClassicTest.php in core/modules/migrate_drupal_ui/tests/src/Functional/d6/NodeClassicTest.php
Upgrade6Test.php in core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php

... See full list

File

core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php, line 10

Namespace

Drupal\Tests\migrate_drupal_ui\Functional
View source
abstract class MigrateUpgradeExecuteTestBase extends MigrateUpgradeTestBase {
  use CreateTestContentEntitiesTrait;

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();

    // Create content.
    $this
      ->createContent();
  }

  /**
   * Executes an upgrade and then an incremental upgrade.
   */
  public function doUpgradeAndIncremental() {

    // Start the upgrade process.
    $this
      ->submitCredentialForm();
    $session = $this
      ->assertSession();
    $this
      ->submitForm([], 'I acknowledge I may lose data. Continue anyway.');
    $session
      ->statusCodeEquals(200);

    // Test the review form.
    $this
      ->assertReviewForm();
    $this
      ->useTestMailCollector();
    $this
      ->submitForm([], 'Perform upgrade');
    $this
      ->assertUpgrade($this
      ->getEntityCounts());
    \Drupal::service('module_installer')
      ->install([
      'forum',
    ]);
    \Drupal::service('module_installer')
      ->install([
      'book',
    ]);

    // Test incremental migration.
    $this
      ->createContentPostUpgrade();
    $this
      ->drupalGet('/upgrade');
    $session
      ->pageTextContains("An upgrade has already been performed on this site. To perform a new migration, create a clean and empty new install of Drupal {$this->destinationSiteVersion}. Rollbacks are not yet supported through the user interface.");
    $this
      ->submitForm([], 'Import new configuration and content from old site');
    $this
      ->submitForm($this->edits, 'Review upgrade');
    $this
      ->submitForm([], 'I acknowledge I may lose data. Continue anyway.');
    $session
      ->statusCodeEquals(200);

    // Run the incremental migration and check the results.
    $this
      ->submitForm([], 'Perform upgrade');
    $this
      ->assertUpgrade($this
      ->getEntityCountsIncremental());
  }

  /**
   * Helper to set the test mail collector in settings.php.
   */
  public function useTestMailCollector() {

    // Set up an override.
    $settings['config']['system.mail']['interface']['default'] = (object) [
      'value' => 'test_mail_collector',
      'required' => TRUE,
    ];
    $this
      ->writeSettings($settings);
  }

}

Members