Compare commits

...

2 Commits
2.0.0 ... 2.0.1

Author SHA1 Message Date
brabli
555eaf4f2d Update changelog 2024-10-09 16:04:55 +01:00
brabli
d6f54eb17f Add tests and make them pass 2024-10-09 16:03:18 +01:00
3 changed files with 22 additions and 1 deletions

View File

@@ -2,6 +2,9 @@
## [x.x.x] xxxx-xx-xx
## [2.0.1] 2024-10-09
- Fix bug that caused isGeocoded to return false if only one of the coordinates was zero
## [2.0.0] 2024-09-26
- Adjust how error messages are formatted
- Add getGeocodeData method to GeocodeInterface to allow for more abstraction in services

View File

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

View File

@@ -89,6 +89,20 @@ final class GeocodeTraitTest extends TestCase
$this->assertFalse($this->obj->isGeocoded());
}
public function testIsGeocodedReturnsTrueIfLongitudeIsZeroAndLatIsNot(): void
{
$this->obj->setLatitude(0.1);
$this->obj->setLongitude(0);
$this->assertTrue($this->obj->isGeocoded());
}
public function testIsGeocodedReturnsTrueIfLatitudeIsZeroAndLongIsNot(): void
{
$this->obj->setLatitude(0);
$this->obj->setLongitude(0.2);
$this->assertTrue($this->obj->isGeocoded());
}
private function getTraitObject(): GeocodeInterface
{
return new class implements GeocodeInterface