WebformElementHelpTest.php in Webform 8.5
File
tests/src/Functional/Element/WebformElementHelpTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Element;
class WebformElementHelpTest extends WebformElementBrowserTestBase {
protected static $testWebforms = [
'test_element_help',
];
public function testHelp() {
$this
->drupalGet('/webform/test_element_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>');
$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>');
$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>');
$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>');
$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>');
$this
->assertRaw('<label for="edit-help-empty">help_empty</label>');
$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>');
$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>');
$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>');
$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>');
$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>');
$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>');
$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>');
$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>');
$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>');
}
}