2018-10-16 18:21:51 +02:00
|
|
|
<?php
|
2019-10-05 17:26:10 +02:00
|
|
|
|
2018-10-16 18:21:51 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2022-09-23 19:03:32 +02:00
|
|
|
namespace ShlinkioTest\Shlink\Core\Visit\Entity;
|
2018-10-16 18:21:51 +02:00
|
|
|
|
2023-02-09 20:42:18 +01:00
|
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
|
|
|
use PHPUnit\Framework\Attributes\Test;
|
2018-10-16 18:21:51 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2022-09-23 19:03:32 +02:00
|
|
|
use Shlinkio\Shlink\Core\Visit\Entity\VisitLocation;
|
2019-08-10 13:42:37 +02:00
|
|
|
use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
2018-10-16 18:21:51 +02:00
|
|
|
|
|
|
|
|
class VisitLocationTest extends TestCase
|
|
|
|
|
{
|
2023-02-09 20:42:18 +01:00
|
|
|
#[Test, DataProvider('provideArgs')]
|
2019-02-26 22:39:26 +01:00
|
|
|
public function isEmptyReturnsTrueWhenAllValuesAreEmpty(array $args, bool $isEmpty): void
|
|
|
|
|
{
|
|
|
|
|
$payload = new Location(...$args);
|
2021-04-10 23:24:01 +02:00
|
|
|
$location = VisitLocation::fromGeolocation($payload);
|
2019-02-26 22:39:26 +01:00
|
|
|
|
2024-03-18 19:11:42 +01:00
|
|
|
self::assertEquals($isEmpty, $location->isEmpty);
|
2019-02-26 22:39:26 +01:00
|
|
|
}
|
|
|
|
|
|
2023-02-09 09:32:38 +01:00
|
|
|
public static function provideArgs(): iterable
|
2019-02-26 22:39:26 +01:00
|
|
|
{
|
|
|
|
|
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 18:21:51 +02:00
|
|
|
}
|