locator = $this->prophesize(VisitLocatorInterface::class); $this->visitToLocation = $this->prophesize(VisitToLocationHelperInterface::class); $this->listener = new LocateUnlocatedVisits($this->locator->reveal(), $this->visitToLocation->reveal()); } /** @test */ public function locatorIsCalledWhenInvoked(): void { ($this->listener)(new GeoLiteDbCreated()); $this->locator->locateUnlocatedVisits($this->listener)->shouldHaveBeenCalledOnce(); } /** @test */ public function visitToLocationHelperIsCalledToGeolocateVisits(): void { $visit = Visit::forBasePath(Visitor::emptyInstance()); $location = Location::emptyInstance(); $resolve = $this->visitToLocation->resolveVisitLocation($visit)->willReturn($location); $result = $this->listener->geolocateVisit($visit); self::assertSame($location, $result); $resolve->shouldHaveBeenCalledOnce(); } }