You are here

function CommentAttributesTest::saveComment in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/rdf/src/Tests/CommentAttributesTest.php \Drupal\rdf\Tests\CommentAttributesTest::saveComment()

Creates a comment entity.

Parameters

$nid: Node id which will hold the comment.

$uid: User id of the author of the comment. Can be NULL if $contact provided.

$contact: Set to NULL for no contact info, TRUE to ignore success checking, and array of values to set contact info.

$pid: Comment id of the parent comment in a thread.

Return value

\Drupal\comment\Entity\Comment The saved comment.

4 calls to CommentAttributesTest::saveComment()
CommentAttributesTest::testCommentRdfaMarkup in core/modules/rdf/src/Tests/CommentAttributesTest.php
Tests if RDFa markup for meta information is present in comments.
CommentAttributesTest::testCommentRdfAuthorMarkup in core/modules/rdf/src/Tests/CommentAttributesTest.php
Tests comment author link markup has not been broken by RDF.
CommentAttributesTest::testCommentReplyOfRdfaMarkup in core/modules/rdf/src/Tests/CommentAttributesTest.php
Tests RDF comment replies.
CommentAttributesTest::testNumberOfCommentsRdfaMarkup in core/modules/rdf/src/Tests/CommentAttributesTest.php
Tests the presence of the RDFa markup for the number of comments.

File

core/modules/rdf/src/Tests/CommentAttributesTest.php, line 360
Contains \Drupal\rdf\Tests\CommentAttributesTest.

Class

CommentAttributesTest
Tests the RDFa markup of comments.

Namespace

Drupal\rdf\Tests

Code

function saveComment($nid, $uid, $contact = NULL, $pid = 0) {
  $values = array(
    'entity_id' => $nid,
    'entity_type' => 'node',
    'field_name' => 'comment',
    'uid' => $uid,
    'pid' => $pid,
    'subject' => $this
      ->randomMachineName(),
    'comment_body' => $this
      ->randomMachineName(),
    'status' => 1,
  );
  if ($contact) {
    $values += $contact;
  }
  $comment = entity_create('comment', $values);
  $comment
    ->save();
  return $comment;
}