WebformSettingsAutofillTest.php in Webform 8.5
File
tests/src/Functional/Settings/WebformSettingsAutofillTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Settings;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformSettingsAutofillTest extends WebformBrowserTestBase {
protected static $testWebforms = [
'test_form_autofill',
];
public function testAutofill() {
$account = $this
->drupalCreateUser();
$this
->drupalLogin($account);
$webform = Webform::load('test_form_autofill');
$this
->drupalGet('/webform/test_form_autofill');
$this
->assertNoRaw('This submission has been autofilled with your previous submission.');
$this
->assertFieldByName('textfield_autofill', '');
$this
->assertFieldByName('textfield_excluded', '');
$edit = [
'textfield_autofill' => '{textfield_autofill}',
'textfield_excluded' => '{textfield_excluded}',
];
$this
->postSubmission($webform, $edit);
$this
->drupalGet('/webform/test_form_autofill');
$this
->assertFieldByName('textfield_autofill', '{textfield_autofill}');
$this
->assertNoFieldByName('textfield_autofill', '{textfield_excluded}');
$this
->assertFieldByName('textfield_excluded', '');
$this
->drupalGet('/webform/test_form_autofill');
$this
->assertFieldByName('textfield_autofill', '{textfield_autofill}');
$this
->assertRaw('This submission has been autofilled with your previous submission.');
\Drupal::configFactory()
->getEditable('webform.settings')
->set('settings.default_autofill_message', '')
->save();
$this
->drupalGet('/webform/test_form_autofill');
$this
->assertFieldByName('textfield_autofill', '{textfield_autofill}');
$this
->assertNoRaw('This submission has been autofilled with your previous submission.');
$webform
->setSetting('autofill_message', '{autofill_message}')
->save();
$this
->drupalGet('/webform/test_form_autofill');
$this
->assertFieldByName('textfield_autofill', '{textfield_autofill}');
$this
->assertRaw('{autofill_message}');
}
}