Passed
Pull Request — master (#258)
by Alejandro
04:00
created

alwaysReturnsAnEmptyResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioTest\Shlink\Common\IpGeolocation;
5
6
use PHPUnit\Framework\TestCase;
7
use Shlinkio\Shlink\Common\IpGeolocation\EmptyIpLocationResolver;
8
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
9
use function Functional\map;
10
use function range;
11
12
class EmptyIpLocationResolverTest extends TestCase
13
{
14
    use StringUtilsTrait;
15
16
    private const EMPTY_RESP = [
17
        'country_code' => '',
18
        'country_name' => '',
19
        'region_name' => '',
20
        'city' => '',
21
        'latitude' => '',
22
        'longitude' => '',
23
        'time_zone' => '',
24
    ];
25
26
    /**
27
     * @var EmptyIpLocationResolver
28
     */
29
    private $resolver;
30
31
    public function setUp()
32
    {
33
        $this->resolver = new EmptyIpLocationResolver();
34
    }
35
36
    /**
37
     * @test
38
     * @dataProvider provideEmptyResponses
39
     */
40
    public function alwaysReturnsAnEmptyResponse(array $expected, string $ipAddress)
41
    {
42
        $this->assertEquals($expected, $this->resolver->resolveIpLocation($ipAddress));
43
    }
44
45
    public function provideEmptyResponses(): array
46
    {
47
        return map(range(0, 5), function () {
48
            return [self::EMPTY_RESP, $this->generateRandomString(10)];
49
        });
50
    }
51
}
52