mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 17:44:44 +08:00
Created new listener to update the GeoLite db after a visit occurs
This commit is contained in:
@@ -226,67 +226,4 @@ class LocateVisitTest extends TestCase
|
||||
yield 'invalid short url' => [Visit::forInvalidShortUrl(new Visitor('', '', '1.2.3.4', '')), '1.2.3.4'];
|
||||
yield 'regular not found' => [Visit::forRegularNotFound(new Visitor('', '', '1.2.3.4', '')), '1.2.3.4'];
|
||||
}
|
||||
|
||||
// /** @test */
|
||||
// public function errorWhenUpdatingGeoLiteWithExistingCopyLogsWarning(): void
|
||||
// {
|
||||
// $e = GeolocationDbUpdateFailedException::withOlderDb();
|
||||
// $ipAddr = '1.2.3.0';
|
||||
// $visit = Visit::forValidShortUrl(ShortUrl::createEmpty(), new Visitor('', '', $ipAddr, ''));
|
||||
// $location = new Location('', '', '', '', 0.0, 0.0, '');
|
||||
// $event = new UrlVisited('123');
|
||||
//
|
||||
// $findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
|
||||
// $flush = $this->em->flush()->will(function (): void {
|
||||
// });
|
||||
// $resolveIp = $this->ipLocationResolver->resolveIpLocation($ipAddr)->willReturn($location);
|
||||
// $checkUpdateDb = $this->dbUpdater->checkDbUpdate(Argument::cetera())->willThrow($e);
|
||||
// $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function (): void {
|
||||
// });
|
||||
//
|
||||
// ($this->locateVisit)($event);
|
||||
//
|
||||
// self::assertEquals($visit->getVisitLocation(), new VisitLocation($location));
|
||||
// $findVisit->shouldHaveBeenCalledOnce();
|
||||
// $flush->shouldHaveBeenCalledOnce();
|
||||
// $resolveIp->shouldHaveBeenCalledOnce();
|
||||
// $checkUpdateDb->shouldHaveBeenCalledOnce();
|
||||
// $this->logger->warning(
|
||||
// 'GeoLite2 database update failed. Proceeding with old version. {e}',
|
||||
// ['e' => $e],
|
||||
// )->shouldHaveBeenCalledOnce();
|
||||
// $dispatch->shouldHaveBeenCalledOnce();
|
||||
// }
|
||||
//
|
||||
// /** @test */
|
||||
// public function errorWhenDownloadingGeoLiteCancelsLocation(): void
|
||||
// {
|
||||
// $e = GeolocationDbUpdateFailedException::withoutOlderDb();
|
||||
// $ipAddr = '1.2.3.0';
|
||||
// $visit = Visit::forValidShortUrl(ShortUrl::createEmpty(), new Visitor('', '', $ipAddr, ''));
|
||||
// $location = new Location('', '', '', '', 0.0, 0.0, '');
|
||||
// $event = new UrlVisited('123');
|
||||
//
|
||||
// $findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
|
||||
// $flush = $this->em->flush()->will(function (): void {
|
||||
// });
|
||||
// $resolveIp = $this->ipLocationResolver->resolveIpLocation($ipAddr)->willReturn($location);
|
||||
// $checkUpdateDb = $this->dbUpdater->checkDbUpdate(Argument::cetera())->willThrow($e);
|
||||
// $logError = $this->logger->error(
|
||||
// 'GeoLite2 database download failed. It is not possible to locate visit with id {visitId}. {e}',
|
||||
// ['e' => $e, 'visitId' => 123],
|
||||
// );
|
||||
// $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function (): void {
|
||||
// });
|
||||
//
|
||||
// ($this->locateVisit)($event);
|
||||
//
|
||||
// self::assertNull($visit->getVisitLocation());
|
||||
// $findVisit->shouldHaveBeenCalledOnce();
|
||||
// $flush->shouldNotHaveBeenCalled();
|
||||
// $resolveIp->shouldNotHaveBeenCalled();
|
||||
// $checkUpdateDb->shouldHaveBeenCalledOnce();
|
||||
// $logError->shouldHaveBeenCalledOnce();
|
||||
// $dispatch->shouldHaveBeenCalledOnce();
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user