prophesize(AccompanyingPeriodStepChangeRequestor::class); $clock = new MockClock($datetime); $cronJob = new AccompanyingPeriodStepChangeCronjob($clock, $requestor->reveal()); $cronJobExecution = (new CronJobExecution($cronJob->getKey()))->setLastStart($lastExecutionStart); $this->assertEquals($canRun, $cronJob->canRun($cronJobExecution)); } public function provideRunTimes(): iterable { // can run, during the night yield ['2023-01-15T01:00:00+02:00', new \DateTimeImmutable('2023-01-14T00:00:00+02:00'), true]; // can not run, not during the night yield ['2023-01-15T10:00:00+02:00', new \DateTimeImmutable('2023-01-14T00:00:00+02:00'), false]; // can not run: not enough elapsed time yield ['2023-01-15T01:00:00+02:00', new \DateTimeImmutable('2023-01-15T00:30:00+02:00'), false]; } }