You are here

public function EntityCloneCommentTest::testCommentEntityClone in Entity Clone 8

Test comment entity clone.

File

tests/src/Functional/EntityCloneCommentTest.php, line 71

Class

EntityCloneCommentTest
Create a comment and test a clone.

Namespace

Drupal\Tests\entity_clone\Functional

Code

public function testCommentEntityClone() {
  $subject = 'Test comment for clone';
  $body = $this
    ->randomMachineName();
  $comment = $this
    ->postComment($this->node, $body, $subject, TRUE);
  $this
    ->drupalPostForm('entity_clone/comment/' . $comment
    ->id(), [], t('Clone'));
  $comments = \Drupal::entityTypeManager()
    ->getStorage('comment')
    ->loadByProperties([
    'subject' => $subject . ' - Cloned',
    'comment_body' => $body,
  ]);
  $comments = reset($comments);
  $this
    ->assertInstanceOf(Comment::class, $comments, 'Test comment cloned found in database.');
}