MigrateUploadEntityFormDisplayTest.php 2.17 KB
Newer Older
1
2
<?php

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
10
 * Upload form entity display.
 *
11
 * @group migrate_drupal_6
12
 */
13
class MigrateUploadEntityFormDisplayTest extends MigrateDrupal6TestBase {
14
15
16

  /**
   * {@inheritdoc}
17
   */
18
  protected static $modules = ['menu_ui'];
19
20
21

  /**
   * {@inheritdoc}
22
   */
23
  protected function setUp(): void {
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
33
    $this->executeMigration('d6_upload_entity_form_display');

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->assertNull($component);
46

47
    $this->assertIdentical([['node', 'page', 'default', 'upload']], $this->getMigration('d6_upload_entity_form_display')->getIdMap()->lookupDestinationIds(['page']));
48
49
  }

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  /**
   * Tests that entity displays are ignored appropriately.
   *
   * Entity displays should be ignored when they belong to node types which
   * were not migrated.
   */
  public function testSkipNonExistentNodeType() {
    // The "story" node type is migrated by d6_node_type but we need to pretend
    // that it didn't occur, so record that in the map table.
    $this->mockFailure('d6_node_type', ['type' => 'story']);

    // d6_upload_entity_form_display should skip over the "story" node type
    // config because according to the map table, it didn't occur.
    $migration = $this->getMigration('d6_upload_entity_form_display');

    $this->executeMigration($migration);
    $this->assertNull($migration->getIdMap()->lookupDestinationIds(['node_type' => 'story'])[0][0]);
  }

69
}