MigrateUploadEntityDisplayTest.php in Drupal 10
File
core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php
View source
<?php
namespace Drupal\Tests\file\Kernel\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
class MigrateUploadEntityDisplayTest extends MigrateDrupal6TestBase {
protected static $modules = [
'menu_ui',
];
protected function setUp() : void {
parent::setUp();
$this
->migrateFields();
}
public function testUploadEntityDisplay() {
$this
->executeMigration('d6_upload_entity_display');
$display = EntityViewDisplay::load('node.page.default');
$component = $display
->getComponent('upload');
$this
->assertSame('file_default', $component['type']);
$display = EntityViewDisplay::load('node.story.default');
$component = $display
->getComponent('upload');
$this
->assertSame('file_default', $component['type']);
$display = EntityViewDisplay::load('node.article.default');
$component = $display
->getComponent('upload');
$this
->assertNull($component);
$this
->assertSame([
[
'node',
'page',
'default',
'upload',
],
], $this
->getMigration('d6_upload_entity_display')
->getIdMap()
->lookupDestinationIds([
'page',
]));
}
public function testSkipNonExistentNodeType() {
$this
->mockFailure('d6_node_type', [
'type' => 'story',
]);
$migration = $this
->getMigration('d6_upload_entity_display');
$this
->executeMigration($migration);
$this
->assertNull($migration
->getIdMap()
->lookupDestinationIds([
'node_type' => 'story',
])[0][0]);
}
}