shlink/module/Common/test/IpGeolocation/EmptyIpLocationResolverTest.php

42 lines
1 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\IpGeolocation;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Common\IpGeolocation\EmptyIpLocationResolver;
use Shlinkio\Shlink\Common\IpGeolocation\Model\Location;
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
use function Functional\map;
use function range;
class EmptyIpLocationResolverTest extends TestCase
{
use StringUtilsTrait;
/** @var EmptyIpLocationResolver */
private $resolver;
2019-02-16 12:53:45 +03:00
public function setUp(): void
{
$this->resolver = new EmptyIpLocationResolver();
}
/**
* @test
* @dataProvider provideEmptyResponses
*/
2019-02-17 22:28:34 +03:00
public function alwaysReturnsAnEmptyLocation(string $ipAddress): void
{
$this->assertEquals(Location::emptyInstance(), $this->resolver->resolveIpLocation($ipAddress));
}
public function provideEmptyResponses(): array
{
return map(range(0, 5), function () {
return [$this->generateRandomString(15)];
});
}
}