function MigrateUserProfileTranslationRollbackTest::testRollback
Same name in other branches
- 9 core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateUserProfileTranslationRollbackTest.php \Drupal\Tests\config_translation\Kernel\Migrate\d6\MigrateUserProfileTranslationRollbackTest::testRollback()
- 11.x core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateUserProfileTranslationRollbackTest.php \Drupal\Tests\config_translation\Kernel\Migrate\d6\MigrateUserProfileTranslationRollbackTest::testRollback()
Tests rollback of the complete node migration.
File
-
core/
modules/ config_translation/ tests/ src/ Kernel/ Migrate/ d6/ MigrateUserProfileTranslationRollbackTest.php, line 30
Class
- MigrateUserProfileTranslationRollbackTest
- Tests rollback of user profile translations.
Namespace
Drupal\Tests\config_translation\Kernel\Migrate\d6Code
public function testRollback() : void {
$migration_ids = [
'user_profile_field',
'd6_profile_field_option_translation',
'user_profile_field_instance',
'd6_user_profile_field_instance_translation',
'language',
];
/** @var \Drupal\migrate\Plugin\MigrationPluginManager $migration_plugin_manager */
$migration_plugin_manager = \Drupal::service('plugin.manager.migration');
$migrations = [];
foreach ($migration_ids as $migration_id) {
$migrations[$migration_id] = $migration_plugin_manager->createInstance($migration_id, []);
}
$migrations = $migration_plugin_manager->buildDependencyMigration($migrations, []);
// Execute the import.
$ids = array_keys($migrations);
$this->executeMigrations($ids);
// Execute the rollback.
$ids = array_reverse($ids);
try {
foreach ($ids as $id) {
// Language rollback tries to rollback the default language so skip it.
if ($id == 'language') {
continue;
}
$migration = $migrations[$id];
(new MigrateExecutable($migration, $this))->rollback();
}
} catch (\Exception $e) {
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.