diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php index dbe67abc1b..472a0de94a 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php @@ -170,11 +170,13 @@ public function testMigrateUpgradeExecute() { } /** - * Gets the source base path for private files the concrete test. + * Provides the source base path for private files for the credential form. * * @return string * The source base path. */ - abstract protected function getSourcePrivateBasePath(); + protected function getSourcePrivateBasePath() { + return NULL; + } } diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php index 75e1b2d785..f8ae8f1e24 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php @@ -267,7 +267,8 @@ protected function assertFileMigrations() { $fs = \Drupal::service('file_system'); $files = $this->getManagedFiles(); foreach ($files as $file) { - $scheme = preg_replace('/:.*/', '', $file['uri']); + preg_match('/^(private|public|temporary):/', $file['uri'], $matches); + $scheme = $matches[1]; $filepath = $fs->realpath($file['uri']); if ($scheme === 'temporary') { $this->assertFileNotExists($filepath); diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php index 0d3158ffe0..eaa62a3b42 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php @@ -3,7 +3,6 @@ namespace Drupal\Tests\migrate_drupal_ui\Functional\d7; use Drupal\Core\File\FileSystemInterface; -use Drupal\migrate\MigrateException; use Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeTestBase; /** @@ -214,9 +213,9 @@ protected function makeFiles() { // Get file information from the source database. $files = $this->getManagedFiles(); foreach ($files as $file) { - $scheme = preg_replace('/:.*/', '', $file['uri']); - - $path = isset($this->variable[$scheme]) ? $this->variable[$scheme] : ''; + 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']; // Create the file. @@ -224,16 +223,10 @@ protected function makeFiles() { if (!$source_file) { // If fopen didn't work, make sure there's a writable directory in // place. - $this->fs = \Drupal::service('file_system'); $dir = $this->fs->dirname($filepath); - if (!$this->fs->prepareDirectory($dir, FileSystemInterface:: CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) { - throw new MigrateException("Could not create or write to directory '$dir'"); - } + $this->fs->prepareDirectory($dir, FileSystemInterface:: CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS); // Let's try that fopen again. $source_file = @fopen($filepath, 'w'); - if (!$source_file) { - throw new MigrateException("Could not write to file '$filepath'"); - } } fwrite($source_file, '42'); } @@ -246,7 +239,7 @@ protected function makeFiles() { * The file scheme. */ public function getSourcePath($scheme) { - $base_path = isset($this->basePath[$scheme]) ? $this->basePath[$scheme] : ''; + $base_path = $this->basePath[$scheme] ?: ''; // Puts the source files in the site temp directory. return $this->tempFilesDirectory . '/' . $base_path; } @@ -308,10 +301,4 @@ protected function getMissingPaths() { protected function getSourceBasePath() { } - /** - * {@inheritdoc} - */ - protected function getSourcePrivateBasePath() { - } - } diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php index 3f94cf66aa..ab8a75be64 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php @@ -74,17 +74,6 @@ protected function getSourcePrivateBasePath() { return __DIR__ . '/files'; } - /** - * {@inheritdoc} - */ - protected function getFilenames() { - return [ - 'public' => ['cube.jpeg', 'ds9.txt'], - 'private' => ['Babylon5.txt'], - 'temporary' => ['TerokNor.txt'], - ]; - } - /** * {@inheritdoc} */