account = $this->drupalCreateUser(['skip comment approval']); $this->account2 = $this->drupalCreateUser(); $this->drupalLogin($this->account); $this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]); $this->addDefaultCommentField('node', 'page'); $this->nodeUserPosted = $this->drupalCreateNode(); $this->nodeUserCommented = $this->drupalCreateNode(['uid' => $this->account2->id()]); $comment = [ 'uid' => $this->loggedInUser->id(), 'entity_id' => $this->nodeUserCommented->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'subject' => 'How much wood would a woodchuck chuck', 'cid' => '', 'pid' => '', 'mail' => 'someone@example.com', ]; $this->comment = Comment::create($comment); $this->comment->save(); } }