WebformStatesWizardTest.php in Webform 8.5
File
tests/src/Functional/States/WebformStatesWizardTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\States;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformStatesWizardTest extends WebformBrowserTestBase {
protected static $testWebforms = [
'test_states_server_wizard',
];
public function testFormStatesValidatorWizard() {
$webform = Webform::load('test_states_server_wizard');
$this
->postSubmission($webform, [], 'Next >');
$this
->assertRaw("page_01_trigger_checkbox: 0\npage_01_textfield_required: '{default_value}'\npage_01_textfield_optional: '{default_value}'\npage_01_textfield_disabled: ''\npage_01_textfield_enabled: ''\npage_01_textfield_visible: ''\npage_01_textfield_invisible: ''\npage_01_checkbox_checked: 0\npage_01_checkbox_unchecked: 0\npage_02_textfield_required: '{default_value}'\npage_02_textfield_optional: '{default_value}'\npage_02_textfield_disabled: ''\npage_02_textfield_enabled: ''\npage_02_textfield_visible: '{default_value}'\npage_02_textfield_visible_slide: '{default_value}'\npage_02_textfield_invisible: '{default_value}'\npage_02_textfield_invisible_slide: '{default_value}'\npage_02_checkbox_checked: 0\npage_02_checkbox_unchecked: 0\npage_03_textfield_required: '{default_value}'\npage_01_trigger_checkbox_computed: 'No'");
$this
->assertFieldByName('page_01_trigger_checkbox_computed', 'No');
$this
->assertNoCssSelect('[name="page_02_textfield_required"][required]');
$this
->assertCssSelect('[name="page_02_textfield_optional"][required]');
$this
->assertNoCssSelect('[name="page_02_textfield_disabled"][disabled]');
$this
->assertCssSelect('[name="page_02_textfield_enabled"][disabled]');
$this
->assertCssSelect('.form-item-page-02-textfield-visible.js-webform-states-hidden');
$this
->assertCssSelect('.form-item-page-02-textfield-visible-slide.js-webform-states-hidden');
$this
->assertFieldByName('page_02_textfield_invisible', '{default_value}');
$this
->assertFieldByName('page_02_textfield_invisible_slide', '{default_value}');
$this
->assertNoFieldChecked('page_02_checkbox_checked');
$this
->assertFieldChecked('page_02_checkbox_unchecked');
$this
->assertCssSelect('details[id="edit-page-02-details-expanded"]');
$this
->assertNoCssSelect('details[id="edit-page-02-details-expanded"][open]');
$this
->assertCssSelect('details[id="edit-page-02-details-collapsed"][open]');
$this
->drupalPostForm(NULL, [], 'Submit');
$this
->assertRaw("page_01_trigger_checkbox: 0\npage_01_textfield_required: '{default_value}'\npage_01_textfield_optional: '{default_value}'\npage_01_textfield_disabled: ''\npage_01_textfield_enabled: ''\npage_01_textfield_visible: ''\npage_01_textfield_invisible: ''\npage_01_checkbox_checked: 0\npage_01_checkbox_unchecked: 0\npage_02_textfield_required: '{default_value}'\npage_02_textfield_optional: '{default_value}'\npage_02_textfield_disabled: ''\npage_02_textfield_enabled: ''\npage_02_textfield_visible: ''\npage_02_textfield_visible_slide: ''\npage_02_textfield_invisible: '{default_value}'\npage_02_textfield_invisible_slide: '{default_value}'\npage_02_checkbox_checked: 0\npage_02_checkbox_unchecked: 1\npage_03_textfield_required: ''\npage_01_trigger_checkbox_computed: 'No'");
$this
->postSubmission($webform, [
'page_01_trigger_checkbox' => TRUE,
], 'Next >');
$this
->assertRaw("page_01_trigger_checkbox: 1\npage_01_textfield_required: '{default_value}'\npage_01_textfield_optional: '{default_value}'\npage_01_textfield_disabled: ''\npage_01_textfield_enabled: ''\npage_01_textfield_visible: ''\npage_01_textfield_invisible: ''\npage_01_checkbox_checked: 0\npage_01_checkbox_unchecked: 0\npage_02_textfield_required: '{default_value}'\npage_02_textfield_optional: '{default_value}'\npage_02_textfield_disabled: ''\npage_02_textfield_enabled: ''\npage_02_textfield_visible: '{default_value}'\npage_02_textfield_visible_slide: '{default_value}'\npage_02_textfield_invisible: '{default_value}'\npage_02_textfield_invisible_slide: '{default_value}'\npage_02_checkbox_checked: 0\npage_02_checkbox_unchecked: 0\npage_03_textfield_required: '{default_value}'\npage_01_trigger_checkbox_computed: 'Yes'");
$this
->assertCssSelect('[name="page_01_trigger_checkbox_computed"][value="Yes"]');
$this
->assertCssSelect('[name="page_02_textfield_required"][required]');
$this
->assertNoCssSelect('[name="page_02_textfield_optional"][required]');
$this
->assertCssSelect('[name="page_02_textfield_disabled"][disabled="disabled"]');
$this
->assertNoCssSelect('[name="page_02_textfield_enabled"][disabled="disabled"]');
$this
->assertFieldByName('page_02_textfield_visible', '{default_value}');
$this
->assertFieldByName('page_02_textfield_visible_slide', '{default_value}');
$this
->assertCssSelect('.form-item-page-02-textfield-invisible.js-webform-states-hidden');
$this
->assertNoFieldByName('page_02_textfield_invisible', '{default_value}');
$this
->assertFieldByName('page_02_textfield_invisible', '');
$this
->assertCssSelect('.form-item-page-02-textfield-invisible-slide.js-webform-states-hidden');
$this
->assertNoFieldByName('page_02_textfield_invisible_slide', '{default_value}');
$this
->assertFieldByName('page_02_textfield_invisible_slide', '');
$this
->assertFieldChecked('page_02_checkbox_checked');
$this
->assertNoFieldChecked('page_02_checkbox_unchecked');
$this
->assertCssSelect('details[id="edit-page-02-details-expanded"][open]');
$this
->assertNoCssSelect('details[id="edit-page-02-details-collapsed"][open]');
$this
->drupalPostForm(NULL, [], 'Next >');
$this
->assertRaw("page_01_trigger_checkbox: 1\npage_01_textfield_required: '{default_value}'\npage_01_textfield_optional: '{default_value}'\npage_01_textfield_disabled: ''\npage_01_textfield_enabled: ''\npage_01_textfield_visible: ''\npage_01_textfield_invisible: ''\npage_01_checkbox_checked: 0\npage_01_checkbox_unchecked: 0\npage_02_textfield_required: '{default_value}'\npage_02_textfield_optional: '{default_value}'\npage_02_textfield_disabled: ''\npage_02_textfield_enabled: ''\npage_02_textfield_visible: '{default_value}'\npage_02_textfield_visible_slide: '{default_value}'\npage_02_textfield_invisible: ''\npage_02_textfield_invisible_slide: ''\npage_02_checkbox_checked: 1\npage_02_checkbox_unchecked: 0\npage_03_textfield_required: '{default_value}'\npage_01_trigger_checkbox_computed: 'Yes'");
$this
->drupalPostForm(NULL, [], 'Submit');
$this
->assertRaw("page_01_trigger_checkbox: 1\npage_01_textfield_required: '{default_value}'\npage_01_textfield_optional: '{default_value}'\npage_01_textfield_disabled: ''\npage_01_textfield_enabled: ''\npage_01_textfield_visible: ''\npage_01_textfield_invisible: ''\npage_01_checkbox_checked: 0\npage_01_checkbox_unchecked: 0\npage_02_textfield_required: '{default_value}'\npage_02_textfield_optional: '{default_value}'\npage_02_textfield_disabled: ''\npage_02_textfield_enabled: ''\npage_02_textfield_visible: '{default_value}'\npage_02_textfield_visible_slide: '{default_value}'\npage_02_textfield_invisible: ''\npage_02_textfield_invisible_slide: ''\npage_02_checkbox_checked: 1\npage_02_checkbox_unchecked: 0\npage_03_textfield_required: '{default_value}'\npage_01_trigger_checkbox_computed: 'Yes'");
}
}