em = $this->prophesize(EntityManager::class); $this->visitService = new VisitService($this->em->reveal()); } /** * @test */ public function saveVisitsPersistsProvidedVisit() { $visit = new Visit(); $this->em->persist($visit)->shouldBeCalledTimes(1); $this->em->flush()->shouldBeCalledTimes(1); $this->visitService->saveVisit($visit); } /** * @test */ public function getUnlocatedVisitsFallbacksToRepository() { $repo = $this->prophesize(VisitRepository::class); $repo->findUnlocatedVisits()->shouldBeCalledTimes(1); $this->em->getRepository(Visit::class)->willReturn($repo->reveal())->shouldBeCalledTimes(1); $this->visitService->getUnlocatedVisits(); } }