WebformSettingsSerialTest.php in Webform 8.5
File
tests/src/Functional/Settings/WebformSettingsSerialTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Settings;
use Drupal\webform\Entity\Webform;
use Drupal\webform\Entity\WebformSubmission;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformSettingsSerialTest extends WebformBrowserTestBase {
public function testSettings() {
$this
->drupalLogin($this->rootUser);
$webform = Webform::load('contact');
$this
->drupalPostForm('/admin/structure/webform/manage/contact/settings/submissions', [
'next_serial' => 99,
], 'Save');
$sid = $this
->postSubmissionTest($webform);
$webform_submission = WebformSubmission::load($sid);
$this
->assertEqual($webform_submission
->serial(), 99);
$this
->assertNotEqual($webform_submission
->serial(), $sid);
$this
->drupalPostForm('/admin/structure/webform/manage/contact/settings/submissions', [
'next_serial' => 1,
], 'Save');
$this
->assertRaw('The next submission number was increased to 100 to make it higher than existing submissions.');
$webform
->setSetting('serial_disabled', TRUE)
->save();
$sid = $this
->postSubmissionTest($webform);
$webform_submission = WebformSubmission::load($sid);
$this
->assertNotEqual($webform_submission
->serial(), 100);
$this
->assertEqual($webform_submission
->serial(), $sid);
}
}