public function EmailedExportTest::testSendExportAsEmailAttachment in Webform Scheduled Tasks 8.2
Test the task when emails are sent as attachments.
File
- tests/
src/ Kernel/ EmailedExportTest.php, line 346
Class
- EmailedExportTest
- Test the email export plugin.
Namespace
Drupal\Tests\webform_scheduled_tasks\KernelCode
public function testSendExportAsEmailAttachment() {
$this
->createTestTask([
'email_addresses' => 'foo@example.com, bar@example.com',
'storage_type' => EmailedExport::STORAGE_TYPE_EMAIL,
'exporter' => 'delimited_text',
'exporter_settings' => [
'delimiter' => '|',
'excel' => TRUE,
],
'include_attachments' => FALSE,
'delete_submissions' => FALSE,
]);
$this
->createTestSubmissions();
webform_scheduled_tasks_cron();
$mail = $this
->getMails();
$this
->assertCount(2, $mail);
// Ensure the attachment information was included in the email params.
$this
->assertEquals('foo.webform_scheduled_task.foo.csv', $mail[0]['params']['attachments'][0]['filename']);
$this
->assertEquals('text/csv', $mail[0]['params']['attachments'][0]['filemime']);
$this
->assertStringContainsString('scheduled-exports/foo.webform_scheduled_task.foo.csv', $mail[0]['params']['attachments'][0]['filepath']);
$this
->assertStringContainsString('FOO SUBMISSION CONTENT', $mail[0]['params']['attachments'][0]['filecontent']);
$this
->assertStringContainsString('BAR SUBMISSION CONTENT', $mail[0]['params']['attachments'][0]['filecontent']);
// The file should still be saved to the private filesystem as a backup.
$this
->assertFileExists('private://scheduled-exports/foo.webform_scheduled_task.foo.csv');
}