You are here

public function CommentNonNodeTest::performCommentOperation in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/comment/tests/src/Functional/CommentNonNodeTest.php \Drupal\Tests\comment\Functional\CommentNonNodeTest::performCommentOperation()

Performs the specified operation on the specified comment.

Parameters

object $comment: Comment to perform operation on.

string $operation: Operation to perform.

bool $approval: Operation is found on approval page.

1 call to CommentNonNodeTest::performCommentOperation()
CommentNonNodeTest::testCommentFunctionality in core/modules/comment/tests/src/Functional/CommentNonNodeTest.php
Tests anonymous comment functionality.

File

core/modules/comment/tests/src/Functional/CommentNonNodeTest.php, line 233

Class

CommentNonNodeTest
Tests commenting on a test entity.

Namespace

Drupal\Tests\comment\Functional

Code

public function performCommentOperation($comment, $operation, $approval = FALSE) {
  $edit = [];
  $edit['operation'] = $operation;
  $edit['comments[' . $comment
    ->id() . ']'] = TRUE;
  $this
    ->drupalPostForm('admin/content/comment' . ($approval ? '/approval' : ''), $edit, t('Update'));
  if ($operation == 'delete') {
    $this
      ->drupalPostForm(NULL, [], t('Delete'));
    $this
      ->assertRaw(\Drupal::translation()
      ->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), new FormattableMarkup('Operation "@operation" was performed on comment.', [
      '@operation' => $operation,
    ]));
  }
  else {
    $this
      ->assertText(t('The update has been performed.'), new FormattableMarkup('Operation "@operation" was performed on comment.', [
      '@operation' => $operation,
    ]));
  }
}