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