You are here

protected function NodewordsEntitiesTest::fileMigrationSetup in Metatag 8

Prepare the file migration for running.

Copied from FileMigrationSetupTrait from 8.4 so that this doesn't have to then also extend getFileMigrationInfo().

1 call to NodewordsEntitiesTest::fileMigrationSetup()
NodewordsEntitiesTest::setUp in tests/src/Kernel/Migrate/d6/NodewordsEntitiesTest.php

File

tests/src/Kernel/Migrate/d6/NodewordsEntitiesTest.php, line 53

Class

NodewordsEntitiesTest
Tests migration of per-entity data from Nodewords-D6.

Namespace

Drupal\Tests\metatag\Kernel\Migrate\d6

Code

protected function fileMigrationSetup() {
  $this
    ->installSchema('file', [
    'file_usage',
  ]);
  $this
    ->installEntitySchema('file');
  $this->container
    ->get('stream_wrapper_manager')
    ->registerWrapper('public', PublicStream::class, StreamWrapperInterface::NORMAL);
  $fs = \Drupal::service('file_system');

  // The public file directory active during the test will serve as the
  // root of the fictional Drupal 6 site we're migrating.
  $fs
    ->mkdir('public://sites/default/files', NULL, TRUE);
  file_put_contents('public://sites/default/files/cube.jpeg', str_repeat('*', 3620));

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

  // 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('public://');
  $migration
    ->set('source', $source);
  $this
    ->executeMigration($migration);
}