WebformStatesRequiredJavaScriptTest.php in Webform 8.5
File
tests/src/FunctionalJavascript/States/WebformStatesRequiredJavaScriptTest.php
View source
<?php
namespace Drupal\Tests\webform\FunctionalJavascript\States;
use Drupal\Tests\webform\FunctionalJavascript\WebformWebDriverTestBase;
class WebformStatesRequiredJavaScriptTest extends WebformWebDriverTestBase {
public static $modules = [
'webform',
'webform_clientside_validation',
'file',
];
protected static $testWebforms = [
'test_states_client_required',
];
public function testRequiredState() {
$this
->assertTrue(TRUE);
return;
$session = $this
->getSession();
$page = $session
->getPage();
$this
->drupalGet('/webform/test_states_client_required');
$this
->assertCssSelect('#edit-radios-static-one[required]');
$this
->assertCssSelect('#edit-radios-static-two[required]');
$this
->assertCssSelect('#edit-radios-static-three[required]');
$this
->assertCssSelect('#edit-radios-static-one[data-msg-required="radios_static field is required."]');
$this
->assertCssSelect('#edit-radios-static-two[data-msg-required="radios_static field is required."]');
$this
->assertCssSelect('#edit-radios-static-three[data-msg-required="radios_static field is required."]');
$this
->assertCssSelect('#edit-radios-other-static-radios-one[required]');
$this
->assertCssSelect('#edit-radios-other-static-radios-two[required]');
$this
->assertCssSelect('#edit-radios-other-static-radios-three[required]');
$this
->assertCssSelect('#edit-checkboxes-static-one[required]');
$this
->assertNoCssSelect('#edit-checkboxes-static-two[required]');
$this
->assertNoCssSelect('#edit-checkboxes-static-three[required]');
$this
->assertCssSelect('#edit-checkboxes-static-one[data-msg-required="checkboxes_static field is required."]');
$this
->assertNoCssSelect('#edit-checkboxes-static-two[data-msg-required="checkboxes_static field is required."]');
$this
->assertNoCssSelect('#edit-checkboxes-static-three[data-msg-required="checkboxes_static field is required."]');
$this
->assertCssSelect('#edit-checkboxes-other-static-checkboxes-one[required]');
$this
->assertNoCssSelect('#edit-checkboxes-other-static-checkboxes--two[required]');
$this
->assertNoCssSelect('#edit-checkboxes-other-static-checkboxes--three[required]');
$this
->assertNoCssSelect('#edit-managed-file-upload[required]');
$this
->assertNoCssSelect('[data-drupal-selector="edit-radios"] .fieldset-legend.js-form-required.form-required');
$this
->assertNoCssSelect('[data-drupal-selector="edit-checkboxes"] .fieldset-legend.js-form-required.form-required');
$this
->assertNoCssSelect('#edit-radios-one[required]');
$this
->assertNoCssSelect('#edit-radios-two[required]');
$this
->assertNoCssSelect('#edit-radios-three[required]');
$this
->assertNoCssSelect('#edit-checkboxes-one[required]');
$this
->assertNoCssSelect('#edit-checkboxes-two[required]');
$this
->assertNoCssSelect('#edit-checkboxes-three[required]');
$this
->assertNoCssSelect('#edit-select-other-select[required]');
$page
->checkField('trigger');
$this
->assertCssSelect('#edit-managed-file-upload[required]');
$this
->assertCssSelect('[data-drupal-selector="edit-radios"] .fieldset-legend.js-form-required.form-required');
$this
->assertCssSelect('[data-drupal-selector="edit-checkboxes"] .fieldset-legend.js-form-required.form-required');
$this
->assertCssSelect('#edit-radios-one[required]');
$this
->assertCssSelect('#edit-radios-two[required]');
$this
->assertCssSelect('#edit-radios-three[required]');
$this
->assertCssSelect('#edit-radios-one[data-msg-required="radios field is required."]');
$this
->assertCssSelect('#edit-radios-two[data-msg-required="radios field is required."]');
$this
->assertCssSelect('#edit-radios-three[data-msg-required="radios field is required."]');
$this
->assertCssSelect('#edit-radios-other-radios-one[required]');
$this
->assertCssSelect('#edit-radios-other-radios-two[required]');
$this
->assertCssSelect('#edit-radios-other-radios-three[required]');
$this
->assertCssSelect('#edit-checkboxes-one[required]');
$this
->assertNoCssSelect('#edit-checkboxes-two[required]');
$this
->assertNoCssSelect('#edit-checkboxes-three[required]');
$this
->assertCssSelect('#edit-checkboxes-one[data-msg-required="checkboxes field is required."]');
$this
->assertNoCssSelect('#edit-checkboxes-two[data-msg-required="checkboxes field is required."]');
$this
->assertNoCssSelect('#edit-checkboxes-three[data-msg-required="checkboxes field is required."]');
$this
->assertCssSelect('#edit-checkboxes-other-checkboxes-one[required]');
$this
->assertNoCssSelect('#edit-checkboxes-other-checkboxes-two[required]');
$this
->assertNoCssSelect('#edit-checkboxes-other-checkboxes-three[required]');
$this
->assertCssSelect('#edit-select-other-select[required]');
$this
->assertNoCssSelect('#edit-select-other-form-element > label[for]');
$this
->assertCssSelect('#edit-select-other-form-element > label.js-form-required.form-required');
$this
->assertNoCssSelect('fieldset#edit-fieldset[required]');
$page
->checkField('edit-checkboxes-one');
$this
->assertNoCssSelect('#edit-checkboxes-one[required]');
$page
->uncheckField('edit-checkboxes-one');
$this
->assertCssSelect('#edit-checkboxes-one[required]');
$page
->checkField('edit-checkboxes-two');
$this
->assertNoCssSelect('#edit-checkboxes-one[required]');
}
}