diff --git a/core/modules/field/tests/src/Kernel/Migrate/d7/RollbackViewModesTest.php b/core/modules/field/tests/src/Kernel/Migrate/d7/RollbackViewModesTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b069387cfc6a8caefef56c34b5bb25bb54a361f8 --- /dev/null +++ b/core/modules/field/tests/src/Kernel/Migrate/d7/RollbackViewModesTest.php @@ -0,0 +1,52 @@ +executeRollback('d7_view_modes'); + + // Check that view modes have been rolled back. + $view_mode_ids = [ + 'comment.full', + 'node.teaser', + 'node.full', + 'user.full', + ]; + foreach ($view_mode_ids as $view_mode_id) { + $this->assertNull(EntityViewMode::load($view_mode_id)); + } + } + + /** + * Executes a single rollback. + * + * @param string|\Drupal\migrate\Plugin\MigrationInterface $migration + * The migration to rollback, or its ID. + */ + protected function executeRollback($migration) { + if (is_string($migration)) { + $this->migration = $this->getMigration($migration); + } + else { + $this->migration = $migration; + } + (new MigrateExecutable($this->migration, $this))->rollback(); + } + +} diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php index 810152aa12deca2a41c6db4c94424d3000ee3b99..fad171b5904b825f2ea268d24f7c101034586939 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php @@ -20,4 +20,12 @@ public function getIds() { return $ids; } + /** + * {@inheritdoc} + */ + public function rollback(array $destination_identifier) { + $destination_identifier = implode('.', $destination_identifier); + parent::rollback(array($destination_identifier)); + } + }