You are here

public function HoneypotFormTestCase::testStrictEmptinessOnHoneypotField in Honeypot 7

Test that any (not-strict-empty) value triggers protection.

File

./honeypot.test, line 199
Testing for Honeypot module.

Class

HoneypotFormTestCase
Test the functionality of the Honeypot module for forms.

Code

public function testStrictEmptinessOnHoneypotField() {

  // Initialise the form values.
  $edit['name'] = $this
    ->randomName();
  $edit['mail'] = $edit['name'] . '@example.com';

  // Any value that is not strictly empty should trigger Honeypot.
  foreach ([
    '0',
    ' ',
  ] as $value) {
    $edit['url'] = $value;
    $this
      ->drupalPost('user/register', $edit, t('Create new account'));
    $this
      ->assertText(t('There was a problem with your form submission. Please refresh the page and try again.'), "Honeypot protection is triggered when the honeypot field contains '{$value}'.");
  }
}