diff --git a/core/modules/file/tests/src/Kernel/Migrate/d7/MigrateFileSubdirectoryTest.php b/core/modules/file/tests/src/Kernel/Migrate/d7/MigrateFileSubdirectoryTest.php new file mode 100644 index 000000000..6c81ae8ef --- /dev/null +++ b/core/modules/file/tests/src/Kernel/Migrate/d7/MigrateFileSubdirectoryTest.php @@ -0,0 +1,52 @@ +mkdir('sites/default/files/geometry'); + $this->fileMigrationSetup(); + } + + /** + * {@inheritdoc} + */ + protected function getFileMigrationInfo() { + return [ + 'path' => 'public://sites/default/files/geometry/cube.jpeg', + 'size' => '3620', + 'base_path' => 'public://', + 'plugin_id' => 'd7_file', + ]; + } + + /** + * Tests that all expected files are migrated. + */ + public function testFileMigration() { + $this->assertEntity(1, 'cube.jpeg', 'public://geometry/cube.jpeg', 'image/jpeg', '3620', '1421727515', '1421727515', '1'); + // Ensure temporary file was not migrated. + $this->assertNull(File::load(4)); + } + +} diff --git a/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileAlternatePathTest.php b/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileAlternatePathTest.php new file mode 100644 index 000000000..9e9fa9487 --- /dev/null +++ b/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileAlternatePathTest.php @@ -0,0 +1,59 @@ +setSetting('file_private_path', $this->container->get('site.path') . '/files/private'); + $this->fileMigrationSetup(); + } + + /** + * {@inheritdoc} + */ + protected function getFileMigrationInfo() { + return [ + 'path' => 'private://sites/default/files/private/Babylon5.txt', + 'size' => '3', + 'base_path' => 'private://', + 'plugin_id' => 'd7_file_private', + ]; + } + + /** + * {@inheritdoc} + */ + public function register(ContainerBuilder $container) { + parent::register($container); + $container->register('stream_wrapper.private', 'Drupal\Core\StreamWrapper\PrivateStream') + ->addTag('stream_wrapper', ['scheme' => 'private']); + } + + /** + * Tests that all expected files are migrated. + */ + public function testFileMigration() { + $this->assertEntity(3, 'Babylon5.txt', 'private://Babylon5.txt', 'text/plain', '3', '1486104045', '1486104045', '1'); + } + +}