Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Migrate / d6 / MigrateCommentTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Kernel\Migrate\d6;
4
5 use Drupal\comment\Entity\Comment;
6 use Drupal\comment\Tests\CommentTestTrait;
7 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
8 use Drupal\node\NodeInterface;
9
10 /**
11  * Tests the migration of comments from Drupal 6.
12  *
13  * @group comment
14  * @group migrate_drupal_6
15  */
16 class MigrateCommentTest extends MigrateDrupal6TestBase {
17
18   use CommentTestTrait;
19
20   /**
21    * {@inheritdoc}
22    */
23   public static $modules = ['comment', 'menu_ui'];
24
25   /**
26    * {@inheritdoc}
27    */
28   protected function setUp() {
29     parent::setUp();
30
31     $this->installEntitySchema('node');
32     $this->installEntitySchema('comment');
33     $this->installSchema('comment', ['comment_entity_statistics']);
34     $this->installConfig(['comment']);
35
36     // The entity.node.canonical route must exist when the RDF hook is called.
37     $this->container->get('router.builder')->rebuild();
38
39     $this->migrateContent();
40     $this->executeMigrations([
41       'd6_node',
42       'd6_comment_type',
43       'd6_comment_field',
44       'd6_comment_field_instance',
45       'd6_comment_entity_display',
46       'd6_comment_entity_form_display',
47       'd6_comment',
48     ]);
49   }
50
51   /**
52    * Tests the migrated comments.
53    */
54   public function testMigration() {
55     $comment = Comment::load(1);
56     $this->assertSame('The first comment.', $comment->getSubject());
57     $this->assertSame('The first comment body.', $comment->comment_body->value);
58     $this->assertSame('filtered_html', $comment->comment_body->format);
59     $this->assertSame(NULL, $comment->pid->target_id);
60     $this->assertSame('1', $comment->getCommentedEntityId());
61     $this->assertSame('node', $comment->getCommentedEntityTypeId());
62     $this->assertSame('en', $comment->language()->getId());
63     $this->assertSame('comment_node_story', $comment->getTypeId());
64     $this->assertSame('203.0.113.1', $comment->getHostname());
65
66     $node = $comment->getCommentedEntity();
67     $this->assertInstanceOf(NodeInterface::class, $node);
68     $this->assertSame('1', $node->id());
69
70     $comment = Comment::load(2);
71     $this->assertSame('The response to the second comment.', $comment->subject->value);
72     $this->assertSame('3', $comment->pid->target_id);
73     $this->assertSame('203.0.113.2', $comment->getHostname());
74
75     $node = $comment->getCommentedEntity();
76     $this->assertInstanceOf(NodeInterface::class, $node);
77     $this->assertSame('1', $node->id());
78
79     $comment = Comment::load(3);
80     $this->assertSame('The second comment.', $comment->subject->value);
81     $this->assertSame(NULL, $comment->pid->target_id);
82     $this->assertSame('203.0.113.3', $comment->getHostname());
83
84     $node = $comment->getCommentedEntity();
85     $this->assertInstanceOf(NodeInterface::class, $node);
86     $this->assertSame('1', $node->id());
87   }
88
89 }