You are here

public function WebformElementFieldsetTest::testFieldset in Webform 6.x

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

Test fieldset element.

File

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

Class

WebformElementFieldsetTest
Tests for fieldset element.

Namespace

Drupal\Tests\webform\Functional\Element

Code

public function testFieldset() {
  $this
    ->drupalGet('/webform/test_element_fieldset');

  // Check fieldset with help, field prefix, field suffix, description,
  // and more. Also, check that invalid 'required' and 'aria-required'
  // attributes are removed.
  $this
    ->assertRaw('<fieldset class="webform-has-field-prefix webform-has-field-suffix required webform-element-help-container--title webform-element-help-container--title-after js-webform-type-fieldset webform-type-fieldset js-form-item form-item js-form-wrapper form-wrapper" data-drupal-selector="edit-fieldset" aria-describedby="edit-fieldset--description" id="edit-fieldset" aria-required="true">');
  $this
    ->assertRaw('<span class="fieldset-legend js-form-required form-required">fieldset<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="fieldset" data-webform-help="&lt;div class=&quot;webform-element-help--title&quot;&gt;fieldset&lt;/div&gt;&lt;div class=&quot;webform-element-help--content&quot;&gt;This is help text.&lt;/div&gt;"><span aria-hidden="true">?</span></span>');
  $this
    ->assertRaw('<span class="field-prefix">prefix</span>');
  $this
    ->assertRaw('<span class="field-suffix">suffix</span>');
  $this
    ->assertRaw('<div class="description">');
  if (floatval(\Drupal::VERSION) >= 9) {
    $this
      ->assertRaw('<div id="edit-fieldset--description" data-drupal-field-elements="description" class="webform-element-description">This is a description.</div>');
  }
  else {
    $this
      ->assertRaw('<div id="edit-fieldset--description" class="webform-element-description">This is a description.</div>');
  }
  $this
    ->assertRaw('<div id="edit-fieldset--more" class="js-webform-element-more webform-element-more">');

  // Check fieldset title_display: invisible.
  $this
    ->assertRaw('<span class="visually-hidden fieldset-legend">fieldset_title_invisible</span>');

  // Check fieldset title_display: none.
  $this
    ->assertRaw('<legend style="display:none">');
  $this
    ->assertRaw('<span class="fieldset-legend"></span>');

  // Check fieldset description_display: before.
  if (floatval(\Drupal::VERSION) >= 9) {
    $this
      ->assertRaw('<span class="field-prefix">prefix<div id="edit-fieldset-description-before--description" data-drupal-field-elements="description" class="webform-element-description">This is a description before.</div>');
  }
  else {
    $this
      ->assertRaw('<span class="field-prefix">prefix<div id="edit-fieldset-description-before--description" class="webform-element-description">This is a description before.</div>');
  }
}