locator = $this->createMock(VisitLocatorInterface::class); $this->visitToLocation = $this->createMock(VisitToLocationHelperInterface::class); $this->listener = new LocateUnlocatedVisits($this->locator, $this->visitToLocation); } #[Test] public function locatorIsCalledWhenInvoked(): void { $this->locator->expects($this->once())->method('locateUnlocatedVisits')->with($this->listener); ($this->listener)(new GeoLiteDbCreated()); } #[Test] public function visitToLocationHelperIsCalledToGeolocateVisits(): void { $visit = Visit::forBasePath(Visitor::empty()); $location = Location::emptyInstance(); $this->visitToLocation->expects($this->once())->method('resolveVisitLocation')->with($visit)->willReturn( $location, ); $result = $this->listener->geolocateVisit($visit); self::assertSame($location, $result); } }