You are here

trait FileMigrationTestTrait in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/file/tests/src/Kernel/Migrate/d6/FileMigrationTestTrait.php \Drupal\Tests\file\Kernel\Migrate\d6\FileMigrationTestTrait

Helper for setting up a file migration test.

Hierarchy

5 files declare their use of FileMigrationTestTrait
MigrateImageTest.php in core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageTest.php
MigrateNodeCompleteTest.php in core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeCompleteTest.php
MigrateNodeTest.php in core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php
MigrateUserPictureD6FileTest.php in core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserPictureD6FileTest.php
MigrateUserTest.php in core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserTest.php

File

core/modules/file/tests/src/Kernel/Migrate/d6/FileMigrationTestTrait.php, line 10

Namespace

Drupal\Tests\file\Kernel\Migrate\d6
View source
trait FileMigrationTestTrait {

  /**
   * Setup and execute d6_file migration.
   */
  protected function setUpMigratedFiles() {
    $this
      ->installEntitySchema('file');
    $this
      ->installConfig([
      'file',
    ]);
    $this
      ->executeMigration('d6_file');
  }

  /**
   * {@inheritdoc}
   */
  protected function prepareMigration(MigrationInterface $migration) {

    // File migrations need a source_base_path.
    // @see MigrateUpgradeRunBatch::run
    $destination = $migration
      ->getDestinationConfiguration();
    if ($destination['plugin'] === 'entity:file') {

      // Make sure we have a single trailing slash.
      $source = $migration
        ->getSourceConfiguration();
      $source['site_path'] = 'core/modules/simpletest';
      $source['constants']['source_base_path'] = $this->root . '/';
      $migration
        ->set('source', $source);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FileMigrationTestTrait::prepareMigration protected function
FileMigrationTestTrait::setUpMigratedFiles protected function Setup and execute d6_file migration.