3 namespace Drupal\Tests\field\Kernel\Migrate\d7;
5 use Drupal\Core\Entity\Entity\EntityViewMode;
6 use Drupal\migrate\MigrateExecutable;
9 * Migrates and rolls back Drupal 7 view modes.
13 class RollbackViewModesTest extends MigrateViewModesTest {
16 * Tests migrating D7 view modes, then rolling back.
18 public function testMigration() {
19 // Test that the view modes have migrated (prior to rollback).
20 parent::testMigration();
22 $this->executeRollback('d7_view_modes');
24 // Check that view modes have been rolled back.
31 foreach ($view_mode_ids as $view_mode_id) {
32 $this->assertNull(EntityViewMode::load($view_mode_id));
37 * Executes a single rollback.
39 * @param string|\Drupal\migrate\Plugin\MigrationInterface $migration
40 * The migration to rollback, or its ID.
42 protected function executeRollback($migration) {
43 if (is_string($migration)) {
44 $this->migration = $this->getMigration($migration);
47 $this->migration = $migration;
49 (new MigrateExecutable($this->migration, $this))->rollback();