Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / field / tests / src / Kernel / Migrate / d7 / RollbackViewModesTest.php
1 <?php
2
3 namespace Drupal\Tests\field\Kernel\Migrate\d7;
4
5 use Drupal\Core\Entity\Entity\EntityViewMode;
6 use Drupal\migrate\MigrateExecutable;
7
8 /**
9  * Migrates and rolls back Drupal 7 view modes.
10  *
11  * @group field
12  */
13 class RollbackViewModesTest extends MigrateViewModesTest {
14
15   /**
16    * Tests migrating D7 view modes, then rolling back.
17    */
18   public function testMigration() {
19     // Test that the view modes have migrated (prior to rollback).
20     parent::testMigration();
21
22     $this->executeRollback('d7_view_modes');
23
24     // Check that view modes have been rolled back.
25     $view_mode_ids = [
26       'comment.full',
27       'node.teaser',
28       'node.full',
29       'user.full',
30     ];
31     foreach ($view_mode_ids as $view_mode_id) {
32       $this->assertNull(EntityViewMode::load($view_mode_id));
33     }
34   }
35
36   /**
37    * Executes a single rollback.
38    *
39    * @param string|\Drupal\migrate\Plugin\MigrationInterface $migration
40    *   The migration to rollback, or its ID.
41    */
42   protected function executeRollback($migration) {
43     if (is_string($migration)) {
44       $this->migration = $this->getMigration($migration);
45     }
46     else {
47       $this->migration = $migration;
48     }
49     (new MigrateExecutable($this->migration, $this))->rollback();
50   }
51
52 }