You are here

protected function FileMigrationSetupTrait::fileMigrationSetup in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/file/tests/src/Kernel/Migrate/d7/FileMigrationSetupTrait.php \Drupal\Tests\file\Kernel\Migrate\d7\FileMigrationSetupTrait::fileMigrationSetup()

Prepare the file migration for running.

6 calls to FileMigrationSetupTrait::fileMigrationSetup()
FollowUpMigrationsTest::setUp in core/modules/migrate_drupal/tests/src/Kernel/d7/FollowUpMigrationsTest.php
MigrateFileTest::setUp in core/modules/file/tests/src/Kernel/Migrate/d7/MigrateFileTest.php
MigrateNodeCompleteTest::setUp in core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeCompleteTest.php
MigrateNodeRevisionTest::setUp in core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeRevisionTest.php
MigrateNodeTest::setUp in core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php

... See full list

File

core/modules/file/tests/src/Kernel/Migrate/d7/FileMigrationSetupTrait.php, line 24

Class

FileMigrationSetupTrait
A trait to setup the file migration.

Namespace

Drupal\Tests\file\Kernel\Migrate\d7

Code

protected function fileMigrationSetup() {
  $this
    ->installEntitySchema('file');
  $this
    ->installSchema('file', [
    'file_usage',
  ]);
  $info = $this
    ->getFileMigrationInfo();
  $fs = $this->container
    ->get('file_system');

  // Ensure that the files directory exists.
  $fs
    ->mkdir(dirname($info['path']), NULL, TRUE);

  // Put test file in the source directory.
  file_put_contents($info['path'], str_repeat('*', $info['size']));

  /** @var \Drupal\migrate\Plugin\Migration $migration */
  $migration = $this
    ->getMigration($info['plugin_id']);

  // Set the source plugin's source_base_path configuration value, which
  // would normally be set by the user running the migration.
  $source = $migration
    ->getSourceConfiguration();
  $source['constants']['source_base_path'] = $fs
    ->realpath($info['base_path']);
  $migration
    ->set('source', $source);
  $this
    ->executeMigration($migration);
}