mirror of
https://github.com/shlinkio/shlink.git
synced 2024-10-23 04:35:34 +03:00
Added test covering case in which the original address is provided when locating visits
This commit is contained in:
parent
3fef4b4a28
commit
fdd8efc12d
1 changed files with 13 additions and 4 deletions
|
@ -130,13 +130,16 @@ class LocateShortUrlVisitTest extends TestCase
|
||||||
yield 'localhost' => [new Visit($shortUrl, new Visitor('', '', IpAddress::LOCALHOST))];
|
yield 'localhost' => [new Visit($shortUrl, new Visitor('', '', IpAddress::LOCALHOST))];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
/**
|
||||||
public function locatableVisitsResolveToLocation(): void
|
* @test
|
||||||
|
* @dataProvider provideIpAddresses
|
||||||
|
*/
|
||||||
|
public function locatableVisitsResolveToLocation(string $anonymizedIpAddress, ?string $originalIpAddress): void
|
||||||
{
|
{
|
||||||
$ipAddr = '1.2.3.0';
|
$ipAddr = $originalIpAddress ?? $anonymizedIpAddress;
|
||||||
$visit = new Visit(new ShortUrl(''), new Visitor('', '', $ipAddr));
|
$visit = new Visit(new ShortUrl(''), new Visitor('', '', $ipAddr));
|
||||||
$location = new Location('', '', '', '', 0.0, 0.0, '');
|
$location = new Location('', '', '', '', 0.0, 0.0, '');
|
||||||
$event = new ShortUrlVisited('123');
|
$event = new ShortUrlVisited('123', $originalIpAddress);
|
||||||
|
|
||||||
$findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
|
$findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
|
||||||
$flush = $this->em->flush()->will(function (): void {
|
$flush = $this->em->flush()->will(function (): void {
|
||||||
|
@ -155,6 +158,12 @@ class LocateShortUrlVisitTest extends TestCase
|
||||||
$dispatch->shouldHaveBeenCalledOnce();
|
$dispatch->shouldHaveBeenCalledOnce();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function provideIpAddresses(): iterable
|
||||||
|
{
|
||||||
|
yield 'no original IP address' => ['1.2.3.0', null];
|
||||||
|
yield 'original IP address' => ['1.2.3.0', '1.2.3.4'];
|
||||||
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function errorWhenUpdatingGeoLiteWithExistingCopyLogsWarning(): void
|
public function errorWhenUpdatingGeoLiteWithExistingCopyLogsWarning(): void
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue