51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace App\Tests\Unit\DTO\Factory;
|
||
|
|
||
|
use App\DTO\Factory\GEOPointFactory;
|
||
|
use App\DTO\GEOPoint;
|
||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
|
||
|
class GEOPointFactoryTest extends TestCase
|
||
|
{
|
||
|
public function testCreateFromStringWillAcceptGeopoints(): void
|
||
|
{
|
||
|
$service = $this->createService();
|
||
|
$geopoint = $service->createFromString('20.303', '30.22');
|
||
|
$this->assertInstanceOf(GEOPoint::class, $geopoint);
|
||
|
$this->assertEquals(20.303, $geopoint->latitude);
|
||
|
$this->assertEquals(30.22, $geopoint->longitude);
|
||
|
}
|
||
|
|
||
|
#[DataProvider('invalidGeoPointProvider')]
|
||
|
public function testCreateFromStringInvalidString(string $lat, string $lon): void
|
||
|
{
|
||
|
$service = $this->createService();
|
||
|
$geopoint = $service->createFromString($lat, $lon);
|
||
|
$this->assertEquals(null, $geopoint);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return array<int|string, array<int|string, string>>
|
||
|
*/
|
||
|
public static function invalidGeoPointProvider(): array
|
||
|
{
|
||
|
return [
|
||
|
['foo', 'foo'],
|
||
|
['33.33', 'foo'],
|
||
|
['foo', '33.33'],
|
||
|
['foo3', 'foo3'],
|
||
|
['33.33', 'foo3'],
|
||
|
['foo3', '33.33'],
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public function createService(): GEOPointFactory
|
||
|
{
|
||
|
return new GEOPointFactory();
|
||
|
}
|
||
|
}
|