Cleanup export files after some time

[MAILPOET-1894]
This commit is contained in:
Pavel Dohnal
2019-04-01 15:00:50 +02:00
committed by M. Shull
parent 9500c1b5d5
commit 08a3a66f4c
7 changed files with 75 additions and 4 deletions

View File

@@ -0,0 +1,23 @@
<?php
namespace MailPoet\Test\Cron\Workers;
use MailPoet\Cron\Workers\ExportFilesCleanup;
use MailPoet\Models\ScheduledTask;
class ExportFilesCleanupTest extends \MailPoetTest {
function testItWorks() {
$wp_upload_dir = wp_upload_dir();
$old_file_path = $wp_upload_dir['basedir'] . '/mailpoet/MailPoet_export_old_file.csv';
$new_file_path = $wp_upload_dir['basedir'] . '/mailpoet/MailPoet_export_new_file.csv';
touch($old_file_path, time() - (60 * 60 * 24 * 7));
touch($new_file_path);
$cleanup = new ExportFilesCleanup();
$cleanup->processTaskStrategy(ScheduledTask::createOrUpdate([]));
$this->assertFileExists($new_file_path);
$this->assertFileNotExists($old_file_path);
}
}