WebformSettingsPreviousTest.php in Webform 8.5
File
tests/src/Functional/Settings/WebformSettingsPreviousTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Settings;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformSettingsPreviousTest extends WebformBrowserTestBase {
public function testPrevious() {
global $base_path;
$this
->drupalLogin($this->rootUser);
$webform = Webform::load('contact');
$sid_1 = $this
->postSubmissionTest($webform);
$this
->drupalGet('/webform/contact');
$this
->assertRaw("You have already submitted this webform. <a href=\"{$base_path}webform/contact/submissions/{$sid_1}\">View your previous submission</a>.");
$this
->config('webform.settings')
->set('settings.default_previous_submission_message', '{default_previous_submission}')
->save();
$this
->drupalGet('/webform/contact');
$this
->assertRaw('{default_previous_submission}');
$webform
->setSetting('previous_submission_message', '{custom_previous_submission}')
->save();
$this
->drupalGet('/webform/contact');
$this
->assertRaw('{custom_previous_submission}');
$sid_2 = $this
->postSubmissionTest($webform);
$this
->drupalGet('/webform/contact');
$this
->assertRaw("You have already submitted this webform. <a href=\"{$base_path}webform/contact/submissions\">View your previous submissions</a>.");
$this
->config('webform.settings')
->set('settings.default_previous_submissions_message', '{default_previous_submissions}')
->save();
$this
->drupalGet('/webform/contact');
$this
->assertRaw('{default_previous_submissions}');
$webform
->setSetting('previous_submissions_message', '{custom_previous_submissions}')
->save();
$this
->drupalGet('/webform/contact');
$this
->assertRaw('{custom_previous_submissions}');
}
}