public function WebformElementTextFormatTest::testTextFormat in Webform 6.x
Same name and namespace in other branches
- 8.5 tests/src/Functional/Element/WebformElementTextFormatTest.php \Drupal\Tests\webform\Functional\Element\WebformElementTextFormatTest::testTextFormat()
Test text format element.
File
- tests/
src/ Functional/ Element/ WebformElementTextFormatTest.php, line 52
Class
- WebformElementTextFormatTest
- Tests for text format element.
Namespace
Drupal\Tests\webform\Functional\ElementCode
public function testTextFormat() {
$webform = Webform::load('test_element_text_format');
// Check that formats and tips are removed and/or hidden.
$this
->drupalGet('/webform/test_element_text_format');
$this
->assertRaw('<div class="js-filter-wrapper filter-wrapper js-form-wrapper form-wrapper" data-drupal-selector="edit-text-format-format" style="display: none" data-webform-states-no-clear id="edit-text-format-format">');
$this
->assertRaw('<div class="filter-help js-form-wrapper form-wrapper" data-drupal-selector="edit-text-format-format-help" style="display: none" id="edit-text-format-format-help">');
// Check description + more.
$this
->assertRaw('<div data-drupal-selector="edit-text-format-description-more" id="edit-text-format-description-more--description"><div class="webform-element-description">This is a description</div>');
$this
->assertRaw('<div id="edit-text-format-description-more--more" class="js-webform-element-more webform-element-more">');
$this
->assertRaw('<div class="webform-element-more--link"><a role="button" href="#edit-text-format-description-more--more--content">More</a></div>');
$this
->assertRaw('<div id="edit-text-format-description-more--more--content" class="webform-element-more--content">This is more</div>');
// Check 'text_format' values.
$this
->drupalGet('/webform/test_element_text_format');
$this
->assertFieldByName('text_format[value]', 'The quick brown fox jumped over the lazy dog.');
$this
->assertRaw('No HTML tags allowed.');
$text_format = [
'value' => 'Custom value',
'format' => 'custom_format',
];
$form = $webform
->getSubmissionForm([
'data' => [
'text_format' => $text_format,
],
]);
$this
->assertEqual($form['elements']['text_format']['#default_value'], $text_format['value']);
$this
->assertEqual($form['elements']['text_format']['#format'], $text_format['format']);
}