Passed
Pull Request — master (#454)
by Alejandro
06:56
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\IpGeolocation\Resolver;
5
6
use PHPUnit\Framework\TestCase;
7
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
8
use Shlinkio\Shlink\IpGeolocation\Model\Location;
9
use Shlinkio\Shlink\IpGeolocation\Resolver\EmptyIpLocationResolver;
10
11
use function Functional\map;
12
use function range;
13
14
class EmptyIpLocationResolverTest extends TestCase
15
{
16
    use StringUtilsTrait;
17
18
    /** @var EmptyIpLocationResolver */
19
    private $resolver;
20
21
    public function setUp(): void
22
    {
23
        $this->resolver = new EmptyIpLocationResolver();
24
    }
25
26
    /**
27
     * @test
28
     * @dataProvider provideEmptyResponses
29
     */
30
    public function alwaysReturnsAnEmptyLocation(string $ipAddress): void
31
    {
32
        $this->assertEquals(Location::emptyInstance(), $this->resolver->resolveIpLocation($ipAddress));
33
    }
34
35
    public function provideEmptyResponses(): array
36
    {
37
        return map(range(0, 5), function () {
38
            return [$this->generateRandomString(15)];
39
        });
40
    }
41
}
42