3 namespace Drupal\Tests\file\Kernel\Migrate\d6;
5 use Drupal\Core\Entity\Entity\EntityViewDisplay;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
9 * Upload entity display.
11 * @group migrate_drupal_6
13 class MigrateUploadEntityDisplayTest extends MigrateDrupal6TestBase {
18 public static $modules = ['menu_ui'];
23 protected function setUp() {
25 $this->migrateFields();
29 * Tests Drupal 6 upload settings to Drupal 8 entity display migration.
31 public function testUploadEntityDisplay() {
32 $this->executeMigration('d6_upload_entity_display');
34 $display = EntityViewDisplay::load('node.page.default');
35 $component = $display->getComponent('upload');
36 $this->assertIdentical('file_default', $component['type']);
38 $display = EntityViewDisplay::load('node.story.default');
39 $component = $display->getComponent('upload');
40 $this->assertIdentical('file_default', $component['type']);
42 // Assure this doesn't exist.
43 $display = EntityViewDisplay::load('node.article.default');
44 $component = $display->getComponent('upload');
45 $this->assertTrue(is_null($component));
47 $this->assertIdentical(['node', 'page', 'default', 'upload'], $this->getMigration('d6_upload_entity_display')->getIdMap()->lookupDestinationID(['page']));
51 * Tests that entity displays are ignored appropriately.
53 * Entity displays should be ignored when they belong to node types which
56 public function testSkipNonExistentNodeType() {
57 // The "story" node type is migrated by d6_node_type but we need to pretend
58 // that it didn't occur, so record that in the map table.
59 $this->mockFailure('d6_node_type', ['type' => 'story']);
61 // d6_upload_entity_display should skip over the "story" node type config
62 // because, according to the map table, it didn't occur.
63 $migration = $this->getMigration('d6_upload_entity_display');
65 $this->executeMigration($migration);
66 $this->assertNull($migration->getIdMap()->lookupDestinationIds(['node_type' => 'story'])[0][0]);