em = $this->prophesize(EntityManager::class); $this->visitService = new VisitService($this->em->reveal()); } /** * @test */ public function locateVisitPersistsProvidedVisit() { $visit = new Visit(new ShortUrl(''), Visitor::emptyInstance()); $this->em->persist($visit)->shouldBeCalledOnce(); $this->em->flush()->shouldBeCalledOnce(); $this->visitService->locateVisit($visit, new VisitLocation([])); } /** * @test */ public function getUnlocatedVisitsFallbacksToRepository() { $repo = $this->prophesize(VisitRepository::class); $repo->findUnlocatedVisits()->shouldBeCalledOnce(); $this->em->getRepository(Visit::class)->willReturn($repo->reveal())->shouldBeCalledOnce(); $this->visitService->getUnlocatedVisits(); } }