You are here

public function DoubleSlashTest::testMigrateUpgradeExecute in Drupal 9

Executes all steps of migrations upgrade.

File

core/modules/migrate_drupal_ui/tests/src/Functional/d7/DoubleSlashTest.php, line 45

Class

DoubleSlashTest
Tests that a double slash is not in d7_file file not found migrate messages.

Namespace

Drupal\Tests\migrate_drupal_ui\Functional\d7

Code

public function testMigrateUpgradeExecute() {

  // Change fid 1 to a filename that does not exist.
  $this->sourceDatabase
    ->update('file_managed')
    ->condition('fid', 1)
    ->fields([
    'filename' => 'foo.txt',
    'uri' => 'public://foo.txt',
  ])
    ->execute();

  // Get valid credentials.
  $edits = $this
    ->translatePostValues($this
    ->getCredentials());

  // Start the upgrade process.
  $this
    ->drupalGet('/upgrade');
  $this
    ->submitForm([], 'Continue');
  $this
    ->submitForm($edits, 'Review upgrade');
  $this
    ->submitForm([], 'I acknowledge I may lose data. Continue anyway.');
  $this
    ->submitForm([], 'Perform upgrade');

  // Tests the migration log contains an error message.
  $migration = $this
    ->getMigrationPluginManager()
    ->createInstance('d7_file');
  $messages = $migration
    ->getIdMap()
    ->getMessages();
  $count = 0;
  foreach ($messages as $message) {
    $count++;
    $this
      ->assertStringContainsString('/migrate_drupal_ui/tests/src/Functional/d7/files/sites/default/files/foo.txt', $message->message);
    $this
      ->assertSame(MigrationInterface::MESSAGE_ERROR, (int) $message->level);
  }
  $this
    ->assertSame(1, $count);
}