public function WebformEncryptEditSumissionsTest::testEditSubmissions in Webform Encrypt 8
Test webform field encryption.
File
- tests/
src/ Functional/ WebformEncryptEditSumissionsTest.php, line 55
Class
- WebformEncryptEditSumissionsTest
- Tests editing of encrypted webform submissions.
Namespace
Drupal\Tests\webform_encrypt\FunctionalCode
public function testEditSubmissions() {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this->notViewEncryptedUser);
// Make a submission.
$edit = [
'test_text_field' => 'Test text field encrypted value',
'test_text_area' => 'Test text area encrypted value',
'test_not_encrypted' => 'Test not encrypted value',
];
$this
->drupalPostForm('/webform/test_encryption', $edit, 'Submit');
$assert_session
->responseContains('New submission added to Test encryption.');
// Ensure form is not accessible by user without the view encrypted values
// permission.
$edit_submission_path = 'admin/structure/webform/manage/test_encryption/submission/1/edit';
$this
->drupalGet($edit_submission_path);
$assert_session
->statusCodeEquals(403);
$assert_session
->responseContains('You are not authorized to access this page.');
// Verify with the view encrypted values permission that form submission is
// editable by user with the view encrypted values permission.
$this
->drupalLogin($this->viewEncryptedUser);
$this
->drupalGet($edit_submission_path);
$assert_session
->fieldValueEquals('test_text_field', $edit['test_text_field']);
$assert_session
->fieldValueEquals('test_text_area', $edit['test_text_area']);
$assert_session
->fieldValueEquals('test_not_encrypted', $edit['test_not_encrypted']);
// Save the form without changing any values.
$this
->drupalPostForm($edit_submission_path, [], 'Save');
// Check submission is still editeable and values are unchanged.
$this
->drupalGet($edit_submission_path);
$assert_session
->fieldValueEquals('test_text_field', $edit['test_text_field']);
$assert_session
->fieldValueEquals('test_text_area', $edit['test_text_area']);
$assert_session
->fieldValueEquals('test_not_encrypted', $edit['test_not_encrypted']);
}