WebformElementCompositeTest.php in Webform 8.5
File
tests/src/Functional/Element/WebformElementCompositeTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Element;
use Drupal\webform\Entity\Webform;
class WebformElementCompositeTest extends WebformElementBrowserTestBase {
protected static $testWebforms = [
'test_element_composite',
'test_element_composite_wrapper',
];
public function testComposite() {
$webform = Webform::load('test_element_composite');
$this
->postSubmission($webform);
$this
->assertRaw("webform_element_composite_basic:\n first_name:\n '#type': textfield\n '#required': true\n '#title': 'First name'\n last_name:\n '#type': textfield\n '#required': true\n '#title': 'Last name'\nwebform_element_composite_advanced:\n first_name:\n '#type': textfield\n '#title': 'First name'\n last_name:\n '#type': textfield\n '#title': 'Last name'\n gender:\n '#type': select\n '#options':\n Male: Male\n Female: Female\n '#title': Gender\n martial_status:\n '#type': webform_select_other\n '#options': marital_status\n '#title': 'Martial status'\n employment_status:\n '#type': webform_select_other\n '#options': employment_status\n '#title': 'Employment status'\n age:\n '#type': number\n '#title': Age\n '#field_suffix': ' yrs. old'\n '#min': 1\n '#max': 125");
$this
->drupalLogin($this->rootUser);
$this
->postSubmission($webform);
$this
->assertRaw("webform_element_composite_basic:\n first_name:\n '#type': textfield\n '#required': true\n '#title': 'First name'\n last_name:\n '#type': textfield\n '#required': true\n '#title': 'Last name'\nwebform_element_composite_advanced:\n first_name:\n '#type': textfield\n '#title': 'First name'\n last_name:\n '#type': textfield\n '#title': 'Last name'\n gender:\n '#type': select\n '#options':\n Male: Male\n Female: Female\n '#title': Gender\n martial_status:\n '#type': webform_select_other\n '#options': marital_status\n '#title': 'Martial status'\n employment_status:\n '#type': webform_select_other\n '#options': employment_status\n '#title': 'Employment status'\n age:\n '#type': number\n '#title': Age\n '#field_suffix': ' yrs. old'\n '#min': 1\n '#max': 125");
$this
->drupalGet('/webform/test_element_composite_wrapper');
$this
->assertRaw('<fieldset data-drupal-selector="edit-radios-wrapper-fieldset" id="edit-radios-wrapper-fieldset--wrapper" class="radios--wrapper fieldgroup form-composite webform-composite-visible-title required js-webform-type-radios webform-type-radios js-form-item form-item js-form-wrapper form-wrapper" aria-required="true">');
$this
->assertRaw('<fieldset data-drupal-selector="edit-radios-wrapper-fieldset-hidden-title" id="edit-radios-wrapper-fieldset-hidden-title--wrapper" class="radios--wrapper fieldgroup form-composite webform-composite-hidden-title required js-webform-type-radios webform-type-radios js-form-item form-item js-form-wrapper form-wrapper" aria-required="true">');
$this
->assertRaw('<div class="js-form-item form-item js-form-type-radios form-item-radios-wrapper-form-element js-form-item-radios-wrapper-form-element">');
$this
->assertRaw('<div data-drupal-selector="edit-radios-wrapper-container" id="edit-radios-wrapper-container--wrapper" class="radios--wrapper fieldgroup form-composite js-form-wrapper form-wrapper">');
$this
->assertRaw('<input data-drupal-selector="edit-radios-wrapper-fieldset-description-one" aria-describedby="edit-radios-wrapper-fieldset-description--wrapper--description" type="radio" id="edit-radios-wrapper-fieldset-description-one" name="radios_wrapper_fieldset_description" value="One" class="form-radio" />');
if (floatval(\Drupal::VERSION) >= 9) {
$this
->assertRaw('<div class="description"><div id="edit-radios-wrapper-fieldset-description--wrapper--description" data-drupal-field-elements="description" class="webform-element-description">This is a description</div>');
}
else {
$this
->assertRaw('<div class="description"><div id="edit-radios-wrapper-fieldset-description--wrapper--description" class="webform-element-description">This is a description</div>');
}
$this
->assertRaw('<fieldset data-drupal-selector="edit-states-fieldset" class="js-webform-states-hidden radios--wrapper fieldgroup form-composite webform-composite-visible-title js-webform-type-radios webform-type-radios js-form-item form-item js-form-wrapper form-wrapper" id="edit-states-fieldset--wrapper" data-drupal-states="{"visible":{".webform-submission-test-element-composite-wrapper-add-form :input[name=\\u0022states_checkbox\\u0022]":{"checked":true}}}">');
$this
->assertRaw('<div class="js-webform-states-hidden js-form-item form-item js-form-type-radios form-item-states-form-item js-form-item-states-form-item" data-drupal-states="{"visible":{".webform-submission-test-element-composite-wrapper-add-form :input[name=\\u0022states_checkbox\\u0022]":{"checked":true}}}">');
$this
->assertRaw('<div data-drupal-selector="edit-states-container" class="js-webform-states-hidden radios--wrapper fieldgroup form-composite js-form-wrapper form-wrapper" id="edit-states-container--wrapper" data-drupal-states="{"visible":{".webform-submission-test-element-composite-wrapper-add-form :input[name=\\u0022states_checkbox\\u0022]":{"checked":true}}}">');
}
}