You are here

public function EmailedExportTest::testIncludeAttachedFilesWithNativeArchive in Webform Scheduled Tasks 8.2

Test exporting archived files with a format that is already an archive.

File

tests/src/Kernel/EmailedExportTest.php, line 282

Class

EmailedExportTest
Test the email export plugin.

Namespace

Drupal\Tests\webform_scheduled_tasks\Kernel

Code

public function testIncludeAttachedFilesWithNativeArchive() {
  $task = $this
    ->createTestTask([
    'email_addresses' => 'foo@example.com, bar@example.com',
    'storage_type' => EmailedExport::STORAGE_TYPE_FILESYSTEM,
    'exporter' => 'json',
    'exporter_settings' => [
      'file_name' => 'submission-[webform_submission:serial]',
    ],
    'delete_submissions' => TRUE,
    'include_attachments' => TRUE,
  ]);
  $this
    ->createTestSubmissions();
  webform_scheduled_tasks_cron();
  $this
    ->assertFalse($task
    ->isHalted());
  $this
    ->assertCount(2, $this
    ->getMails());
  $archive = new ArchiveTar('private://scheduled-exports/foo.webform_scheduled_task.foo.tar.gz');
  $contents = $archive
    ->listContent();
  $this
    ->assertCount(4, $contents);
  $this
    ->assertEquals('submission-1/test.pdf', $contents[0]['filename']);
  $this
    ->assertEquals('submission-1.json', $contents[1]['filename']);
  $this
    ->assertEquals('submission-2/test.pdf', $contents[2]['filename']);
  $this
    ->assertEquals('submission-2.json', $contents[3]['filename']);
}