From d8ecb41ac375d12351be2612860c5bfb296d7213 Mon Sep 17 00:00:00 2001 From: Bradley Date: Thu, 26 Sep 2024 09:41:54 +0100 Subject: [PATCH] Add test to return false on is geocoded if coords are 0 0 --- src/Trait/Entity/GeocodeTrait.php | 2 +- tests/Trait/GeocodeTraitTest.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Trait/Entity/GeocodeTrait.php b/src/Trait/Entity/GeocodeTrait.php index 6457805..98c843e 100644 --- a/src/Trait/Entity/GeocodeTrait.php +++ b/src/Trait/Entity/GeocodeTrait.php @@ -45,7 +45,7 @@ trait GeocodeTrait 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()); } } diff --git a/tests/Trait/GeocodeTraitTest.php b/tests/Trait/GeocodeTraitTest.php index fcc8cfd..a802447 100644 --- a/tests/Trait/GeocodeTraitTest.php +++ b/tests/Trait/GeocodeTraitTest.php @@ -75,11 +75,18 @@ final class GeocodeTraitTest extends TestCase $this->assertTrue($this->obj->isGeocoded()); } - public function testIsGeocodeReturnsTrueIfLatAndLonAreBothZero(): void + public function testIsGeocodedReturnsFalseIfLatAndLonAreBothZero(): void { $this->obj->setLatitude(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