Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Migrate / d6 / MigrateCommentTest.php
index 2a13178f6774fb330fd796232df3de4b862fec80..06ca65582e532674ad47590707f1834ed3649d3e 100644 (file)
@@ -2,12 +2,15 @@
 
 namespace Drupal\Tests\comment\Kernel\Migrate\d6;
 
+use Drupal\comment\Entity\Comment;
 use Drupal\comment\Tests\CommentTestTrait;
 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
+use Drupal\node\NodeInterface;
 
 /**
- * Upgrade comments.
+ * Tests the migration of comments from Drupal 6.
  *
+ * @group comment
  * @group migrate_drupal_6
  */
 class MigrateCommentTest extends MigrateDrupal6TestBase {
@@ -46,32 +49,41 @@ class MigrateCommentTest extends MigrateDrupal6TestBase {
   }
 
   /**
-   * Tests the Drupal 6 to Drupal 8 comment migration.
+   * Tests the migrated comments.
    */
-  public function testComments() {
-    /** @var \Drupal\Core\Entity\EntityStorageInterface $comment_storage */
-    $comment_storage = $this->container->get('entity.manager')->getStorage('comment');
-    /** @var \Drupal\comment\CommentInterface $comment */
-    $comment = $comment_storage->load(1);
-    $this->assertIdentical('The first comment.', $comment->getSubject());
-    $this->assertIdentical('The first comment body.', $comment->comment_body->value);
-    $this->assertIdentical('filtered_html', $comment->comment_body->format);
-    $this->assertIdentical(NULL, $comment->pid->target_id);
-    $this->assertIdentical('1', $comment->getCommentedEntityId());
-    $this->assertIdentical('node', $comment->getCommentedEntityTypeId());
-    $this->assertIdentical('en', $comment->language()->getId());
-    $this->assertIdentical('comment_no_subject', $comment->getTypeId());
-    $this->assertEquals('203.0.113.1', $comment->getHostname());
-
-    $comment = $comment_storage->load(2);
-    $this->assertIdentical('The response to the second comment.', $comment->subject->value);
-    $this->assertIdentical('3', $comment->pid->target_id);
-    $this->assertEquals('203.0.113.2', $comment->getHostname());
-
-    $comment = $comment_storage->load(3);
-    $this->assertIdentical('The second comment.', $comment->subject->value);
-    $this->assertIdentical(NULL, $comment->pid->target_id);
-    $this->assertEquals('203.0.113.3', $comment->getHostname());
+  public function testMigration() {
+    $comment = Comment::load(1);
+    $this->assertSame('The first comment.', $comment->getSubject());
+    $this->assertSame('The first comment body.', $comment->comment_body->value);
+    $this->assertSame('filtered_html', $comment->comment_body->format);
+    $this->assertSame(NULL, $comment->pid->target_id);
+    $this->assertSame('1', $comment->getCommentedEntityId());
+    $this->assertSame('node', $comment->getCommentedEntityTypeId());
+    $this->assertSame('en', $comment->language()->getId());
+    $this->assertSame('comment_node_story', $comment->getTypeId());
+    $this->assertSame('203.0.113.1', $comment->getHostname());
+
+    $node = $comment->getCommentedEntity();
+    $this->assertInstanceOf(NodeInterface::class, $node);
+    $this->assertSame('1', $node->id());
+
+    $comment = Comment::load(2);
+    $this->assertSame('The response to the second comment.', $comment->subject->value);
+    $this->assertSame('3', $comment->pid->target_id);
+    $this->assertSame('203.0.113.2', $comment->getHostname());
+
+    $node = $comment->getCommentedEntity();
+    $this->assertInstanceOf(NodeInterface::class, $node);
+    $this->assertSame('1', $node->id());
+
+    $comment = Comment::load(3);
+    $this->assertSame('The second comment.', $comment->subject->value);
+    $this->assertSame(NULL, $comment->pid->target_id);
+    $this->assertSame('203.0.113.3', $comment->getHostname());
+
+    $node = $comment->getCommentedEntity();
+    $this->assertInstanceOf(NodeInterface::class, $node);
+    $this->assertSame('1', $node->id());
   }
 
 }