Fix bug when changing ScheduledTask in_progress field
In3394568
, SendingQueue::stopProgress() was refactored to use Doctrine but a typo introduced a bug causing this method to set ScheduledTaskEntity::inProgress to true instead of false:3394568792 (diff-3a26b2d8faf9cc01efd5aef47b058c088c0de01b8074c3be7cefd9adb77fbaaaR551)
This luckly was caught by the EditorCouponCest.php:seeNoticeWhenCouponCantGenerateAndResumeSending acceptance test. This commit fixes the problem and also adds two integration tests to protect against similar regressions in the future. [MAILPOET-5682]
This commit is contained in:
@@ -559,7 +559,7 @@ class SendingQueue {
|
||||
}
|
||||
|
||||
private function stopProgress(ScheduledTaskEntity $task): void {
|
||||
$task->setInProgress(true);
|
||||
$task->setInProgress(false);
|
||||
$this->scheduledTasksRepository->flush();
|
||||
}
|
||||
|
||||
|
@@ -1393,6 +1393,31 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
verify($newsletter->getStatus())->equals(NewsletterEntity::STATUS_SENDING);
|
||||
}
|
||||
|
||||
public function testProcessMarksScheduledTaskInProgressAsFalseWhenProperlyProcessingTask() {
|
||||
$sendingQueueWorker = $this->getSendingQueueWorker();
|
||||
$sendingQueueWorker->process();
|
||||
$this->assertSame(false, $this->scheduledTask->getInProgress());
|
||||
}
|
||||
|
||||
public function testProcessMarksScheduledTaskProgressAsFinishedWhenThereIsAnErrorProcessingTask() {
|
||||
$mailerTask = $this->createMock(MailerTask::class);
|
||||
$mailerTask
|
||||
->method('send')
|
||||
->willThrowException(new \Exception());
|
||||
$mailerTask
|
||||
->method('getProcessingMethod')
|
||||
->willReturn('individual');
|
||||
$sendingQueueWorker = $this->getSendingQueueWorker($mailerTask);
|
||||
|
||||
try {
|
||||
$sendingQueueWorker->process();
|
||||
} catch (\Exception $e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
$this->assertSame(false, $this->scheduledTask->getInProgress());
|
||||
}
|
||||
|
||||
private function createNewsletter(string $type, $subject, string $status = NewsletterEntity::STATUS_DRAFT): NewsletterEntity {
|
||||
$newsletter = new NewsletterEntity();
|
||||
$newsletter->setType($type);
|
||||
|
Reference in New Issue
Block a user