Add test to return false on is geocoded if coords are 0 0

This commit is contained in:
2024-09-26 09:41:54 +01:00
parent 214fcc2bac
commit d8ecb41ac3
2 changed files with 10 additions and 3 deletions

View File

@@ -45,7 +45,7 @@ trait GeocodeTrait
public function isGeocoded(): bool public function isGeocoded(): bool
{ {
return null !== $this->getLatitude() && null !== $this->getLongitude(); return null !== $this->getLatitude() && null !== $this->getLongitude() && (0.0 !== $this->getLatitude() && 0.0 !== $this->getLongitude());
} }
} }

View File

@@ -75,11 +75,18 @@ final class GeocodeTraitTest extends TestCase
$this->assertTrue($this->obj->isGeocoded()); $this->assertTrue($this->obj->isGeocoded());
} }
public function testIsGeocodeReturnsTrueIfLatAndLonAreBothZero(): void public function testIsGeocodedReturnsFalseIfLatAndLonAreBothZero(): void
{ {
$this->obj->setLatitude(0.000); $this->obj->setLatitude(0.000);
$this->obj->setLongitude(0.000); $this->obj->setLongitude(0.000);
$this->assertTrue($this->obj->isGeocoded()); $this->assertFalse($this->obj->isGeocoded());
}
public function testIsGeocodedReturnsFalseIfLatAndLonAreBothZeroInts(): void
{
$this->obj->setLatitude(0);
$this->obj->setLongitude(0);
$this->assertFalse($this->obj->isGeocoded());
} }
private function getTraitObject(): GeocodeInterface private function getTraitObject(): GeocodeInterface