WebformElementButtonsTest.php in Webform 6.x
File
modules/webform_jqueryui_buttons/tests/src/Functional/WebformElementButtonsTest.php
View source
<?php
namespace Drupal\Tests\webform_jqueryui_buttons\Functional;
use Drupal\Tests\webform\Functional\Element\WebformElementBrowserTestBase;
class WebformElementButtonsTest extends WebformElementBrowserTestBase {
public static $modules = [
'webform_jqueryui_buttons',
'webform_jqueryui_buttons_test',
];
public function testBuildingOtherElements() {
$this
->drupalGet('/webform/test_element_buttons');
$this
->assertRaw('<span class="fieldset-legend">buttons_other_basic</span>');
$this
->assertRaw('<input data-drupal-selector="edit-buttons-other-basic-buttons-one" type="radio" id="edit-buttons-other-basic-buttons-one" name="buttons_other_basic[buttons]" value="One" class="form-radio" />');
$this
->assertRaw('<label for="edit-buttons-other-basic-buttons-one" class="option">One</label>');
$this
->assertRaw('<input data-drupal-selector="edit-buttons-other-basic-other" type="text" id="edit-buttons-other-basic-other" name="buttons_other_basic[other]" value="Four" size="60" maxlength="255" placeholder="Enter other…" class="form-text" />');
$this
->assertRaw('<span class="fieldset-legend js-form-required form-required">buttons_other_advanced</span>');
$this
->assertRaw('<input data-drupal-selector="edit-buttons-other-advanced-buttons-one" type="radio" id="edit-buttons-other-advanced-buttons-one" name="buttons_other_advanced[buttons]" value="One" class="form-radio" />');
$this
->assertRaw('<input data-drupal-selector="edit-buttons-other-advanced-other" aria-describedby="edit-buttons-other-advanced-other--description" type="text" id="edit-buttons-other-advanced-other" name="buttons_other_advanced[other]" value="Four" size="60" maxlength="255" placeholder="What is this other option" class="form-text" />');
$this
->assertRaw('<div id="edit-buttons-other-advanced-other--description" class="webform-element-description">Other button description</div>');
$edit = [
'buttons_other_basic[buttons]' => '_other_',
'buttons_other_basic[other]' => '',
];
$this
->drupalPostForm('/webform/test_element_buttons', $edit, 'Submit');
$this
->assertRaw('buttons_other_basic field is required.');
$edit = [
'buttons_other_basic[buttons]' => 'One',
'buttons_other_basic[other]' => '',
];
$this
->drupalPostForm('/webform/test_element_buttons', $edit, 'Submit');
$this
->assertNoRaw('buttons_other_basic field is required.');
$edit = [
'buttons_other_advanced[buttons]' => '_other_',
'buttons_other_advanced[other]' => '',
];
$this
->drupalPostForm('/webform/test_element_buttons', $edit, 'Submit');
$this
->assertRaw('buttons_other_advanced field is required.');
$edit = [
'buttons_other_advanced[buttons]' => '_other_',
'buttons_other_advanced[other]' => 'Five',
];
$this
->drupalPostForm('/webform/test_element_buttons', $edit, 'Submit');
$this
->assertRaw('buttons_other_advanced: Five');
$edit = [
'buttons_other_advanced[buttons]' => 'One',
'buttons_other_advanced[other]' => 'Five',
];
$this
->drupalPostForm('/webform/test_element_buttons', $edit, 'Submit');
$this
->assertRaw('buttons_other_advanced: One');
$this
->assertNoRaw('buttons_other_advanced: Five');
}
}