MigrateUploadInstanceTest.php 1.38 KB
Newer Older
1
2
<?php

3
namespace Drupal\Tests\file\Kernel\Migrate\d6;
4

5
use Drupal\field\Entity\FieldConfig;
6
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
7
8

/**
9
10
 * Upload field instance migration.
 *
11
 * @group migrate_drupal_6
12
 */
13
class MigrateUploadInstanceTest extends MigrateDrupal6TestBase {
14
15
16

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

  /**
   * {@inheritdoc}
22
23
24
   */
  protected function setUp() {
    parent::setUp();
25
    $this->migrateFields();
26
27
28
29
30
31
  }

  /**
   * Tests the Drupal 6 upload settings to Drupal 8 field instance migration.
   */
  public function testUploadFieldInstance() {
32
    $field = FieldConfig::load('node.page.upload');
33
    $settings = $field->getSettings();
34
35
36
37
    $this->assertIdentical('node.page.upload', $field->id());
    $this->assertIdentical('jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp', $settings['file_extensions']);
    $this->assertIdentical('1MB', $settings['max_filesize']);
    $this->assertIdentical(TRUE, $settings['description_field']);
38

39
    $field = FieldConfig::load('node.story.upload');
40
    $this->assertIdentical('node.story.upload', $field->id());
41
42

    // Shouldn't exist.
43
    $field = FieldConfig::load('node.article.upload');
44
45
    $this->assertTrue(is_null($field));

46
    $this->assertIdentical(['node', 'page', 'upload'], $this->getMigration('d6_upload_field_instance')->getIdMap()->lookupDestinationId(['page']));
47
48
49
  }

}