Completed
Push — master ( c70077...3d32a9 )
by Alejandro
16s queued 10s
created

VisitLocationTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 16
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A valuesFoundWhenExchangingArrayAreCastToString() 0 7 1
A isEmptyReturnsTrueWhenAllValuesAreEmpty() 0 6 1
A provideArgs() 0 10 1
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioTest\Shlink\Core\Entity;
5
6
use PHPUnit\Framework\TestCase;
7
use Shlinkio\Shlink\Common\IpGeolocation\Model\Location;
8
use Shlinkio\Shlink\Core\Entity\VisitLocation;
9
10
class VisitLocationTest extends TestCase
11
{
12
    /** @test */
13
    public function valuesFoundWhenExchangingArrayAreCastToString(): void
14
    {
15
        $payload = new Location('', '', '', '', 1000.7, -2000.4, '');
16
        $location = new VisitLocation($payload);
17
18
        $this->assertSame('1000.7', $location->getLatitude());
19
        $this->assertSame('-2000.4', $location->getLongitude());
20
    }
21
22
    /**
23
     * @test
24
     * @dataProvider provideArgs
25
     */
26
    public function isEmptyReturnsTrueWhenAllValuesAreEmpty(array $args, bool $isEmpty): void
27
    {
28
        $payload = new Location(...$args);
29
        $location = new VisitLocation($payload);
30
31
        $this->assertEquals($isEmpty, $location->isEmpty());
32
    }
33
34
    public function provideArgs(): iterable
35
    {
36
        yield [['', '', '', '', 0.0, 0.0, ''], true];
37
        yield [['', '', '', '', 0.0, 0.0, 'dd'], false];
38
        yield [['', '', '', 'dd', 0.0, 0.0, ''], false];
39
        yield [['', '', 'dd', '', 0.0, 0.0, ''], false];
40
        yield [['', 'dd', '', '', 0.0, 0.0, ''], false];
41
        yield [['dd', '', '', '', 0.0, 0.0, ''], false];
42
        yield [['', '', '', '', 1.0, 0.0, ''], false];
43
        yield [['', '', '', '', 0.0, 1.0, ''], false];
44
    }
45
}
46