WebformElementSectionTest.php in Webform 6.x
File
tests/src/Functional/Element/WebformElementSectionTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Element;
class WebformElementSectionTest extends WebformElementBrowserTestBase {
protected static $testWebforms = [
'test_element_section',
];
public function testSection() {
$this
->drupalGet('/webform/test_element_section');
$this
->assertRaw('<section data-drupal-selector="edit-webform-section" aria-describedby="edit-webform-section--description" id="edit-webform-section" class="required webform-element-help-container--title webform-element-help-container--title-after js-form-item form-item js-form-wrapper form-wrapper webform-section" required="required" aria-required="true">');
$this
->assertRaw('<h2 class="webform-section-title js-form-required form-required">webform_section<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="webform_section" data-webform-help="<div class="webform-element-help--title">webform_section</div><div class="webform-element-help--content">This is help text.</div>"><span aria-hidden="true">?</span></span>');
$this
->assertRaw('<div class="description"><div id="edit-webform-section--description" class="webform-element-description">This is a description.</div>');
$this
->assertRaw('<div id="edit-webform-section--more" class="js-webform-element-more webform-element-more">');
$this
->assertRaw('<section data-drupal-selector="edit-webform-section-title-custom" id="edit-webform-section-title-custom" class="js-form-item form-item js-form-wrapper form-wrapper webform-section">');
$this
->assertRaw('<h5 style="color: red" class="webform-section-title">webform_section_title_custom</h5>');
$this
->assertRaw('<h2 class="visually-hidden webform-section-title">webform_section_title_invisible</h2>');
$this
->assertPattern('/Display default description.+name="webform_section_description_display_default_textfield"/ms');
$this
->assertPattern('/Display before description.+name="webform_section_description_display_before_textfield"/ms');
$this
->assertPattern('/name="webform_section_description_display_after_textfield".+Display after description/ms');
$this
->assertRaw('<div class="description"><div id="edit-webform-section-description-display-invisible--description" class="webform-element-description visually-hidden">Display invisible description.</div>');
\Drupal::configFactory()
->getEditable('webform.settings')
->set('element.default_section_title_tag', 'address')
->save();
$this
->drupalGet('/webform/test_element_section');
$this
->assertNoRaw('<h2 class="webform-section-title js-form-required form-required">');
$this
->assertRaw('<address class="webform-section-title js-form-required form-required">');
}
}