Move ScheduledTask::findFutureScheduledByType() to ScheduledTasksRepository

Now that all other methods that use ScheduledTask::findByTypeAndStatus()
were moved to ScheduledTasksRepository, we can move
findFutureScheduledByType() as well and delete
ScheduledTask::findByTypeAndStatus().

[MAILPOET-3845]
This commit is contained in:
Rodrigo Primo
2021-10-13 17:23:06 -03:00
committed by Veljko V
parent d841ca7255
commit ba15b9b251
6 changed files with 37 additions and 69 deletions

View File

@@ -53,6 +53,16 @@ class ScheduledTasksRepositoryTest extends \MailPoetTest {
$this->assertSame($expectedResult, $tasks);
}
public function testItCanGetFutureScheduledTasks() {
$expectedResult[] = $this->scheduledTaskFactory->create('test', ScheduledTaskEntity::STATUS_SCHEDULED, Carbon::now()->addDay()); // scheduled (in future)
$this->scheduledTaskFactory->create('test', ScheduledTaskEntity::STATUS_SCHEDULED, Carbon::now()->addDay(), Carbon::now()); // deleted (should not be fetched)
$this->scheduledTaskFactory->create('test', ScheduledTaskEntity::STATUS_SCHEDULED, Carbon::now()->subDay()); // scheduled in past (should not be fetched)
$this->scheduledTaskFactory->create('test', null, Carbon::now()->addDay()); // wrong status (should not be fetched)
$tasks = $this->repository->findFutureScheduledByType('test', 10);
$this->assertSame($expectedResult, $tasks);
}
public function cleanup() {
$this->truncateEntity(ScheduledTaskEntity::class);
}