MigrateUploadInstanceTest.php

Same filename in other branches
  1. 9 core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadInstanceTest.php
  2. 8.9.x core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadInstanceTest.php
  3. 11.x core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadInstanceTest.php

Namespace

Drupal\Tests\file\Kernel\Migrate\d6

File

core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadInstanceTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\file\Kernel\Migrate\d6;

use Drupal\field\Entity\FieldConfig;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;

/**
 * Upload field instance migration.
 *
 * @group migrate_drupal_6
 */
class MigrateUploadInstanceTest extends MigrateDrupal6TestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'menu_ui',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() : void {
        parent::setUp();
        $this->migrateFields();
    }
    
    /**
     * Tests the Drupal 6 upload settings to Drupal 8 field instance migration.
     */
    public function testUploadFieldInstance() : void {
        $field = FieldConfig::load('node.page.upload');
        $settings = $field->getSettings();
        $this->assertSame('node.page.upload', $field->id());
        $this->assertSame('jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp', $settings['file_extensions']);
        $this->assertSame('1MB', $settings['max_filesize']);
        $this->assertTrue($settings['description_field']);
        $field = FieldConfig::load('node.story.upload');
        $this->assertSame('node.story.upload', $field->id());
        // Shouldn't exist.
        $field = FieldConfig::load('node.article.upload');
        $this->assertNull($field);
        $this->assertSame([
            [
                'node',
                'page',
                'upload',
            ],
        ], $this->getMigration('d6_upload_field_instance')
            ->getIdMap()
            ->lookupDestinationIds([
            'page',
        ]));
    }

}

Classes

Title Deprecated Summary
MigrateUploadInstanceTest Upload field instance migration.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.