repository = $this->createMock(JobRepository::class); $this->processor = $this->createMock(JobProcessorInterface::class); $this->runner = new PendingDataflowRunner($this->repository, $this->processor); } public function testRunPendingDataflows() { $job1 = new Job(); $job2 = new Job(); $this->repository ->expects($this->exactly(3)) ->method('findNextPendingDataflow') ->willReturnOnConsecutiveCalls($job1, $job2, null) ; $matcher = $this->exactly(2); $this->processor ->expects($matcher) ->method('process') ->with($this->callback(fn($arg) => match ($matcher->numberOfInvocations()) { 1 => $arg === $job1, 2 => $arg === $job2, default => false, })) ; $this->runner->runPendingDataflows(); } }