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