Passed
Pull Request — master (#359)
by Alejandro
05:46
created

EmptyIpLocationResolverTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 25
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A provideEmptyResponses() 0 4 1
A setUp() 0 3 1
A alwaysReturnsAnEmptyLocation() 0 3 1
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\IpGeolocation\Model\Location;
9
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
10
use function Functional\map;
11
use function range;
12
13
class EmptyIpLocationResolverTest extends TestCase
14
{
15
    use StringUtilsTrait;
16
17
    /** @var EmptyIpLocationResolver */
18
    private $resolver;
19
20
    public function setUp(): void
21
    {
22
        $this->resolver = new EmptyIpLocationResolver();
23
    }
24
25
    /**
26
     * @test
27
     * @dataProvider provideEmptyResponses
28
     */
29
    public function alwaysReturnsAnEmptyLocation(string $ipAddress): void
30
    {
31
        $this->assertEquals(Location::emptyInstance(), $this->resolver->resolveIpLocation($ipAddress));
32
    }
33
34
    public function provideEmptyResponses(): array
35
    {
36
        return map(range(0, 5), function () {
37
            return [$this->generateRandomString(15)];
38
        });
39
    }
40
}
41