43a0ea6e474052c6e26e44373d259681dadceedf
[yaffs-website] / web / core / modules / file / tests / src / Kernel / Migrate / d6 / MigrateUploadEntityFormDisplayTest.php
1 <?php
2
3 namespace Drupal\Tests\file\Kernel\Migrate\d6;
4
5 use Drupal\Core\Entity\Entity\EntityFormDisplay;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
7
8 /**
9  * Upload form entity display.
10  *
11  * @group migrate_drupal_6
12  */
13 class MigrateUploadEntityFormDisplayTest extends MigrateDrupal6TestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['menu_ui'];
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function setUp() {
24     parent::setUp();
25     $this->migrateFields();
26   }
27
28   /**
29    * Tests Drupal 6 upload settings to Drupal 8 entity form display migration.
30    */
31   public function testUploadEntityFormDisplay() {
32     $this->executeMigration('d6_upload_entity_form_display');
33
34     $display = EntityFormDisplay::load('node.page.default');
35     $component = $display->getComponent('upload');
36     $this->assertIdentical('file_generic', $component['type']);
37
38     $display = EntityFormDisplay::load('node.story.default');
39     $component = $display->getComponent('upload');
40     $this->assertIdentical('file_generic', $component['type']);
41
42     // Assure this doesn't exist.
43     $display = EntityFormDisplay::load('node.article.default');
44     $component = $display->getComponent('upload');
45     $this->assertTrue(is_null($component));
46
47     $this->assertIdentical(['node', 'page', 'default', 'upload'], $this->getMigration('d6_upload_entity_form_display')->getIdMap()->lookupDestinationId(['page']));
48   }
49
50   /**
51    * Tests that entity displays are ignored appropriately.
52    *
53    * Entity displays should be ignored when they belong to node types which
54    * were not migrated.
55    */
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']);
60
61     // d6_upload_entity_form_display should skip over the "story" node type
62     // config because according to the map table, it didn't occur.
63     $migration = $this->getMigration('d6_upload_entity_form_display');
64
65     $this->executeMigration($migration);
66     $this->assertNull($migration->getIdMap()->lookupDestinationIds(['node_type' => 'story'])[0][0]);
67   }
68
69 }