function FilePathTest::testFilePath
Same name in other branches
- 9 core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php \Drupal\Tests\migrate_drupal_ui\Functional\d7\FilePathTest::testFilePath()
- 11.x core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php \Drupal\Tests\migrate_drupal_ui\Functional\d7\FilePathTest::testFilePath()
Executes all steps of migrations upgrade.
@dataProvider providerTestFilePath
Parameters
string $file_private_path: The source database file_private_path value.
string $file_public_path: The source database file_public_path value.
string $file_temporary_path: The source database file_temporary_path value.
string $private: The path to the source private files.
string $public: The path to the source public files.
string $temporary: The path to the source temporary files.
File
-
core/
modules/ migrate_drupal_ui/ tests/ src/ Functional/ d7/ FilePathTest.php, line 97
Class
- FilePathTest
- Tests the Drupal 7 public and private file migrations.
Namespace
Drupal\Tests\migrate_drupal_ui\Functional\d7Code
public function testFilePath(string $file_private_path, string $file_public_path, string $file_temporary_path, string $private, string $public, string $temporary) : void {
$this->sourceFileScheme['private'] = $file_private_path;
$this->sourceFileScheme['public'] = $file_public_path;
$this->sourceFileScheme['temporary'] = $file_temporary_path;
$this->localDirectory['private'] = $private;
$this->localDirectory['public'] = $public;
$this->localDirectory['temporary'] = $temporary;
// Create the source files.
$this->makeFiles();
// Set the source db variables.
$this->sourceDatabase
->update('variable')
->fields([
'value' => serialize($file_private_path),
])
->condition('name', 'file_private_path')
->execute();
$this->sourceDatabase
->update('variable')
->fields([
'value' => serialize($file_public_path),
])
->condition('name', 'file_public_path')
->execute();
$this->sourceDatabase
->update('variable')
->fields([
'value' => serialize($file_temporary_path),
])
->condition('name', 'file_temporary_path')
->execute();
$connection_options = $this->sourceDatabase
->getConnectionOptions();
$driver = $connection_options['driver'];
// Use the driver connection form to get the correct options out of the
// database settings. This supports all of the databases we test against.
$drivers = Database::getDriverList()->getInstallableList();
$form = $drivers[$driver]->getInstallTasks()
->getFormOptions($connection_options);
$connection_options = array_intersect_key($connection_options, $form + $form['advanced_options']);
// Remove isolation_level since that option is not configurable in the UI.
unset($connection_options['isolation_level']);
$edit = [
$driver => $connection_options,
'version' => '7',
];
if (count($drivers) !== 1) {
$edit['driver'] = $driver;
}
// Set the public and private base paths for the Credential Form.
$edit['source_private_file_path'] = $this->fs
->realpath($this->getSourcePath('private'));
$edit['source_base_path'] = $this->fs
->realpath($this->getSourcePath('public'));
$edits = $this->translatePostValues($edit);
// Start the upgrade.
$this->drupalGet('/upgrade');
$this->submitForm([], 'Continue');
$this->submitForm($edits, 'Review upgrade');
// The migrations are now in store - remove all but the file migrations.
$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.
$this->submitForm([], 'Perform upgrade');
$this->resetAll();
$this->assertFileMigrations();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.