Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / file / tests / src / Kernel / Migrate / d7 / FileMigrationSetupTrait.php
1 <?php
2
3 namespace Drupal\Tests\file\Kernel\Migrate\d7;
4
5 use Drupal\Core\StreamWrapper\PublicStream;
6 use Drupal\Core\StreamWrapper\StreamWrapperInterface;
7
8 /**
9  * A trait to setup the file migration.
10  */
11 trait FileMigrationSetupTrait {
12
13   /**
14    * Prepare the file migration for running.
15    */
16   protected function fileMigrationSetup() {
17     $this->installSchema('file', ['file_usage']);
18     $this->installEntitySchema('file');
19     $this->container->get('stream_wrapper_manager')->registerWrapper('public', PublicStream::class, StreamWrapperInterface::NORMAL);
20
21     $fs = \Drupal::service('file_system');
22     // The public file directory active during the test will serve as the
23     // root of the fictional Drupal 7 site we're migrating.
24     $fs->mkdir('public://sites/default/files', NULL, TRUE);
25     file_put_contents('public://sites/default/files/cube.jpeg', str_repeat('*', 3620));
26
27     /** @var \Drupal\migrate\Plugin\Migration $migration */
28     $migration = $this->getMigration('d7_file');
29     // Set the source plugin's source_base_path configuration value, which
30     // would normally be set by the user running the migration.
31     $source = $migration->getSourceConfiguration();
32     $source['constants']['source_base_path'] = $fs->realpath('public://');
33     $migration->set('source', $source);
34     $this->executeMigration($migration);
35   }
36
37 }