From 9c6420fe2672ef2ad6afeb02b0f1fffe26cb127c Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 30 Jul 2016 23:01:07 +0200 Subject: [PATCH] Created VisitServiceTest --- module/Core/test/Service/VisitServiceTest.php | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 module/Core/test/Service/VisitServiceTest.php diff --git a/module/Core/test/Service/VisitServiceTest.php b/module/Core/test/Service/VisitServiceTest.php new file mode 100644 index 00000000..2ecf0a45 --- /dev/null +++ b/module/Core/test/Service/VisitServiceTest.php @@ -0,0 +1,49 @@ +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(); + } +}