95717ed352d005cfc12620c4abd569342eb1f389
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Migrate / d7 / MigrateCommentTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Kernel\Migrate\d7;
4
5 use Drupal\comment\Entity\Comment;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
7 use Drupal\node\NodeInterface;
8
9 /**
10  * Tests the migration of comments from Drupal 7.
11  *
12  * @group comment
13  * @group migrate_drupal_7
14  */
15 class MigrateCommentTest extends MigrateDrupal7TestBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   public static $modules = ['filter', 'node', 'comment', 'text', 'menu_ui'];
21
22   /**
23    * {@inheritdoc}
24    */
25   protected function setUp() {
26     parent::setUp();
27
28     $this->installEntitySchema('node');
29     $this->installEntitySchema('comment');
30     $this->installConfig(['comment', 'node']);
31     $this->installSchema('comment', ['comment_entity_statistics']);
32
33     $this->executeMigrations([
34       'd7_user_role',
35       'd7_user',
36       'd7_node_type',
37       'd7_node',
38       'd7_comment_type',
39       'd7_comment_field',
40       'd7_comment_field_instance',
41       'd7_comment_entity_display',
42       'd7_comment_entity_form_display',
43       'd7_comment',
44     ]);
45   }
46
47   /**
48    * Tests the migrated comments.
49    */
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());
62
63     $node = $comment->getCommentedEntity();
64     $this->assertInstanceOf(NodeInterface::class, $node);
65     $this->assertSame('1', $node->id());
66   }
67
68 }