null, default => (new CronJobExecution('collate-address'))->setLastStart($lastExecution), }; $clock = new MockClock($now); $collator = $this->prophesize(CollateAddressWithReferenceOrPostalCodeInterface::class); $job = new CollateAddressWithReferenceOrPostalCodeCronJob($clock, $collator->reveal()); self::assertEquals($expected, $job->canRun($execution)); } public function testRun(): void { $clock = new MockClock(); $collator = $this->prophesize(CollateAddressWithReferenceOrPostalCodeInterface::class); $collator->__invoke(0)->shouldBeCalledOnce(); $collator->__invoke(0)->willReturn(1); $job = new CollateAddressWithReferenceOrPostalCodeCronJob($clock, $collator->reveal()); $actual = $job->run(['last-max-id' => 0]); self::assertEquals(['last-max-id' => 1], $actual); } public static function provideDataCanRun(): iterable { yield [new \DateTimeImmutable('2023-07-10T12:00:00'), new \DateTimeImmutable('2023-07-10T11:00:00'), false]; yield [new \DateTimeImmutable('2023-07-10T12:00:00'), new \DateTimeImmutable('2023-07-10T05:00:00'), true]; yield [new \DateTimeImmutable('2023-07-10T12:00:00'), new \DateTimeImmutable('2023-07-01T12:00:00'), true]; yield [new \DateTimeImmutable('2023-07-10T12:00:00'), null, true]; } }