You are here

public function HoneypotFormTest::testProtectCommentFormNormal in Honeypot 2.0.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/HoneypotFormTest.php \Drupal\Tests\honeypot\Functional\HoneypotFormTest::testProtectCommentFormNormal()

Test comment form protection.

File

tests/src/Functional/HoneypotFormTest.php, line 194

Class

HoneypotFormTest
Test Honeypot spam protection functionality.

Namespace

Drupal\Tests\honeypot\Functional

Code

public function testProtectCommentFormNormal() {
  $comment = 'Test comment.';

  // Disable time limit for honeypot.
  \Drupal::configFactory()
    ->getEditable('honeypot.settings')
    ->set('time_limit', 0)
    ->save();

  // Log in the web user.
  $this
    ->drupalLogin($this->webUser);

  // Set up form and submit it.
  $edit["comment_body[0][value]"] = $comment;
  $this
    ->drupalPostForm('comment/reply/node/' . $this->node
    ->id() . '/comment', $edit, $this
    ->t('Save'));
  $this
    ->assertSession()
    ->pageTextContains('Your comment has been queued for review');
}