Version 1
[yaffs-website] / web / core / modules / file / tests / src / Kernel / Migrate / d6 / FileMigrationTestTrait.php
1 <?php
2
3 namespace Drupal\Tests\file\Kernel\Migrate\d6;
4 use Drupal\migrate\Plugin\MigrationInterface;
5
6 /**
7  * Helper for setting up a file migration test.
8  */
9 trait FileMigrationTestTrait {
10
11   /**
12    * Setup and execute d6_file migration.
13    */
14   protected function setUpMigratedFiles() {
15     $this->installEntitySchema('file');
16     $this->installConfig(['file']);
17
18     $this->executeMigration('d6_file');
19   }
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function prepareMigration(MigrationInterface $migration) {
25     // File migrations need a source_base_path.
26     // @see MigrateUpgradeRunBatch::run
27     $destination = $migration->getDestinationConfiguration();
28     if ($destination['plugin'] === 'entity:file') {
29       // Make sure we have a single trailing slash.
30       $source = $migration->getSourceConfiguration();
31       $source['site_path'] = 'core/modules/simpletest';
32       $source['constants']['source_base_path'] = \Drupal::root() . '/';
33       $migration->set('source', $source);
34     }
35   }
36
37 }