Update queue counts or delete scheduled task

[MAILPOET-3782]
This commit is contained in:
Rostislav Wolny
2021-10-06 10:35:29 +02:00
committed by Veljko V
parent bafb41c94e
commit 9aae441d99
2 changed files with 39 additions and 9 deletions

View File

@@ -59,6 +59,12 @@ class ReEngagementSchedulerTest extends \MailPoetTest {
expect($scheduled)->count(0);
}
public function testItDoesntScheduleAnythingIfThereAreNoSubscribersToSendTo() {
$this->createReEngagementEmail(5);
$scheduled = $this->scheduler->scheduleAll();
expect($scheduled)->count(0);
}
public function testItScheduleEmailWithCorrectSubscribers() {
$beforeCheckInterval = Carbon::now();
$beforeCheckInterval->subMonths(10);
@@ -119,6 +125,12 @@ class ReEngagementSchedulerTest extends \MailPoetTest {
$this->assertInstanceOf(\DateTimeInterface::class, $scheduledAt);
expect($scheduledAt->getTimestamp())->equals(Carbon::now()->getTimestamp(), 1);
expect($task->getSubscribers()->count())->equals(2);
$sendingQueue = $this->entityManager->getRepository(SendingQueueEntity::class)->findOneBy(['task' => $task]);
$this->assertInstanceOf(SendingQueueEntity::class, $sendingQueue);
expect($sendingQueue->getCountToProcess())->equals(2);
expect($sendingQueue->getCountTotal())->equals(2);
expect($sendingQueue->getCountProcessed())->equals(0);
}
private function createReEngagementEmail(int $monthsAfter, string $status = NewsletterEntity::STATUS_ACTIVE) {