mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-17 00:22:10 +03:00
52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
|
<?php
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace ShlinkioTest\Shlink\Common\IpGeolocation;
|
||
|
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
use Shlinkio\Shlink\Common\IpGeolocation\EmptyIpLocationResolver;
|
||
|
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
|
||
|
use function Functional\map;
|
||
|
use function range;
|
||
|
|
||
|
class EmptyIpLocationResolverTest extends TestCase
|
||
|
{
|
||
|
use StringUtilsTrait;
|
||
|
|
||
|
private const EMPTY_RESP = [
|
||
|
'country_code' => '',
|
||
|
'country_name' => '',
|
||
|
'region_name' => '',
|
||
|
'city' => '',
|
||
|
'latitude' => '',
|
||
|
'longitude' => '',
|
||
|
'time_zone' => '',
|
||
|
];
|
||
|
|
||
|
/**
|
||
|
* @var EmptyIpLocationResolver
|
||
|
*/
|
||
|
private $resolver;
|
||
|
|
||
|
public function setUp()
|
||
|
{
|
||
|
$this->resolver = new EmptyIpLocationResolver();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @test
|
||
|
* @dataProvider provideEmptyResponses
|
||
|
*/
|
||
|
public function alwaysReturnsAnEmptyResponse(array $expected, string $ipAddress)
|
||
|
{
|
||
|
$this->assertEquals($expected, $this->resolver->resolveIpLocation($ipAddress));
|
||
|
}
|
||
|
|
||
|
public function provideEmptyResponses(): array
|
||
|
{
|
||
|
return map(range(0, 5), function () {
|
||
|
return [self::EMPTY_RESP, $this->generateRandomString(10)];
|
||
|
});
|
||
|
}
|
||
|
}
|