3 namespace Drupal\Tests\field\Kernel\Migrate\d7;
5 use Drupal\Core\Entity\Entity\EntityViewMode;
6 use Drupal\Core\Entity\EntityViewModeInterface;
7 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
10 * Tests migration of D7 view modes.
14 class MigrateViewModesTest extends MigrateDrupal7TestBase {
16 public static $modules = ['comment', 'node', 'taxonomy'];
21 protected function setUp() {
23 $this->installEntitySchema('comment');
24 $this->installEntitySchema('node');
25 $this->executeMigration('d7_view_modes');
29 * Asserts various aspects of a view mode entity.
33 * @param string $label
34 * The expected label of the view mode.
35 * @param string $entity_type
36 * The expected entity type ID which owns the view mode.
38 protected function assertEntity($id, $label, $entity_type) {
39 /** @var \Drupal\Core\Entity\EntityViewModeInterface $view_mode */
40 $view_mode = EntityViewMode::load($id);
41 $this->assertTrue($view_mode instanceof EntityViewModeInterface);
42 $this->assertIdentical($label, $view_mode->label());
43 $this->assertIdentical($entity_type, $view_mode->getTargetType());
47 * Tests migration of D7 view mode variables to D8 config entities.
49 public function testMigration() {
50 $this->assertEntity('comment.full', 'Full', 'comment');
51 $this->assertEntity('node.teaser', 'Teaser', 'node');
52 $this->assertEntity('node.full', 'Full', 'node');
53 $this->assertEntity('node.custom', 'custom', 'node');
54 $this->assertEntity('user.full', 'Full', 'user');