You are here

public function HoneypotAdminFormTest::testElementNameUpdateInvalidCharacterFail in Honeypot 8

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

Test an invalid element name (invalid character in name).

File

tests/src/Functional/HoneypotAdminFormTest.php, line 92

Class

HoneypotAdminFormTest
Test Honeypot spam protection admin form functionality.

Namespace

Drupal\Tests\honeypot\Functional

Code

public function testElementNameUpdateInvalidCharacterFail() {

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

  // Set up form and submit it.
  $edit['element_name'] = "special-character-&";
  $this
    ->drupalPostForm('admin/config/content/honeypot', $edit, $this
    ->t('Save configuration'));

  // Form submission should fail.
  $this
    ->assertSession()
    ->pageTextContains('The element name cannot contain spaces or other special characters.');

  // Set up form and submit it.
  $edit['element_name'] = "space in name";
  $this
    ->drupalPostForm('admin/config/content/honeypot', $edit, $this
    ->t('Save configuration'));

  // Form submission should fail.
  $this
    ->assertSession()
    ->pageTextContains('The element name cannot contain spaces or other special characters.');
}