public function RowPluginTest::drupalCreateComment

Helper function to create a random comment.

Parameters

array $settings: (optional) An associative array of settings for the comment, as used in entity_create().

Return value

\Drupal\comment\Plugin\Core\Entity\Comment Returns the created and saved comment.

1 call to RowPluginTest::drupalCreateComment()
RowPluginTest::setUp in drupal/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php
Sets up a Drupal site for running functional and integration tests.

File

drupal/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php, line 92
Contains \Drupal\node\Tests\Views\RowPluginTest.

Class

RowPluginTest
Tests the node row plugin.

Namespace

Drupal\node\Tests\Views

Code

public function drupalCreateComment(array $settings = array()) {
  $node = node_load($settings['nid']);
  $settings += array(
    'subject' => $this
      ->randomName(),
    'node_type' => "comment_node_{$node->bundle()}",
    'comment_body' => $this
      ->randomName(40),
  );
  $comment = entity_create('comment', $settings);
  $comment
    ->save();
  return $comment;
}