You are here

public function HoneypotFormTest::testProtectNodeFormTooFast in Honeypot 8

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

Test node form protection.

File

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

Class

HoneypotFormTest
Test Honeypot spam protection functionality.

Namespace

Drupal\Tests\honeypot\Functional

Code

public function testProtectNodeFormTooFast() {

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

  // Reset the time limit to 5 seconds.
  \Drupal::configFactory()
    ->getEditable('honeypot.settings')
    ->set('time_limit', 5)
    ->save();

  // Set up the form and submit it.
  $edit["title[0][value]"] = 'Test Page';
  $this
    ->drupalPostForm('node/add/article', $edit, $this
    ->t('Save'));
  $this
    ->assertSession()
    ->pageTextContains('There was a problem with your form submission.');
}