WebformSubmissionGenerateTest.php in Webform 8.5
File
tests/src/Functional/WebformSubmissionGenerateTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional;
use Drupal\webform\Entity\Webform;
use Drupal\webform\Entity\WebformSubmission;
class WebformSubmissionGenerateTest extends WebformBrowserTestBase {
public function testWebformSubmissionGenerate() {
$this
->drupalLogin($this->rootUser);
$webform = Webform::load('contact');
$sid = $this
->postSubmissionTest($webform);
$webform_submission = WebformSubmission::load($sid);
$test_data = [
'message' => 'Please ignore this email.',
'subject' => 'Testing contact webform from Drupal',
];
$data = $webform_submission
->getData();
$this
->assertEqual($data['message'], $test_data['message']);
$this
->assertEqual($data['subject'], $test_data['subject']);
$this
->drupalGet('/webform/contact/test');
$this
->assertCssSelect('.webform-submission-form.webform-submission-test-form.webform-submission-contact-form.webform-submission-contact-test-form');
foreach ($test_data as $name => $value) {
$this
->assertFieldByName($name, $value);
}
$this
->drupalGet('/webform/contact');
$this
->assertCssSelect('.webform-submission-form.webform-submission-add-form.webform-submission-contact-form.webform-submission-contact-add-form');
foreach ($test_data as $name => $value) {
$this
->assertNoFieldByName($name, $value);
}
$this
->drupalGet('/webform/contact', [
'query' => [
'_webform_test' => 'contact',
],
]);
$this
->assertCssSelect('.webform-submission-form.webform-submission-test-form.webform-submission-contact-form.webform-submission-contact-test-form');
foreach ($test_data as $name => $value) {
$this
->assertFieldByName($name, $value);
}
}
}