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->equalTo($this->listener)); ($this->listener)(new GeoLiteDbCreated()); } /** @test */ public function visitToLocationHelperIsCalledToGeolocateVisits(): void { $visit = Visit::forBasePath(Visitor::emptyInstance()); $location = Location::emptyInstance(); $this->visitToLocation->expects($this->once())->method('resolveVisitLocation')->with( $this->equalTo($visit), )->willReturn($location); $result = $this->listener->geolocateVisit($visit); self::assertSame($location, $result); } }