function CommentTestBase::setCommentPreview

Same name in this branch
  1. 8.9.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentPreview()
Same name in other branches
  1. 9 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentPreview()
  2. 10 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentPreview()
  3. 11.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentPreview()

Sets the value governing the previewing mode for the comment form.

Parameters

int $mode: The preview mode: DRUPAL_DISABLED, DRUPAL_OPTIONAL or DRUPAL_REQUIRED.

string $field_name: (optional) Field name through which the comment should be posted. Defaults to 'comment'.

File

core/modules/comment/src/Tests/CommentTestBase.php, line 269

Class

CommentTestBase
Provides setup and helper methods for comment tests.

Namespace

Drupal\comment\Tests

Code

public function setCommentPreview($mode, $field_name = 'comment') {
    switch ($mode) {
        case DRUPAL_DISABLED:
            $mode_text = 'disabled';
            break;
        case DRUPAL_OPTIONAL:
            $mode_text = 'optional';
            break;
        case DRUPAL_REQUIRED:
            $mode_text = 'required';
            break;
    }
    $this->setCommentSettings('preview', $mode, new FormattableMarkup('Comment preview @mode_text.', [
        '@mode_text' => $mode_text,
    ]), $field_name);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.