You are here

public function HoneypotFormTest::testProtectCommentFormHoneypotFilled in Honeypot 8

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

Test for comment form honeypot filled.

File

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

Class

HoneypotFormTest
Test Honeypot spam protection functionality.

Namespace

Drupal\Tests\honeypot\Functional

Code

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

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

  // Set up form and submit it.
  $edit["comment_body[0][value]"] = $comment;
  $edit['url'] = 'http://www.example.com/';
  $this
    ->drupalPostForm('comment/reply/node/' . $this->node
    ->id() . '/comment', $edit, $this
    ->t('Save'));
  $this
    ->assertSession()
    ->pageTextContains('There was a problem with your form submission. Please refresh the page and try again.');
}