1 comment.test public CommentFieldsTest::testCommentEmptyNonRequiredBody()

Tests trying to save a comment with an empty, NON-required body.

Trying to save should succeed and not generate a warning.

File

core/modules/comment/tests/comment.test, line 2045
Tests for the Comment module.

Class

CommentFieldsTest
Tests fields on comments.

Code

public function testCommentEmptyNonRequiredBody() {
  // Set the requirement-indicator of the comment_body field.
  $this->backdropLogin($this->admin_user);
  $edit = array('instance[required]' => FALSE);
  $this->backdropPost('admin/structure/types/manage/post/comment/fields/comment_body', $edit, t('Save settings'));

  // Preview an empty comment, and check if an error is shown.
  $this->backdropPost('node/' . $this->node->nid, array(), t('Preview'));
  $this->assertNoText('Comment field is required.', 'Can preview comment with empty required body.');

  // Post an empty comment, and check if an error is shown.
  $this->backdropPost('node/' . $this->node->nid, array(), t('Save'));
  $this->assertNoText('Comment field is required.', 'Can save comment with empty required body.');
  $this->assertText('Your comment has been posted.', 'Can save comment with empty required body.');
}