From 0e05fa31bf15d439ce4eab71ec324b61d6739bee Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Thu, 4 Mar 2021 20:17:32 -0600 Subject: [PATCH] Location tests more reliable (#12584) * Location tests more reliable * perhaps this stayed disabled --- LibreNMS/Util/Dns.php | 4 ++-- tests/Unit/LocationTest.php | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/LibreNMS/Util/Dns.php b/LibreNMS/Util/Dns.php index 4879049e73..be6f9057b3 100644 --- a/LibreNMS/Util/Dns.php +++ b/LibreNMS/Util/Dns.php @@ -57,8 +57,8 @@ class Dns implements Geocoder { foreach ($this->getRecord($hostname, 'LOC') as $record) { return [ - 'lat' => $record->latitude, - 'lng' => $record->longitude, + 'lat' => $record->latitude ?? null, + 'lng' => $record->longitude ?? null, ]; } diff --git a/tests/Unit/LocationTest.php b/tests/Unit/LocationTest.php index c468998ee5..3dd402da0b 100644 --- a/tests/Unit/LocationTest.php +++ b/tests/Unit/LocationTest.php @@ -60,6 +60,7 @@ class LocationTest extends TestCase public function testCanSetEncodedLocation() { + Config::set('geoloc.dns', false); $device = Device::factory()->make(); /** @var Device $device */ // valid coords @@ -92,6 +93,7 @@ class LocationTest extends TestCase public function testCanHandleGivenCoordinates() { + Config::set('geoloc.dns', false); $device = Device::factory()->make(); /** @var Device $device */ $location = Location::factory()->withCoordinates()->make(); @@ -136,6 +138,7 @@ class LocationTest extends TestCase public function testCanSetDnsCoordinate() { + Config::set('geoloc.dns', true); $device = Device::factory()->make(); /** @var Device $device */ $location = Location::factory()->withCoordinates()->make();