diff -u b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php --- b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php +++ b/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php @@ -111,8 +111,8 @@ $definition = \Drupal::service('plugin.manager.migration')->getDefinition($migration_id); $configuration = []; - // Set the source plugin constant, source_base_path, for all migrations - // with a file entity destination. + // Set the source plugin constant, source_base_path, for all migrations with + // a file entity destination. // @todo https://www.drupal.org/node/2804611. // Find a way to avoid having to set configuration here. if ($definition['destination']['plugin'] === 'entity:file') { diff -u b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php --- b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php @@ -172,7 +172,7 @@ /** * Provides the source base path for private files for the credential form. * - * @return string + * @return string|null * The source base path. */ protected function getSourcePrivateBasePath() { reverted: --- b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/IdConflictTest.php +++ a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/IdConflictTest.php @@ -43,12 +43,6 @@ return __DIR__ . '/files'; } - /** - * {@inheritdoc} - */ - protected function getSourcePrivateBasePath() { - } - /** * {@inheritdoc} */ reverted: --- b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/NodeClassicTest.php +++ a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/NodeClassicTest.php @@ -50,12 +50,6 @@ return __DIR__ . '/files'; } - /** - * {@inheritdoc} - */ - protected function getSourcePrivateBasePath() { - } - /** * {@inheritdoc} */ reverted: --- b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php +++ a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php @@ -65,12 +65,6 @@ return __DIR__ . '/files'; } - /** - * {@inheritdoc} - */ - protected function getSourcePrivateBasePath() { - } - /** * {@inheritdoc} */ diff -u b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php --- b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php @@ -28,21 +28,24 @@ protected $defaultTheme = 'stark'; /** - * The file system. + * The file system service. * - * @var \Drupal\Core\File\FileSystem + * @var \Drupal\Core\File\FileSystemInterface */ protected $fs; /** - * The file path variables in the source database. + * The base path to the source files on the destination site. * * @var string[] */ protected $basePath = []; /** - * The file path variables in the source database. + * The file scheme variables in the source database. + * + * These are 'file_private_path', 'file_public_path', and + * 'file_temporary_path', * * @var string[] */ @@ -83,8 +86,6 @@ * @param string $temporary * The path to the source temporary files. * - * @throws \Drupal\migrate\MigrateException - * * @dataProvider providerTestFilePath */ public function testFilePath($file_private_path, $file_public_path, $file_temporary_path, $private, $public, $temporary) { @@ -140,13 +141,11 @@ $this->drupalPostForm(NULL, $edits, 'Review upgrade'); // The migrations are now in store - remove all but the file migrations. - $tempstore_private = \Drupal::service('tempstore.private'); - $store = $tempstore_private->get('migrate_drupal_ui'); - $all_migrations = $store->get('migrations'); - $migration_array = array_intersect_key($all_migrations, [ - 'd7_file' => [], - 'd7_file_private' => [], - ]); + $store = \Drupal::service('tempstore.private')->get('migrate_drupal_ui'); + $migration_array = array_intersect_key( + $store->get('migrations'), + array_flip(['d7_file', 'd7_file_private']) + ); $store->set('migrations', $migration_array); // Perform the migrations. @@ -163,41 +162,37 @@ */ public function providerTestFilePath() { return [ - // All source base paths are at temporary://. - [ - 'file_private_path' => 'sites/default/private', - 'file_public_path' => 'sites/default/files', - 'file_temporary_path' => '/tmp', - 'private' => '', - 'public' => '', - 'temporary' => '', + 'All source base paths are at temporary' => [ + 'sites/default/private', + 'sites/default/files', + '/tmp', + '', + '', + '', ], - // The private files are in a subdirectory. - [ - 'file_private_path' => 'sites/default/private', - 'file_public_path' => 'sites/default/files', - 'file_temporary_path' => '/tmp', - 'private' => 'abc', - 'public' => '', - 'temporary' => '', + 'The private files are in a subdirectory' => [ + 'sites/default/private', + 'sites/default/files', + '/tmp', + 'abc', + '', + '', ], - // The public files are in a subdirectory. - [ - 'file_private_path' => 'sites/default/private', - 'file_public_path' => 'sites/default/files', - 'file_temporary_path' => '/tmp', - 'private' => '', - 'public' => 'def', - 'temporary' => '', + ' The public files are in a subdirectory' => [ + 'sites/default/private', + 'sites/default/files', + '/tmp', + '', + 'def', + '', ], - // The private and public files are in separate subdirectories. - [ - 'file_private_path' => 'private', - 'file_public_path' => 'files', - 'file_temporary_path' => '/tmp', - 'private' => 'abc', - 'public' => 'def', - 'temporary' => 'xyz', + 'The private and public files are in separate subdirectories' => [ + 'private', + 'files', + '/tmp', + 'abc', + 'def', + 'xyz', ], ]; } @@ -213,11 +208,16 @@ // Get file information from the source database. $files = $this->getManagedFiles(); foreach ($files as $file) { - preg_match('/^(private|public|temporary):/', $file['uri'], $matches); + $this->assertSame(1, preg_match('/^(private|public|temporary):/', $file['uri'], $matches)); + //assertSame(1, preg_match('/^(private|public|temporary):/', $file['uri'], $matches)); $scheme = $matches[1]; - $path = $this->variable[$scheme] ?: ''; - $base_path = $this->getSourcePath($scheme) . '/' . $path; - $filepath = $base_path . '/' . $file['filename']; + $path = $this->variable[$scheme] ?? ''; + $filepath = implode('/', [ + $this->getSourcePath($scheme), + $path, + $file['filename'], + ]); + // Create the file. $source_file = @fopen($filepath, 'w'); if (!$source_file) { reverted: --- b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/IdConflictTest.php +++ a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/IdConflictTest.php @@ -45,12 +45,6 @@ return __DIR__ . '/files'; } - /** - * {@inheritdoc} - */ - protected function getSourcePrivateBasePath() { - } - /** * {@inheritdoc} */