WebformHandlerEmailStatesTest.php in Webform 8.5
File
tests/src/Functional/Handler/WebformHandlerEmailStatesTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Handler;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformHandlerEmailStatesTest extends WebformBrowserTestBase {
protected static $testWebforms = [
'test_handler_email_states',
];
public function testEmailStates() {
$webform = Webform::load('test_handler_email_states');
$this
->drupalPostForm('/webform/test_handler_email_states', [], 'Save Draft');
$this
->assertRaw('Debug: Email: Draft saved');
$sid = $this
->postSubmission($webform);
$this
->assertRaw('Debug: Email: Submission completed');
$this
->drupalLogin($this->rootUser);
$email = $this
->getLastEmail();
$this
->assertEqual($email['id'], 'webform_test_handler_email_states_email_converted');
$this
->drupalPostForm("/admin/structure/webform/manage/test_handler_email_states/submission/{$sid}/edit", [], 'Save');
$this
->drupalGet("/admin/structure/webform/manage/test_handler_email_states/submission/{$sid}/resend");
$this
->assertRaw('<b>Subject:</b> Draft saved<br />');
$this
->assertRaw('<b>Subject:</b> Submission converted<br />');
$this
->assertRaw('<b>Subject:</b> Submission completed<br />');
$this
->assertRaw('<b>Subject:</b> Submission updated<br />');
$this
->assertRaw('<b>Subject:</b> Submission locked<br />');
$this
->assertRaw('<b>Subject:</b> Submission deleted<br />');
$this
->assertRaw('<b>Subject:</b> Submission custom<br />');
$this
->drupalPostForm("/admin/structure/webform/manage/test_handler_email_states/submission/{$sid}/notes", [
'locked' => TRUE,
], 'Save');
$this
->assertRaw('Debug: Email: Submission locked');
$this
->drupalPostForm("/admin/structure/webform/manage/test_handler_email_states/submission/{$sid}/delete", [], 'Delete');
$this
->assertRaw('Debug: Email: Submission deleted');
$this
->drupalGet('/admin/structure/webform/manage/test_handler_email_states/handlers/email_draft/edit');
$this
->assertRaw('<span class="fieldset-legend">Send email</span>');
$webform
->setSetting('results_disabled', TRUE)
->save();
$this
->drupalGet('/admin/structure/webform/manage/test_handler_email_states/handlers/email_draft/edit');
$this
->assertNoRaw('<span class="fieldset-legend js-form-required form-required">Send email</span>');
$this
->postSubmission($webform);
$this
->assertNoRaw('Debug: Email: Draft saved');
$this
->assertRaw('Debug: Email: Submission completed');
$this
->assertNoRaw('Debug: Email: Submission updated');
$this
->assertNoRaw('Debug: Email: Submission deleted');
$this
->assertNoRaw('Debug: Email: Submission custom');
$this
->drupalPostForm('/admin/structure/webform/manage/test_handler_email_states/handlers/email_draft/edit', [], 'Save');
$this
->postSubmission($webform);
$this
->assertRaw('Debug: Email: Draft saved');
$this
->assertRaw('Debug: Email: Submission completed');
$this
->assertNoRaw('Debug: Email: Submission updated');
$this
->assertNoRaw('Debug: Email: Submission deleted');
$this
->assertNoRaw('Debug: Email: Submission custom');
}
}