Rename Mappable stuff to Geocode stuff, change dir structure

This commit is contained in:
brabli
2024-08-05 14:25:03 +01:00
parent a6c8c4cc0c
commit 8b662ebfa3
4 changed files with 20 additions and 21 deletions

View File

@@ -0,0 +1,93 @@
<?php
declare(strict_types=1);
namespace Pcm\GeocodeBundle\Tests;
use Pcm\GeocodeBundle\Interface\Entity\GeocodeInterface;
use Pcm\GeocodeBundle\Trait\Entity\GeocodeTrait;
use PHPUnit\Framework\TestCase;
final class GeocodeTraitTest extends TestCase
{
private const float COORD = 123.456;
private GeocodeInterface $obj;
protected function setUp(): void
{
$this->obj = $this->getTraitObject();
}
public function testSetLatitude(): void
{
$this->assertInstanceOf(GeocodeInterface::class, $this->obj->setLatitude(self::COORD));
}
public function testGetLatitudeReturnsNull(): void
{
$this->assertNull($this->obj->getLatitude());
}
public function testGetLatitude(): void
{
$this->obj->setLatitude(self::COORD);
$this->assertSame(self::COORD, $this->obj->getLatitude());
}
public function testSetLongitude(): void
{
$this->assertInstanceOf(GeocodeInterface::class, $this->obj->setLongitude(self::COORD));
}
public function testGetLongitudeReturnsNull(): void
{
$this->assertNull($this->obj->getLongitude());
}
public function testGetLongitude(): void
{
$this->obj->setLongitude(self::COORD);
$this->assertSame(self::COORD, $this->obj->getLongitude());
}
public function testIsGeocodedReturnsFalse(): void
{
$this->assertFalse($this->obj->isGeocoded());
}
public function testIsGeocodedReturnsFalseIfLatIsSet(): void
{
$this->obj->setLatitude(self::COORD);
$this->assertFalse($this->obj->isGeocoded());
}
public function testIsGeocodedReturnsFalseIfLonIsSet(): void
{
$this->obj->setLongitude(self::COORD);
$this->assertFalse($this->obj->isGeocoded());
}
public function testIsGeocodedReturnsTrueIfLatAndLonAreSet(): void
{
$this->obj->setLatitude(self::COORD);
$this->obj->setLongitude(self::COORD);
$this->assertTrue($this->obj->isGeocoded());
}
public function testIsGeocodeReturnsTrueIfLatAndLonAreBothZero(): void
{
$this->obj->setLatitude(0.000);
$this->obj->setLongitude(0.000);
$this->assertTrue($this->obj->isGeocoded());
}
private function getTraitObject(): GeocodeInterface
{
return new class implements GeocodeInterface
{
use GeocodeTrait;
};
}
}