3 namespace Drupal\Tests\comment\Kernel\Migrate\d7;
5 use Drupal\comment\Entity\Comment;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
7 use Drupal\node\NodeInterface;
10 * Tests the migration of comments from Drupal 7.
13 * @group migrate_drupal_7
15 class MigrateCommentTest extends MigrateDrupal7TestBase {
20 public static $modules = ['filter', 'node', 'comment', 'text', 'menu_ui'];
25 protected function setUp() {
28 $this->installEntitySchema('node');
29 $this->installEntitySchema('comment');
30 $this->installConfig(['comment', 'node']);
31 $this->installSchema('comment', ['comment_entity_statistics']);
33 $this->executeMigrations([
40 'd7_comment_field_instance',
41 'd7_comment_entity_display',
42 'd7_comment_entity_form_display',
48 * Tests the migrated comments.
50 public function testMigration() {
51 $comment = Comment::load(1);
52 $this->assertInstanceOf(Comment::class, $comment);
53 $this->assertSame('A comment', $comment->getSubject());
54 $this->assertSame('1421727536', $comment->getCreatedTime());
55 $this->assertSame('1421727536', $comment->getChangedTime());
56 $this->assertTrue($comment->getStatus());
57 $this->assertSame('admin', $comment->getAuthorName());
58 $this->assertSame('admin@local.host', $comment->getAuthorEmail());
59 $this->assertSame('This is a comment', $comment->comment_body->value);
60 $this->assertSame('filtered_html', $comment->comment_body->format);
61 $this->assertSame('2001:db8:ffff:ffff:ffff:ffff:ffff:ffff', $comment->getHostname());
63 $node = $comment->getCommentedEntity();
64 $this->assertInstanceOf(NodeInterface::class, $node);
65 $this->assertSame('1', $node->id());