MigrateForumTest.php in Drupal 10
File
core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumTest.php
View source
<?php
namespace Drupal\Tests\forum\Kernel\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\node\Entity\Node;
use Drupal\Tests\node\Kernel\Migrate\d6\MigrateNodeTestBase;
class MigrateForumTest extends MigrateNodeTestBase {
protected static $modules = [
'comment',
'forum',
'menu_ui',
'taxonomy',
];
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('comment');
$this
->installSchema('comment', [
'comment_entity_statistics',
]);
$this
->installSchema('forum', [
'forum',
'forum_index',
]);
$this
->installConfig([
'comment',
'forum',
]);
$this
->migrateContent();
$this
->migrateTaxonomy();
$this
->executeMigrations([
'd6_comment_type',
'd6_comment_field',
'd6_comment_field_instance',
'd6_comment_entity_display',
'd6_comment_entity_form_display',
'd6_comment',
'd6_term_node',
]);
}
public function testForumMigration() {
$field_storage_config = FieldStorageConfig::load('node.taxonomy_forums');
$this
->assertInstanceOf(FieldStorageConfig::class, $field_storage_config);
$field_config = FieldConfig::load('node.forum.taxonomy_forums');
$this
->assertInstanceOf(FieldConfig::class, $field_config);
$entity_view_display = EntityViewDisplay::load('node.forum.default')
->getComponent('taxonomy_forums');
$this
->assertIsArray($entity_view_display);
$entity_form_display = EntityFormDisplay::load('node.forum.default')
->getComponent('taxonomy_forums');
$this
->assertIsArray($entity_form_display);
$node = Node::load(19);
$this
->assertEquals(8, $node->taxonomy_forums->target_id);
}
}