MigrateVocabularyEntityDisplayTest.php in Drupal 10
File
core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php
View source
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
protected static $modules = [
'field',
'taxonomy',
'menu_ui',
];
protected function setUp() : void {
parent::setUp();
$this
->migrateContentTypes();
$this
->installEntitySchema('taxonomy_term');
$this
->executeMigrations([
'd6_node_type',
'd6_taxonomy_vocabulary',
'd6_vocabulary_field',
'd6_vocabulary_field_instance',
]);
}
public function testVocabularyEntityDisplay() {
$this
->executeMigration('d6_vocabulary_entity_display');
$component = EntityViewDisplay::load('node.page.default')
->getComponent('field_tags');
$this
->assertSame('entity_reference_label', $component['type']);
$this
->assertSame(20, $component['weight']);
$this
->assertSame([
[
'node',
'article',
'default',
'field_tags',
],
], $this
->getMigration('d6_vocabulary_entity_display')
->getIdMap()
->lookupDestinationIds([
4,
'article',
]));
$field_type = EntityViewDisplay::load('node.sponsor.default')
->getComponent('field_type');
$this
->assertIsArray($field_type);
}
public function testSkipNonExistentNodeType() {
$this
->mockFailure('d6_node_type', [
'type' => 'story',
]);
$migration = $this
->getMigration('d6_vocabulary_entity_display');
$this
->executeMigration($migration);
$this
->assertNull($migration
->getIdMap()
->lookupDestinationIds([
'type' => 'story',
])[0][0]);
}
}