Reschedules past due scheduled queues when reactivating notification

This commit is contained in:
Vlad
2017-08-24 20:57:43 -04:00
committed by pavel-mailpoet
parent 544bf0ddfd
commit c1e542cb5a
4 changed files with 85 additions and 7 deletions

View File

@@ -25,7 +25,7 @@ class SchedulerTest extends \MailPoetTest {
function testItGetsActiveNewslettersFilteredByType() {
$newsletter = $this->_createNewsletter($type = Newsletter::TYPE_WELCOME);
// no newsletters wtih type "notification" should be found
// no newsletters with type "notification" should be found
expect(Scheduler::getNewsletters(Newsletter::TYPE_NOTIFICATION))->isEmpty();
// one newsletter with type "welcome" should be found
@@ -41,6 +41,15 @@ class SchedulerTest extends \MailPoetTest {
expect(Scheduler::getNextRunDate('invalid CRON expression'))->false();
}
function testItCanGetPreviousRunDate() {
// it accepts cron syntax and returns previous run date
$current_time = Carbon::createFromTimestamp(current_time('timestamp'));
expect(Scheduler::getPreviousRunDate('* * * * *'))
->equals($current_time->subMinute()->format('Y-m-d H:i:00'));
// when invalid CRON expression is used, false response is returned
expect(Scheduler::getPreviousRunDate('invalid CRON expression'))->false();
}
function testItFormatsDatetimeString() {
expect(Scheduler::formatDatetimeString('April 20, 2016 4pm'))
->equals('2016-04-20 16:00:00');