MigrateUserProfileTranslationRollbackTest.php in Drupal 9
File
core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateUserProfileTranslationRollbackTest.php
View source
<?php
namespace Drupal\Tests\config_translation\Kernel\Migrate\d6;
use Drupal\migrate\MigrateExecutable;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
class MigrateUserProfileTranslationRollbackTest extends MigrateDrupal6TestBase {
protected static $modules = [
'config_translation',
'locale',
'language',
'field',
];
public function testRollback() {
$migration_ids = [
'user_profile_field',
'd6_profile_field_option_translation',
'user_profile_field_instance',
'd6_user_profile_field_instance_translation',
'language',
];
$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, []);
$ids = array_keys($migrations);
$this
->executeMigrations($ids);
$ids = array_reverse($ids);
try {
foreach ($ids as $id) {
if ($id == 'language') {
continue;
}
$migration = $migrations[$id];
(new MigrateExecutable($migration, $this))
->rollback();
}
} catch (\Exception $e) {
}
}
}