Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f6a3fed2b | |||
|
|
8f52f72679 | ||
|
|
555eaf4f2d | ||
|
|
d6f54eb17f |
@@ -2,6 +2,13 @@
|
||||
|
||||
## [x.x.x] xxxx-xx-xx
|
||||
|
||||
## [2.0.2] 2025-05-08
|
||||
- Updating composer to allow `doctrine/orm` version 2 or 3
|
||||
- Update postcode in tests as the old one stopped working
|
||||
|
||||
## [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
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"symfony/dependency-injection": "^7.1",
|
||||
"symfony/framework-bundle": "^7.1",
|
||||
"symfony/yaml": "^7.1",
|
||||
"doctrine/orm": "^2.13"
|
||||
"doctrine/orm": "^2|^3"
|
||||
},
|
||||
|
||||
"require-dev": {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
*/
|
||||
final class GeocoderTest extends KernelTestCase
|
||||
{
|
||||
// Buckingham Palace
|
||||
private const string POSTCODE = 'SW1A 1AA';
|
||||
// Yes this is a real postcode
|
||||
private const string POSTCODE = 'ABC 123';
|
||||
|
||||
private Geocoder $geocoder;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user