function 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.

3 calls to CommentAttributesTest::saveComment()
CommentAttributesTest::testCommentRdfaMarkup in drupal/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php
Tests if RDFa markup for meta information is present in comments.
CommentAttributesTest::testCommentReplyOfRdfaMarkup in drupal/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php
Tests RDF comment replies.
CommentAttributesTest::testNumberOfCommentsRdfaMarkup in drupal/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php
Tests the presence of the RDFa markup for the number of comments.

File

drupal/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php, line 278
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(
    'nid' => $nid,
    'uid' => $uid,
    'pid' => $pid,
    'node_type' => 'comment_node_article',
    'subject' => $this
      ->randomName(),
    'comment_body' => $this
      ->randomName(),
    'status' => 1,
  );
  if ($contact) {
    $values += $contact;
  }
  $comment = entity_create('comment', $values);
  $comment
    ->save();
  return $comment;
}