|
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
|
|
|
|