View source
<?php
namespace Drupal\Tests\webform\Functional\Wizard;
class WebformWizardValidateTest extends WebformWizardTestBase {
public static $modules = [
'webform',
'webform_test_element',
];
protected static $testWebforms = [
'test_form_wizard_validate',
'test_form_wizard_validate_comp',
];
public function testWizardValidate() {
$this
->drupalGet('/webform/test_form_wizard_validate');
$this
->drupalPostForm('/webform/test_form_wizard_validate', [], 'Next >');
$this
->assertRaw('wizard_1_textfield field is required.');
$this
->assertRaw('wizard_1_select_other field is required.');
$this
->assertRaw('wizard_1_datelist field is required.');
$edit = [
'wizard_1_textfield' => '{wizard_1_textfield}',
'wizard_1_select_other[select]' => 'one',
'wizard_1_datelist[items][0][_item_][year]' => '2001',
'wizard_1_datelist[items][0][_item_][month]' => '1',
'wizard_1_datelist[items][0][_item_][day]' => '1',
'wizard_1_datelist[items][0][_item_][hour]' => '1',
'wizard_1_datelist[items][0][_item_][minute]' => '10',
];
$this
->drupalPostForm('/webform/test_form_wizard_validate', $edit, 'Next >');
$this
->assertRaw("wizard_1_textfield: '{wizard_1_textfield}'\nwizard_1_select_other: one\nwizard_1_datelist:\n - '2001-01-01T01:10:00+1100'\nwizard_2_textfield: ''\nwizard_2_select_other: null\nwizard_2_datelist: { }");
$edit = [
'wizard_2_textfield' => '{wizard_2_textfield}',
'wizard_2_select_other[select]' => 'two',
'wizard_2_datelist[items][0][_item_][year]' => '2002',
'wizard_2_datelist[items][0][_item_][month]' => '2',
'wizard_2_datelist[items][0][_item_][day]' => '2',
'wizard_2_datelist[items][0][_item_][hour]' => '2',
'wizard_2_datelist[items][0][_item_][minute]' => '20',
];
$this
->drupalPostForm(NULL, $edit, 'Next >');
$this
->assertRaw("wizard_1_textfield: '{wizard_1_textfield}'\nwizard_1_select_other: one\nwizard_1_datelist:\n - '2001-01-01T01:10:00+1100'\nwizard_2_textfield: '{wizard_2_textfield}'\nwizard_2_select_other: two\nwizard_2_datelist:\n - '2002-02-02T02:20:00+1100'");
$this
->drupalPostForm('/webform/test_form_wizard_validate_comp', [], 'Next >');
$this
->assertRaw('textfield field is required.');
$edit = [
'wizard_1_custom_composite[items][0][datelist][year]' => '2001',
'wizard_1_custom_composite[items][0][datelist][month]' => '1',
'wizard_1_custom_composite[items][0][datelist][day]' => '1',
'wizard_1_custom_composite[items][0][datelist][hour]' => '1',
'wizard_1_custom_composite[items][0][datelist][minute]' => '10',
'wizard_1_custom_composite[items][0][textfield]' => '{wizard_1_custom_composite_textfield}',
'wizard_1_test_composite[textfield]' => '{wizard_1_test_composite_textfield}',
'wizard_1_test_composite[datelist][year]' => '2001',
'wizard_1_test_composite[datelist][month]' => '1',
'wizard_1_test_composite[datelist][day]' => '1',
'wizard_1_test_composite[datelist][hour]' => '1',
'wizard_1_test_composite[datelist][minute]' => '10',
'wizard_1_test_composite_multiple[items][0][_item_][textfield]' => '{wizard_1_test_composite_multiple_textfield}',
'wizard_1_test_composite_multiple[items][0][_item_][datelist][year]' => '2001',
'wizard_1_test_composite_multiple[items][0][_item_][datelist][month]' => '1',
'wizard_1_test_composite_multiple[items][0][_item_][datelist][day]' => '1',
'wizard_1_test_composite_multiple[items][0][_item_][datelist][hour]' => '1',
'wizard_1_test_composite_multiple[items][0][_item_][datelist][minute]' => '10',
];
$this
->drupalPostForm('/webform/test_form_wizard_validate_comp', $edit, 'Next >');
$this
->assertRaw("wizard_1_custom_composite:\n - datelist: '2001-01-01T01:10:00+1100'\n textfield: '{wizard_1_custom_composite_textfield}'\nwizard_1_test_composite:\n textfield: '{wizard_1_test_composite_textfield}'\n datelist: '2001-01-01T01:10:00+1100'\n nested_tel: ''\n nested_select: ''\n email: ''\n webform_email_confirm: ''\n tel: ''\n select: ''\n radios: ''\n date: ''\n webform_entity_select: ''\n entity_autocomplete: null\n datetime: ''\n nested_radios: ''\nwizard_1_test_composite_multiple:\n - textfield: '{wizard_1_test_composite_multiple_textfield}'\n datelist: '2001-01-01T01:10:00+1100'\n nested_tel: ''\n nested_select: ''\n email: ''\n webform_email_confirm: ''\n tel: ''\n select: ''\n radios: null\n date: ''\n webform_entity_select: ''\n entity_autocomplete: null\n datetime: ''\n nested_radios: null\nwizard_2_custom_composite: { }\nwizard_2_test_composite: null\nwizard_2_test_composite_multiple: { }");
$edit = [
'wizard_2_custom_composite[items][0][datelist][year]' => '2002',
'wizard_2_custom_composite[items][0][datelist][month]' => '2',
'wizard_2_custom_composite[items][0][datelist][day]' => '2',
'wizard_2_custom_composite[items][0][datelist][hour]' => '2',
'wizard_2_custom_composite[items][0][datelist][minute]' => '20',
'wizard_2_custom_composite[items][0][textfield]' => '{wizard_2_custom_composite_textfield}',
'wizard_2_test_composite[textfield]' => '{wizard_2_test_composite_textfield}',
'wizard_2_test_composite[datelist][year]' => '2002',
'wizard_2_test_composite[datelist][month]' => '2',
'wizard_2_test_composite[datelist][day]' => '2',
'wizard_2_test_composite[datelist][hour]' => '2',
'wizard_2_test_composite[datelist][minute]' => '20',
'wizard_2_test_composite_multiple[items][0][_item_][textfield]' => '{wizard_2_test_composite_multiple_textfield}',
'wizard_2_test_composite_multiple[items][0][_item_][datelist][year]' => '2002',
'wizard_2_test_composite_multiple[items][0][_item_][datelist][month]' => '2',
'wizard_2_test_composite_multiple[items][0][_item_][datelist][day]' => '2',
'wizard_2_test_composite_multiple[items][0][_item_][datelist][hour]' => '2',
'wizard_2_test_composite_multiple[items][0][_item_][datelist][minute]' => '20',
];
$this
->drupalPostForm(NULL, $edit, 'Next >');
$raw = "wizard_1_custom_composite:\n - datelist: '2001-01-01T01:10:00+1100'\n textfield: '{wizard_1_custom_composite_textfield}'\nwizard_1_test_composite:\n textfield: '{wizard_1_test_composite_textfield}'\n datelist: '2001-01-01T01:10:00+1100'\n nested_tel: ''\n nested_select: ''\n email: ''\n webform_email_confirm: ''\n tel: ''\n select: ''\n radios: ''\n date: ''\n webform_entity_select: ''\n entity_autocomplete: null\n datetime: ''\n nested_radios: ''\nwizard_1_test_composite_multiple:\n - textfield: '{wizard_1_test_composite_multiple_textfield}'\n datelist: '2001-01-01T01:10:00+1100'\n nested_tel: ''\n nested_select: ''\n email: ''\n webform_email_confirm: ''\n tel: ''\n select: ''\n radios: null\n date: ''\n webform_entity_select: ''\n entity_autocomplete: null\n datetime: ''\n nested_radios: null\nwizard_2_custom_composite:\n - datelist: '2002-02-02T02:20:00+1100'\n textfield: '{wizard_2_custom_composite_textfield}'\nwizard_2_test_composite:\n textfield: '{wizard_2_test_composite_textfield}'\n datelist: '2002-02-02T02:20:00+1100'\n nested_tel: ''\n nested_select: ''\n email: ''\n webform_email_confirm: ''\n tel: ''\n select: ''\n radios: ''\n date: ''\n webform_entity_select: ''\n entity_autocomplete: null\n datetime: ''\n nested_radios: ''\nwizard_2_test_composite_multiple:\n - textfield: '{wizard_2_test_composite_multiple_textfield}'\n datelist: '2002-02-02T02:20:00+1100'\n nested_tel: ''\n nested_select: ''\n email: ''\n webform_email_confirm: ''\n tel: ''\n select: ''\n radios: null\n date: ''\n webform_entity_select: ''\n entity_autocomplete: null\n datetime: ''\n nested_radios: null";
$this
->assertRaw($raw);
$this
->drupalPostForm(NULL, [], '< Previous');
$this
->assertRaw($raw);
$this
->drupalPostForm(NULL, [], '< Previous');
$this
->assertRaw($raw);
$this
->drupalPostForm(NULL, [], 'Next >');
$this
->assertRaw($raw);
$this
->drupalPostForm(NULL, [], 'Next >');
$this
->assertRaw($raw);
}
}