Migrate methods findDueByType() and findRunningByType() to Doctrine

[MAILPOET-2996]
This commit is contained in:
Rodrigo Primo
2021-09-16 15:16:00 -03:00
committed by Veljko V
parent 252197d0d7
commit 65eef3dfbe
6 changed files with 113 additions and 81 deletions

View File

@@ -181,74 +181,6 @@ class ScheduledTaskTest extends \MailPoetTest {
expect($timeout)->equals(ScheduledTask::MAX_RESCHEDULE_TIMEOUT);
}
public function testItCanGetDueTasks() {
// due (scheduled in past)
ScheduledTask::createOrUpdate([
'type' => 'test',
'status' => ScheduledTask::STATUS_SCHEDULED,
'scheduled_at' => Carbon::now()->subDay(),
]);
// deleted (should not be fetched)
ScheduledTask::createOrUpdate([
'type' => 'test',
'status' => ScheduledTask::STATUS_SCHEDULED,
'scheduled_at' => Carbon::now()->subDay(),
'deleted_at' => Carbon::now(),
]);
// scheduled in future (should not be fetched)
ScheduledTask::createOrUpdate([
'type' => 'test',
'status' => ScheduledTask::STATUS_SCHEDULED,
'scheduled_at' => Carbon::now()->addDay(),
]);
// wrong status (should not be fetched)
ScheduledTask::createOrUpdate([
'type' => 'test',
'status' => null,
'scheduled_at' => Carbon::now()->subDay(),
]);
$tasks = ScheduledTask::findDueByType('test', 10);
expect($tasks)->count(1);
}
public function testItCanGetRunningTasks() {
// running (scheduled in past)
ScheduledTask::createOrUpdate([
'type' => 'test',
'status' => null,
'scheduled_at' => Carbon::now()->subDay(),
]);
// deleted (should not be fetched)
ScheduledTask::createOrUpdate([
'type' => 'test',
'status' => null,
'scheduled_at' => Carbon::now()->subDay(),
'deleted_at' => Carbon::now(),
]);
// scheduled in future (should not be fetched)
ScheduledTask::createOrUpdate([
'type' => 'test',
'status' => null,
'scheduled_at' => Carbon::now()->addDay(),
]);
// wrong status (should not be fetched)
ScheduledTask::createOrUpdate([
'type' => 'test',
'status' => ScheduledTask::STATUS_COMPLETED,
'scheduled_at' => Carbon::now()->subDay(),
]);
$tasks = ScheduledTask::findRunningByType('test', 10);
expect($tasks)->count(1);
}
public function testItCanGetCompletedTasks() {
// completed (scheduled in past)
ScheduledTask::createOrUpdate([