From c466c487e6126bc1bb08ab31ba839aced6d5ae28 Mon Sep 17 00:00:00 2001 From: Martin Lagler Date: Mon, 19 Jan 2026 12:54:01 +0100 Subject: [PATCH 1/2] Fix doctrine compatibility --- src/Command/DebugTasksCommand.php | 2 +- src/Entity/TaskExecutionRepository.php | 10 +++++----- src/Entity/TaskRepository.php | 10 +++++----- src/Resources/config/doctrine/Task.orm.xml | 2 +- src/Resources/config/doctrine/TaskExecution.orm.xml | 4 ++-- tests/Functional/Command/RunCommandTest.php | 4 ++-- .../Functional/Entity/TaskExecutionRepositoryTest.php | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Command/DebugTasksCommand.php b/src/Command/DebugTasksCommand.php index 4de05e8..2ef8e94 100644 --- a/src/Command/DebugTasksCommand.php +++ b/src/Command/DebugTasksCommand.php @@ -65,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $page = $input->getOption('page'); $pageSize = $input->getOption('page-size'); - $executions = $this->taskExecutionRepository->findAll($page, $pageSize); + $executions = $this->taskExecutionRepository->findAllPaginated($page, $pageSize); $table = new Table($output); $table->setHeaders(['uuid', 'status', 'handler', 'schedule time', 'end time', 'duration']); diff --git a/src/Entity/TaskExecutionRepository.php b/src/Entity/TaskExecutionRepository.php index 3bb6db5..23dd94c 100644 --- a/src/Entity/TaskExecutionRepository.php +++ b/src/Entity/TaskExecutionRepository.php @@ -36,8 +36,8 @@ public function create(TaskInterface $task, \DateTime $scheduleTime) */ public function save(TaskExecutionInterface $execution) { - $this->_em->persist($execution); - $this->_em->flush($execution); + $this->getEntityManager()->persist($execution); + $this->getEntityManager()->flush($execution); return $this; } @@ -47,8 +47,8 @@ public function save(TaskExecutionInterface $execution) */ public function remove(TaskExecutionInterface $execution) { - $this->_em->remove($execution); - $this->_em->flush($execution); + $this->getEntityManager()->remove($execution); + $this->getEntityManager()->flush($execution); return $this; } @@ -56,7 +56,7 @@ public function remove(TaskExecutionInterface $execution) /** * {@inheritdoc} */ - public function findAll($page = 1, $pageSize = null) + public function findAllPaginated(int $page = 1, ?int $pageSize = null): array { $query = $this->createQueryBuilder('e') ->innerJoin('e.task', 't') diff --git a/src/Entity/TaskRepository.php b/src/Entity/TaskRepository.php index 7cf7fb7..dce9625 100644 --- a/src/Entity/TaskRepository.php +++ b/src/Entity/TaskRepository.php @@ -44,8 +44,8 @@ public function findByUuid($uuid) */ public function save(TaskInterface $task) { - $this->_em->persist($task); - $this->_em->flush($task); + $this->getEntityManager()->persist($task); + $this->getEntityManager()->flush($task); return $this; } @@ -55,8 +55,8 @@ public function save(TaskInterface $task) */ public function remove(TaskInterface $task) { - $this->_em->remove($task); - $this->_em->flush($task); + $this->getEntityManager()->remove($task); + $this->getEntityManager()->flush($task); return $this; } @@ -64,7 +64,7 @@ public function remove(TaskInterface $task) /** * {@inheritdoc} */ - public function findAll($page = 1, $pageSize = null): array + public function findAllPaginated(int $page = 1, ?int $pageSize = null): array { $query = $this->createQueryBuilder('t') ->getQuery(); diff --git a/src/Resources/config/doctrine/Task.orm.xml b/src/Resources/config/doctrine/Task.orm.xml index 93a6c12..f9ce763 100644 --- a/src/Resources/config/doctrine/Task.orm.xml +++ b/src/Resources/config/doctrine/Task.orm.xml @@ -18,7 +18,7 @@ - + diff --git a/src/Resources/config/doctrine/TaskExecution.orm.xml b/src/Resources/config/doctrine/TaskExecution.orm.xml index 54ece00..32df8d5 100644 --- a/src/Resources/config/doctrine/TaskExecution.orm.xml +++ b/src/Resources/config/doctrine/TaskExecution.orm.xml @@ -14,13 +14,13 @@ - + - + diff --git a/tests/Functional/Command/RunCommandTest.php b/tests/Functional/Command/RunCommandTest.php index 252cd55..ff70e15 100644 --- a/tests/Functional/Command/RunCommandTest.php +++ b/tests/Functional/Command/RunCommandTest.php @@ -61,7 +61,7 @@ public function testExecute() $this->assertGreaterThan(0, $execution->getDuration()); $this->assertGreaterThanOrEqual($execution->getStartTime(), $execution->getEndTime()); - $result = $this->taskExecutionRepository->findAll(2, 3); + $result = $this->taskExecutionRepository->findAllPaginated(2, 3); $this->assertCount(1, $result); $task = $result[0]->getTask(); @@ -119,7 +119,7 @@ public function testExecuteWithFail() $this->assertGreaterThan(0, $execution->getDuration()); $this->assertGreaterThanOrEqual($execution->getStartTime(), $execution->getEndTime()); - $result = $this->taskExecutionRepository->findAll(2, 3); + $result = $this->taskExecutionRepository->findAllPaginated(2, 3); $this->assertCount(1, $result); $task = $result[0]->getTask(); diff --git a/tests/Functional/Entity/TaskExecutionRepositoryTest.php b/tests/Functional/Entity/TaskExecutionRepositoryTest.php index 6ecc982..e9b76f0 100644 --- a/tests/Functional/Entity/TaskExecutionRepositoryTest.php +++ b/tests/Functional/Entity/TaskExecutionRepositoryTest.php @@ -85,7 +85,7 @@ public function testFindAllPaginated() $executions[$execution->getUuid()] = $execution; } - $result = $this->taskExecutionRepository->findAll(1, 2); + $result = $this->taskExecutionRepository->findAllPaginated(1, 2); $this->assertCount(2, $result); foreach ($result as $item) { @@ -93,7 +93,7 @@ public function testFindAllPaginated() unset($executions[$item->getUuid()]); } - $result = $this->taskExecutionRepository->findAll(2, 2); + $result = $this->taskExecutionRepository->findAllPaginated(2, 2); $this->assertCount(1, $result); foreach ($result as $item) { From 24fd08c5eeb9aeb40747752cba54ca6f76e05d7a Mon Sep 17 00:00:00 2001 From: Martin Lagler Date: Mon, 19 Jan 2026 16:51:57 +0100 Subject: [PATCH 2/2] Update DateTime to DateTimeImmutable --- src/Command/DebugTasksCommand.php | 4 ++-- src/Command/ScheduleSystemTasksCommand.php | 2 +- src/Command/ScheduleTaskCommand.php | 6 +++--- src/Entity/Task.php | 2 +- src/Entity/TaskExecutionRepository.php | 6 +++--- src/Entity/TaskRepository.php | 7 +++---- src/Resources/config/doctrine/Task.orm.xml | 4 ++-- src/Resources/config/doctrine/TaskExecution.orm.xml | 7 +++---- tests/Functional/BaseCommandTestCase.php | 6 +++--- tests/Functional/BaseDatabaseTestCase.php | 4 ++-- tests/Functional/Command/DebugTasksCommandTest.php | 10 +++++----- tests/Functional/Command/RunCommandTest.php | 12 ++++++------ tests/Functional/Command/ScheduleTaskCommandTest.php | 6 +++--- .../Entity/TaskExecutionRepositoryTest.php | 12 ++++++------ .../Unit/Command/ScheduleSystemTasksCommandTest.php | 12 ++++++------ 15 files changed, 49 insertions(+), 51 deletions(-) diff --git a/src/Command/DebugTasksCommand.php b/src/Command/DebugTasksCommand.php index 2ef8e94..3cbd9dc 100644 --- a/src/Command/DebugTasksCommand.php +++ b/src/Command/DebugTasksCommand.php @@ -76,8 +76,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $execution->getUuid(), $execution->getStatus(), $execution->getHandlerClass(), - $execution->getScheduleTime()->format(\DateTime::RFC3339), - !$execution->getEndTime() ? '' : $execution->getEndTime()->format(\DateTime::RFC3339), + $execution->getScheduleTime()->format(\DateTimeImmutable::RFC3339), + !$execution->getEndTime() ? '' : $execution->getEndTime()->format(\DateTimeImmutable::RFC3339), (round($execution->getDuration(), 6) * 1000000) . 'ms', ] ); diff --git a/src/Command/ScheduleSystemTasksCommand.php b/src/Command/ScheduleSystemTasksCommand.php index 808e0ad..6a34388 100644 --- a/src/Command/ScheduleSystemTasksCommand.php +++ b/src/Command/ScheduleSystemTasksCommand.php @@ -177,7 +177,7 @@ private function disableSystemTask($systemKey) */ public function disableTask(TaskInterface $task) { - $task->setInterval($task->getInterval(), $task->getFirstExecution(), new \DateTime()); + $task->setInterval($task->getInterval(), $task->getFirstExecution(), new \DateTimeImmutable()); return $this->abortPending($task); } diff --git a/src/Command/ScheduleTaskCommand.php b/src/Command/ScheduleTaskCommand.php index 16a2fc7..e96da6d 100644 --- a/src/Command/ScheduleTaskCommand.php +++ b/src/Command/ScheduleTaskCommand.php @@ -83,14 +83,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (null !== $cronExpression) { $endDate = null; if (null !== $endDateString) { - $endDate = new \DateTime($endDateString); + $endDate = new \DateTimeImmutable($endDateString); } - $taskBuilder->cron($cronExpression, new \DateTime(), $endDate); + $taskBuilder->cron($cronExpression, new \DateTimeImmutable(), $endDate); } if (null !== $executionDateString) { - $taskBuilder->executeAt(new \DateTime($executionDateString)); + $taskBuilder->executeAt(new \DateTimeImmutable($executionDateString)); } $taskBuilder->schedule(); diff --git a/src/Entity/Task.php b/src/Entity/Task.php index 9dbafa2..d6793f1 100644 --- a/src/Entity/Task.php +++ b/src/Entity/Task.php @@ -52,7 +52,7 @@ public function getInterval() /** * {@inheritdoc} */ - public function setInterval(CronExpression $interval, \DateTime $firstExecution = null, \DateTime $lastExecution = null) + public function setInterval(CronExpression $interval, \DateTimeImmutable $firstExecution = null, \DateTimeImmutable $lastExecution = null) { parent::setInterval($interval, $firstExecution, $lastExecution); diff --git a/src/Entity/TaskExecutionRepository.php b/src/Entity/TaskExecutionRepository.php index 23dd94c..7236008 100644 --- a/src/Entity/TaskExecutionRepository.php +++ b/src/Entity/TaskExecutionRepository.php @@ -26,7 +26,7 @@ class TaskExecutionRepository extends EntityRepository implements TaskExecutionR /** * {@inheritdoc} */ - public function create(TaskInterface $task, \DateTime $scheduleTime) + public function create(TaskInterface $task, \DateTimeImmutable $scheduleTime) { return new TaskExecution($task, $task->getHandlerClass(), $scheduleTime, $task->getWorkload()); } @@ -129,13 +129,13 @@ public function findByTaskUuid($taskUuid) /** * {@inheritdoc} */ - public function findNextScheduled(\DateTime $dateTime = null, array $skippedExecutions = []) + public function findNextScheduled(\DateTimeImmutable $dateTime = null, array $skippedExecutions = []) { $queryBuilder = $this->createQueryBuilder('e') ->innerJoin('e.task', 't') ->where('e.status = :status') ->andWhere('e.scheduleTime < :date') - ->setParameter('date', $dateTime ?: new \DateTime()) + ->setParameter('date', $dateTime ?: new \DateTimeImmutable()) ->setParameter('status', TaskStatus::PLANNED) ->setMaxResults(1); diff --git a/src/Entity/TaskRepository.php b/src/Entity/TaskRepository.php index dce9625..bc93005 100644 --- a/src/Entity/TaskRepository.php +++ b/src/Entity/TaskRepository.php @@ -11,7 +11,6 @@ namespace Task\TaskBundle\Entity; -use DateTime; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\NoResultException; use Task\TaskInterface; @@ -82,17 +81,17 @@ public function findAllPaginated(int $page = 1, ?int $pageSize = null): array */ public function findEndBeforeNow() { - return $this->findEndBefore(new \DateTime()); + return $this->findEndBefore(new \DateTimeImmutable()); } /** * Returns task where last-execution is before given date-time. * - * @param \DateTime $dateTime + * @param \DateTimeImmutable $dateTime * * @return TaskInterface[] */ - public function findEndBefore(\DateTime $dateTime) + public function findEndBefore(\DateTimeImmutable $dateTime) { return $this->createQueryBuilder('t') ->where('t.lastExecution IS NULL OR t.lastExecution > :dateTime') diff --git a/src/Resources/config/doctrine/Task.orm.xml b/src/Resources/config/doctrine/Task.orm.xml index f9ce763..5402595 100644 --- a/src/Resources/config/doctrine/Task.orm.xml +++ b/src/Resources/config/doctrine/Task.orm.xml @@ -15,8 +15,8 @@ - - + + diff --git a/src/Resources/config/doctrine/TaskExecution.orm.xml b/src/Resources/config/doctrine/TaskExecution.orm.xml index 32df8d5..f76bb2b 100644 --- a/src/Resources/config/doctrine/TaskExecution.orm.xml +++ b/src/Resources/config/doctrine/TaskExecution.orm.xml @@ -16,9 +16,9 @@ - - - + + + @@ -27,6 +27,5 @@ - diff --git a/tests/Functional/BaseCommandTestCase.php b/tests/Functional/BaseCommandTestCase.php index 344de77..cf40ee8 100644 --- a/tests/Functional/BaseCommandTestCase.php +++ b/tests/Functional/BaseCommandTestCase.php @@ -102,7 +102,7 @@ protected function createTask($workload, CronExpression $cronExpression = null, { $task = $this->taskRepository->create($handlerClass, $workload); if ($cronExpression) { - $task->setInterval($cronExpression, new \DateTime(), new \DateTime('+1 year')); + $task->setInterval($cronExpression, new \DateTimeImmutable(), new \DateTimeImmutable('+1 year')); } $this->taskRepository->save($task); @@ -113,12 +113,12 @@ protected function createTask($workload, CronExpression $cronExpression = null, * Create task-execution. * * @param TaskInterface $task - * @param \DateTime $scheduleTime + * @param \DateTimeImmutable $scheduleTime * @param string $status * * @return TaskExecutionInterface */ - protected function createTaskExecution(TaskInterface $task, \DateTime $scheduleTime, $status = TaskStatus::PLANNED) + protected function createTaskExecution(TaskInterface $task, \DateTimeImmutable $scheduleTime, $status = TaskStatus::PLANNED) { $execution = $this->taskExecutionRepository->create($task, $scheduleTime); $execution->setStatus($status); diff --git a/tests/Functional/BaseDatabaseTestCase.php b/tests/Functional/BaseDatabaseTestCase.php index 4380eb6..38f7164 100644 --- a/tests/Functional/BaseDatabaseTestCase.php +++ b/tests/Functional/BaseDatabaseTestCase.php @@ -73,12 +73,12 @@ protected function createTask($handlerClass = TestHandler::class) * Create a new task-execution. * * @param TaskInterface $task - * @param \DateTime $scheduleTime + * @param \DateTimeImmutable $scheduleTime * @param string $status * * @return TaskExecution */ - protected function createTaskExecution(TaskInterface $task, \DateTime $scheduleTime, $status = TaskStatus::PLANNED) + protected function createTaskExecution(TaskInterface $task, \DateTimeImmutable $scheduleTime, $status = TaskStatus::PLANNED) { $execution = new TaskExecution($task, $task->getHandlerClass(), $scheduleTime); $execution->setStatus($status); diff --git a/tests/Functional/Command/DebugTasksCommandTest.php b/tests/Functional/Command/DebugTasksCommandTest.php index cd87182..33fe3a5 100644 --- a/tests/Functional/Command/DebugTasksCommandTest.php +++ b/tests/Functional/Command/DebugTasksCommandTest.php @@ -26,8 +26,8 @@ public function testExecute() /** @var TaskExecutionInterface[] $executions */ $executions = [ - $this->createTaskExecution($task, new \DateTime('-1 hour'), TaskStatus::COMPLETED), - $this->createTaskExecution($task, new \DateTime('-2 hour'), TaskStatus::COMPLETED), + $this->createTaskExecution($task, new \DateTimeImmutable('-1 hour'), TaskStatus::COMPLETED), + $this->createTaskExecution($task, new \DateTimeImmutable('-2 hour'), TaskStatus::COMPLETED), ]; $executions[0]->setResult(strrev($executions[0]->getWorkload())); @@ -59,9 +59,9 @@ public function testExecutePaginated() /** @var TaskExecutionInterface[] $executions */ $executions = [ - $this->createTaskExecution($task, new \DateTime('-1 hour')), - $this->createTaskExecution($task, new \DateTime('-2 hour')), - $this->createTaskExecution($task, new \DateTime('+1 hour')), + $this->createTaskExecution($task, new \DateTimeImmutable('-1 hour')), + $this->createTaskExecution($task, new \DateTimeImmutable('-2 hour')), + $this->createTaskExecution($task, new \DateTimeImmutable('+1 hour')), ]; if (self::$kernel->getContainer()->has('doctrine')) { diff --git a/tests/Functional/Command/RunCommandTest.php b/tests/Functional/Command/RunCommandTest.php index ff70e15..ececabc 100644 --- a/tests/Functional/Command/RunCommandTest.php +++ b/tests/Functional/Command/RunCommandTest.php @@ -31,9 +31,9 @@ public function testExecute() /** @var TaskExecutionInterface[] $executions */ $executions = [ - $this->createTaskExecution($singleTask, new \DateTime('-1 hour')), - $this->createTaskExecution($laterTask, new \DateTime('+1 hour')), - $this->createTaskExecution($intervalTask, new \DateTime('-2 hour')), + $this->createTaskExecution($singleTask, new \DateTimeImmutable('-1 hour')), + $this->createTaskExecution($laterTask, new \DateTimeImmutable('+1 hour')), + $this->createTaskExecution($intervalTask, new \DateTimeImmutable('-2 hour')), ]; $this->commandTester->execute( @@ -89,9 +89,9 @@ public function testExecuteWithFail() /** @var TaskExecutionInterface[] $executions */ $executions = [ - $this->createTaskExecution($singleTask, new \DateTime('-1 hour')), - $this->createTaskExecution($laterTask, new \DateTime('+1 hour')), - $this->createTaskExecution($intervalTask, new \DateTime('-2 hour')), + $this->createTaskExecution($singleTask, new \DateTimeImmutable('-1 hour')), + $this->createTaskExecution($laterTask, new \DateTimeImmutable('+1 hour')), + $this->createTaskExecution($intervalTask, new \DateTimeImmutable('-2 hour')), ]; $this->commandTester->execute( diff --git a/tests/Functional/Command/ScheduleTaskCommandTest.php b/tests/Functional/Command/ScheduleTaskCommandTest.php index 2dd3360..e6d0995 100644 --- a/tests/Functional/Command/ScheduleTaskCommandTest.php +++ b/tests/Functional/Command/ScheduleTaskCommandTest.php @@ -77,14 +77,14 @@ public function testExecuteWithWorkloadAndInterval() public function testExecuteWithWorkloadAndIntervalAndEndDate() { - $date = new \DateTime('+1 day'); + $date = new \DateTimeImmutable('+1 day'); $this->commandTester->execute( [ 'command' => $this->command->getName(), 'handlerClass' => TestHandler::class, 'workload' => 'Test workload 1', '--cron-expression' => '0 * * * *', - '--end-date' => $date->format(\DateTime::RFC3339), + '--end-date' => $date->format(\DateTimeImmutable::RFC3339), ] ); @@ -99,7 +99,7 @@ public function testExecuteWithWorkloadAndIntervalAndEndDate() public function testExecuteWithExecutionDate() { - $date = new \DateTime('+1 day'); + $date = new \DateTimeImmutable('+1 day'); $this->commandTester->execute( [ 'command' => $this->command->getName(), diff --git a/tests/Functional/Entity/TaskExecutionRepositoryTest.php b/tests/Functional/Entity/TaskExecutionRepositoryTest.php index e9b76f0..0a94fa2 100644 --- a/tests/Functional/Entity/TaskExecutionRepositoryTest.php +++ b/tests/Functional/Entity/TaskExecutionRepositoryTest.php @@ -152,7 +152,7 @@ public function testFindScheduledPast() $task = $this->createTask(); $this->taskRepository->save($task); - $execution = $this->save($task, new \DateTime('-1 hour')); + $execution = $this->save($task, new \DateTimeImmutable('-1 hour')); $result = $this->taskExecutionRepository->findNextScheduled(); $this->assertEquals($execution->getUuid(), $result->getUuid()); @@ -163,7 +163,7 @@ public function testFindScheduledFuture() $task = $this->createTask(); $this->taskRepository->save($task); - $this->save($task, new \DateTime('+1 hour')); + $this->save($task, new \DateTimeImmutable('+1 hour')); $this->assertNull($this->taskExecutionRepository->findNextScheduled()); } @@ -173,7 +173,7 @@ public function testFindScheduledSkipped() $task = $this->createTask(); $this->taskRepository->save($task); - $this->save($task, new \DateTime('+1 hour')); + $this->save($task, new \DateTimeImmutable('+1 hour')); $this->assertNull($this->taskExecutionRepository->findNextScheduled()); } @@ -182,15 +182,15 @@ public function testFindScheduledSkipped() * Save a new execution to database. * * @param TaskInterface $task - * @param \DateTime $scheduleTime + * @param \DateTimeImmutable $scheduleTime * @param string $status * * @return TaskExecutionInterface */ - private function save(TaskInterface $task = null, \DateTime $scheduleTime = null, $status = TaskStatus::PLANNED) + private function save(TaskInterface $task = null, \DateTimeImmutable $scheduleTime = null, $status = TaskStatus::PLANNED) { if (!$scheduleTime) { - $scheduleTime = new \DateTime(); + $scheduleTime = new \DateTimeImmutable(); } if (!$task) { diff --git a/tests/Unit/Command/ScheduleSystemTasksCommandTest.php b/tests/Unit/Command/ScheduleSystemTasksCommandTest.php index 6a53b51..7df9b47 100644 --- a/tests/Unit/Command/ScheduleSystemTasksCommandTest.php +++ b/tests/Unit/Command/ScheduleSystemTasksCommandTest.php @@ -158,7 +158,7 @@ public function testExecuteDisable() $task = $this->prophesize(Task::class); $task->getInterval()->willReturn(CronExpression::factory('* * * * *')); - $task->getFirstExecution()->willReturn(new \DateTime()); + $task->getFirstExecution()->willReturn(new \DateTimeImmutable()); $task->getSystemKey()->willReturn('testing'); $task->setInterval( @@ -166,7 +166,7 @@ public function testExecuteDisable() $task->reveal()->getFirstExecution(), Argument::that( function ($date) { - return $date <= new \DateTime('+1 Minute'); + return $date <= new \DateTimeImmutable('+1 Minute'); } ) )->shouldBeCalled(); @@ -204,7 +204,7 @@ public function testExecuteUpdate() $task->getHandlerClass()->willReturn(TestHandler::class); $task->getWorkload()->willReturn('test'); $task->getInterval()->willReturn(CronExpression::factory('@daily')); - $task->getFirstExecution()->willReturn(new \DateTime()); + $task->getFirstExecution()->willReturn(new \DateTimeImmutable()); $task->setInterval(CronExpression::factory('* * * * *'), $task->reveal()->getFirstExecution())->shouldBeCalled( ); @@ -244,7 +244,7 @@ public function testExecuteUpdateNotSupported() $task->getHandlerClass()->willReturn('not-existing'); $task->getWorkload()->willReturn('new-workload'); $task->getInterval()->willReturn(CronExpression::factory('@daily')); - $task->getFirstExecution()->willReturn(new \DateTime()); + $task->getFirstExecution()->willReturn(new \DateTimeImmutable()); $task->setInterval(Argument::cetera())->shouldNotBeCalled(); @@ -267,7 +267,7 @@ public function testExecuteRemove() $task = $this->prophesize(Task::class); $task->getInterval()->willReturn(CronExpression::factory('* * * * *')); - $task->getFirstExecution()->willReturn(new \DateTime()); + $task->getFirstExecution()->willReturn(new \DateTimeImmutable()); $task->getSystemKey()->willReturn('testing'); $task->setInterval( @@ -275,7 +275,7 @@ public function testExecuteRemove() $task->reveal()->getFirstExecution(), Argument::that( function ($date) { - return $date <= new \DateTime('+1 Minute'); + return $date <= new \DateTimeImmutable('+1 Minute'); } ) )->shouldBeCalled();