You are here

protected function StandardProfileTest::saveComment in Zircon Profile 8

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

Creates a comment entity.

Parameters

int $nid: Node id which will hold the comment.

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

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

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

Return value

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

1 call to StandardProfileTest::saveComment()
StandardProfileTest::setUp in core/modules/rdf/src/Tests/StandardProfileTest.php
Sets up a Drupal site for running functional and integration tests.

File

core/modules/rdf/src/Tests/StandardProfileTest.php, line 503
Contains \Drupal\rdf\Tests\StandardProfileTest.

Class

StandardProfileTest
Tests the RDF mappings and RDFa markup of the standard profile.

Namespace

Drupal\rdf\Tests

Code

protected 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;
}