You are here

public function WebformElementValidateRequiredTest::testPattern in Webform 6.x

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/Element/WebformElementValidateRequiredTest.php \Drupal\Tests\webform\Functional\Element\WebformElementValidateRequiredTest::testPattern()

Tests pattern validation.

File

tests/src/Functional/Element/WebformElementValidateRequiredTest.php, line 22

Class

WebformElementValidateRequiredTest
Tests for webform required validation.

Namespace

Drupal\Tests\webform\Functional\Element

Code

public function testPattern() {

  // Check that HTML tags are stripped  from required error attribute.
  $this
    ->drupalGet('/webform/test_element_validate_required');
  $this
    ->assertRaw(' <input data-webform-required-error="This is a custom required message" data-drupal-selector="edit-required-textfield-html" type="text" id="edit-required-textfield-html" name="required_textfield_html" value="" size="60" maxlength="255" class="form-text required" required="required" aria-required="true" />');

  // Check that HTML tags are rendered in validation message.
  $this
    ->drupalPostForm('/webform/test_element_validate_required', [], 'Submit');
  $this
    ->assertRaw('<li>This is a <em>custom required message</em></li>');
}