3 namespace Drupal\Tests\comment\Kernel\Migrate\d6;
5 use Drupal\comment\Tests\CommentTestTrait;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
11 * @group migrate_drupal_6
13 class MigrateCommentTest extends MigrateDrupal6TestBase {
20 public static $modules = ['comment', 'menu_ui'];
25 protected function setUp() {
28 $this->installEntitySchema('node');
29 $this->installEntitySchema('comment');
30 $this->installSchema('comment', ['comment_entity_statistics']);
31 $this->installConfig(['comment']);
33 // The entity.node.canonical route must exist when the RDF hook is called.
34 $this->container->get('router.builder')->rebuild();
36 $this->migrateContent();
37 $this->executeMigrations([
41 'd6_comment_field_instance',
42 'd6_comment_entity_display',
43 'd6_comment_entity_form_display',
49 * Tests the Drupal 6 to Drupal 8 comment migration.
51 public function testComments() {
52 /** @var \Drupal\Core\Entity\EntityStorageInterface $comment_storage */
53 $comment_storage = $this->container->get('entity.manager')->getStorage('comment');
54 /** @var \Drupal\comment\CommentInterface $comment */
55 $comment = $comment_storage->load(1);
56 $this->assertIdentical('The first comment.', $comment->getSubject());
57 $this->assertIdentical('The first comment body.', $comment->comment_body->value);
58 $this->assertIdentical('filtered_html', $comment->comment_body->format);
59 $this->assertIdentical(NULL, $comment->pid->target_id);
60 $this->assertIdentical('1', $comment->getCommentedEntityId());
61 $this->assertIdentical('node', $comment->getCommentedEntityTypeId());
62 $this->assertIdentical('en', $comment->language()->getId());
63 $this->assertIdentical('comment_no_subject', $comment->getTypeId());
64 $this->assertEquals('203.0.113.1', $comment->getHostname());
66 $comment = $comment_storage->load(2);
67 $this->assertIdentical('The response to the second comment.', $comment->subject->value);
68 $this->assertIdentical('3', $comment->pid->target_id);
69 $this->assertEquals('203.0.113.2', $comment->getHostname());
71 $comment = $comment_storage->load(3);
72 $this->assertIdentical('The second comment.', $comment->subject->value);
73 $this->assertIdentical(NULL, $comment->pid->target_id);
74 $this->assertEquals('203.0.113.3', $comment->getHostname());