View source
<?php
namespace Drupal\Tests\webform_encrypt\Functional;
use Drupal\Tests\BrowserTestBase;
class WebformEncryptWizardTest extends BrowserTestBase {
protected $adminUser;
protected static $modules = [
'webform_encrypt',
'webform_encrypt_test',
];
protected function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'access administration pages',
'view any webform submission',
'edit any webform',
]);
}
public function testWizardEncrypted() {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('webform/test_wizard_encryption');
$edit = [
'test_first_name_field' => 'FirstNameTest',
'test_last_name_field' => 'LastNameTest',
'test_gender_field' => 'Male',
];
$this
->drupalPostForm(NULL, $edit, 'Next Page >');
$this
->drupalPostForm(NULL, NULL, '< Previous Page');
$assert_session
->fieldValueEquals('test_last_name_field', $edit['test_last_name_field']);
$this
->drupalPostForm(NULL, NULL, 'Next Page >');
$edit = [
'test_email_field' => 'testsubmission@test.test',
'test_phone_field' => '+3333333333',
'test_contact_via_phone_field' => 'Yes',
'test_address_field[address]' => 'Test multiple address field address',
'test_address_field[address_2]' => 'Test multiple address field address 2',
'test_address_field[city]' => 'Test multiple address field city',
'test_address_field[state_province]' => 'California',
'test_address_field[postal_code]' => 'AA11AA',
'test_address_field[country]' => 'United Kingdom',
'test_multiple_address_field[items][0][_item_][address]' => 'Test multiple address field address',
'test_multiple_address_field[items][0][_item_][address_2]' => 'Test multiple address field address 2',
'test_multiple_address_field[items][0][_item_][city]' => 'Test multiple address field city',
'test_multiple_address_field[items][0][_item_][state_province]' => 'California',
'test_multiple_address_field[items][0][_item_][postal_code]' => 'AA11AA',
'test_multiple_address_field[items][0][_item_][country]' => 'United Kingdom',
];
$this
->drupalPostForm(NULL, $edit, 'Next Page >');
$this
->drupalPostForm(NULL, NULL, '< Previous Page');
$assert_session
->fieldValueEquals('test_email_field', $edit['test_email_field']);
$assert_session
->fieldValueEquals('test_phone_field', $edit['test_phone_field']);
$assert_session
->fieldValueEquals('test_contact_via_phone_field', $edit['test_contact_via_phone_field']);
$assert_session
->fieldValueEquals('test_address_field[address]', $edit['test_address_field[address]']);
$assert_session
->fieldValueEquals('test_address_field[address_2]', $edit['test_address_field[address_2]']);
$assert_session
->fieldValueEquals('test_address_field[city]', $edit['test_address_field[city]']);
$assert_session
->fieldValueEquals('test_address_field[state_province]', $edit['test_address_field[state_province]']);
$assert_session
->fieldValueEquals('test_address_field[postal_code]', $edit['test_address_field[postal_code]']);
$assert_session
->fieldValueEquals('test_address_field[country]', $edit['test_address_field[country]']);
$assert_session
->fieldValueEquals('test_multiple_address_field[items][0][_item_][address]', $edit['test_multiple_address_field[items][0][_item_][address]']);
$assert_session
->fieldValueEquals('test_multiple_address_field[items][0][_item_][address_2]', $edit['test_multiple_address_field[items][0][_item_][address_2]']);
$assert_session
->fieldValueEquals('test_multiple_address_field[items][0][_item_][city]', $edit['test_multiple_address_field[items][0][_item_][city]']);
$assert_session
->fieldValueEquals('test_multiple_address_field[items][0][_item_][state_province]', $edit['test_multiple_address_field[items][0][_item_][state_province]']);
$assert_session
->fieldValueEquals('test_multiple_address_field[items][0][_item_][postal_code]', $edit['test_multiple_address_field[items][0][_item_][postal_code]']);
$assert_session
->fieldValueEquals('test_multiple_address_field[items][0][_item_][country]', $edit['test_multiple_address_field[items][0][_item_][country]']);
}
}