2018-10-16 19:21:51 +03:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace ShlinkioTest\Shlink\Core\Entity;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Shlinkio\Shlink\Core\Entity\VisitLocation;
|
2019-08-10 14:42:37 +03:00
|
|
|
use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
2018-10-16 19:21:51 +03:00
|
|
|
|
|
|
|
class VisitLocationTest extends TestCase
|
|
|
|
{
|
2019-02-17 14:59:55 +03:00
|
|
|
/** @test */
|
|
|
|
public function valuesFoundWhenExchangingArrayAreCastToString(): void
|
2018-10-16 19:21:51 +03:00
|
|
|
{
|
2019-02-17 14:59:55 +03:00
|
|
|
$payload = new Location('', '', '', '', 1000.7, -2000.4, '');
|
2018-10-28 17:13:45 +03:00
|
|
|
$location = new VisitLocation($payload);
|
2018-10-16 19:21:51 +03:00
|
|
|
|
|
|
|
$this->assertSame('1000.7', $location->getLatitude());
|
|
|
|
$this->assertSame('-2000.4', $location->getLongitude());
|
|
|
|
}
|
2019-02-27 00:39:26 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @dataProvider provideArgs
|
|
|
|
*/
|
|
|
|
public function isEmptyReturnsTrueWhenAllValuesAreEmpty(array $args, bool $isEmpty): void
|
|
|
|
{
|
|
|
|
$payload = new Location(...$args);
|
|
|
|
$location = new VisitLocation($payload);
|
|
|
|
|
|
|
|
$this->assertEquals($isEmpty, $location->isEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
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 19:21:51 +03:00
|
|
|
}
|