public function WebformElementAttributesTest::testAttributes in Webform 6.x
Same name and namespace in other branches
- 8.5 tests/src/Functional/Element/WebformElementAttributesTest.php \Drupal\Tests\webform\Functional\Element\WebformElementAttributesTest::testAttributes()
Tests element attributes.
File
- tests/
src/ Functional/ Element/ WebformElementAttributesTest.php, line 22
Class
- WebformElementAttributesTest
- Tests for webform element attributes.
Namespace
Drupal\Tests\webform\Functional\ElementCode
public function testAttributes() {
/* Rendering */
$this
->drupalGet('/webform/test_element_attributes');
// Check four and five are merged in class select other text field.
$this
->assertFieldByName('webform_element_attributes[class][other]', 'four five');
// Check one, two, four, and five are merged in class text field.
$this
->assertFieldByName('webform_element_attributes_no_classes[class]', 'one two four five');
/* Submit */
// Check default value handling.
$this
->drupalPostForm('/webform/test_element_attributes', [], 'Submit');
$this
->assertRaw("webform_element_attributes:\n class:\n - one\n - two\n - four\n - five\n style: 'color: red'\n custom: test\nwebform_element_attributes_no_classes:\n class:\n - one\n - two\n - four\n - five");
}