2018-10-16 11:21:51 -05:00
|
|
|
<?php
|
2019-10-05 10:26:10 -05:00
|
|
|
|
2018-10-16 11:21:51 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2022-09-23 12:03:32 -05:00
|
|
|
namespace ShlinkioTest\Shlink\Core\Visit\Entity;
|
2018-10-16 11:21:51 -05:00
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2022-09-23 12:03:32 -05:00
|
|
|
use Shlinkio\Shlink\Core\Visit\Entity\VisitLocation;
|
2019-08-10 06:42:37 -05:00
|
|
|
use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
2018-10-16 11:21:51 -05:00
|
|
|
|
|
|
|
class VisitLocationTest extends TestCase
|
|
|
|
{
|
2019-02-26 15:39:26 -06:00
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @dataProvider provideArgs
|
|
|
|
*/
|
|
|
|
public function isEmptyReturnsTrueWhenAllValuesAreEmpty(array $args, bool $isEmpty): void
|
|
|
|
{
|
|
|
|
$payload = new Location(...$args);
|
2021-04-10 16:24:01 -05:00
|
|
|
$location = VisitLocation::fromGeolocation($payload);
|
2019-02-26 15:39:26 -06:00
|
|
|
|
2020-10-03 17:35:14 -05:00
|
|
|
self::assertEquals($isEmpty, $location->isEmpty());
|
2019-02-26 15:39:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
public function provideArgs(): iterable
|
|
|
|
{
|
|
|
|
yield [['', '', '', '', 0.0, 0.0, ''], true];
|
|
|
|
yield [['', '', '', '', 0.0, 0.0, 'dd'], false];
|
|
|
|
yield [['', '', '', 'dd', 0.0, 0.0, ''], false];
|
|
|
|
yield [['', '', 'dd', '', 0.0, 0.0, ''], false];
|
|
|
|
yield [['', 'dd', '', '', 0.0, 0.0, ''], false];
|
|
|
|
yield [['dd', '', '', '', 0.0, 0.0, ''], false];
|
|
|
|
yield [['', '', '', '', 1.0, 0.0, ''], false];
|
|
|
|
yield [['', '', '', '', 0.0, 1.0, ''], false];
|
|
|
|
}
|
2018-10-16 11:21:51 -05:00
|
|
|
}
|