repository = $this->createMock(JobRepository::class); $this->processor = $this->createMock(JobProcessorInterface::class); $this->handler = new JobMessageHandler($this->repository, $this->processor); } public function testInvoke() { $message = new JobMessage($id = 32); $this->repository ->expects($this->once()) ->method('find') ->with($id) ->willReturn($job = new Job()) ; $this->processor ->expects($this->once()) ->method('process') ->with($job) ; ($this->handler)($message); } }