public function WebformElementHelpTest::testHelp in Webform 8.5
Same name and namespace in other branches
- 6.x tests/src/Functional/Element/WebformElementHelpTest.php \Drupal\Tests\webform\Functional\Element\WebformElementHelpTest::testHelp()
Test element help.
File
- tests/
src/ Functional/ Element/ WebformElementHelpTest.php, line 22
Class
- WebformElementHelpTest
- Tests for element help.
Namespace
Drupal\Tests\webform\Functional\ElementCode
public function testHelp() {
$this
->drupalGet('/webform/test_element_help');
// Check basic help.
$this
->assertRaw('<label for="edit-help">help<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help" data-webform-help="<div class="webform-element-help--title">help</div><div class="webform-element-help--content">{This is an example of help}</div>"><span aria-hidden="true">?</span></span>');
// Check help with required.
$this
->assertRaw('<label for="edit-help-required" class="js-form-required form-required">help_required<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_required" data-webform-help="<div class="webform-element-help--title">help_required</div><div class="webform-element-help--content">{This is an example of help for a required element}</div>"><span aria-hidden="true">?</span></span>');
// Check help with custom title.
$this
->assertRaw('<label for="edit-help-title">help_title<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="{Help custom title}" data-webform-help="<div class="webform-element-help--title">{Help custom title}</div><div class="webform-element-help--content">{This is an example of help with a custom help title}</div>"><span aria-hidden="true">?</span></span>');
// Check help with HTML markup.
$this
->assertRaw('<label for="edit-help-html">help_html<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_html" data-webform-help="<div class="webform-element-help--title">help_html</div><div class="webform-element-help--content">{This is an example of help with <b>HTML markup</b>}</div>"><span aria-hidden="true">?</span></span>');
// Check help with XSS.
$this
->assertRaw('<label for="edit-help-xss">help_xss<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_xss" data-webform-help="<div class="webform-element-help--title">help_xss</div><div class="webform-element-help--content">{This is an example of help with <b>XSS alert("XSS")</b>}</div>"><span aria-hidden="true">?</span></span>');
// Check help empty.
$this
->assertRaw('<label for="edit-help-empty">help_empty</label>');
// Check help with inline title.
$this
->assertRaw('<label for="edit-help-checkbox" class="option">help_checkbox<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_checkbox" data-webform-help="<div class="webform-element-help--title">help_checkbox</div><div class="webform-element-help--content">{This is an example of help}</div>"><span aria-hidden="true">?</span></span>');
$this
->assertRaw('<label for="edit-help-inline"><span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_inline" data-webform-help="<div class="webform-element-help--title">help_inline</div><div class="webform-element-help--content">{This is an example of help with an inline title}</div>"><span aria-hidden="true">?</span></span>');
// Check radios (fieldset).
$this
->assertRaw('<span class="fieldset-legend">help_radios<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_radios" data-webform-help="<div class="webform-element-help--title">help_radios</div><div class="webform-element-help--content">{This is an example of help for radio buttons}</div>"><span aria-hidden="true">?</span></span>');
// Check fieldset.
$this
->assertRaw('<span class="fieldset-legend">help_radios<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_radios" data-webform-help="<div class="webform-element-help--title">help_radios</div><div class="webform-element-help--content">{This is an example of help for radio buttons}</div>"><span aria-hidden="true">?</span></span>');
// Check details.
$this
->assertRaw('<summary role="button" aria-controls="edit-help-details" aria-expanded="false" aria-pressed="false">help_details<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_details" data-webform-help="<div class="webform-element-help--title">help_details</div><div class="webform-element-help--content">{This is an example of help for a details element}</div>"><span aria-hidden="true">?</span>');
// Check section.
$this
->assertRaw('<h2 class="webform-section-title">help_section<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_section" data-webform-help="<div class="webform-element-help--title">help_section</div><div class="webform-element-help--content">{This is an example of help for a section element}</div>"><span aria-hidden="true">?</span></span>');
// Check help display title after.
$this
->assertRaw('<label for="edit-help-after-title">help_after_title<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_after_title" data-webform-help="<div class="webform-element-help--title">help_after_title</div><div class="webform-element-help--content">{This is an example of help}</div>"><span aria-hidden="true">?</span></span></label>');
// Check help display title before.
$this
->assertRaw('<label for="edit-help-before-title"><span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_before_title" data-webform-help="<div class="webform-element-help--title">help_before_title</div><div class="webform-element-help--content">{This is an example of help}</div>"><span aria-hidden="true">?</span></span>help_before_title</label>');
// Check help display element after.
$this
->assertRaw('<span class="field-suffix"><span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_after_element" data-webform-help="<div class="webform-element-help--title">help_after_element</div><div class="webform-element-help--content">{This is an example of help}</div>"><span aria-hidden="true">?</span></span></span>');
// Check help display element before.
$this
->assertRaw('<span class="field-prefix"><span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="help_before_element" data-webform-help="<div class="webform-element-help--title">help_before_element</div><div class="webform-element-help--content">{This is an example of help}</div>"><span aria-hidden="true">?</span></span></span>');
}