Cleanup export files after some time
[MAILPOET-1894]
This commit is contained in:
23
tests/integration/Cron/Workers/ExportFilesCleanupTest.php
Normal file
23
tests/integration/Cron/Workers/ExportFilesCleanupTest.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user