From 519ae600d55c48e41b48ae05da4a6fbe9179e10a Mon Sep 17 00:00:00 2001 From: Nabeel S Date: Thu, 4 Jun 2020 03:30:35 -0700 Subject: [PATCH] Fix METAR invalid parameter #738 (#743) --- app/Services/Metar/AviationWeather.php | 4 +-- tests/MetarTest.php | 8 ++++++ tests/data/aviationweather/kphx.xml | 34 ++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 tests/data/aviationweather/kphx.xml diff --git a/app/Services/Metar/AviationWeather.php b/app/Services/Metar/AviationWeather.php index 400ce1b3..169287eb 100644 --- a/app/Services/Metar/AviationWeather.php +++ b/app/Services/Metar/AviationWeather.php @@ -14,9 +14,7 @@ use Illuminate\Support\Facades\Log; class AviationWeather extends Metar { private const METAR_URL = - 'https://www.aviationweather.gov/adds/dataserver_current/httpparam?' - .'dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3' - .'&mostRecent=true&fields=raw_text&stationString='; + 'https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString='; private $httpClient; diff --git a/tests/MetarTest.php b/tests/MetarTest.php index ef794629..33363853 100644 --- a/tests/MetarTest.php +++ b/tests/MetarTest.php @@ -173,6 +173,14 @@ class MetarTest extends TestCase $this->assertInstanceOf(Metar::class, $airportSvc->getMetar('kjfk')); } + public function testHttpCallSuccessFullResponse() + { + $this->mockXmlResponse('aviationweather/kphx.xml'); + $airportSvc = app(AirportService::class); + + $this->assertInstanceOf(Metar::class, $airportSvc->getMetar('kphx')); + } + public function testHttpCallEmpty() { $this->mockXmlResponse('aviationweather/empty.xml'); diff --git a/tests/data/aviationweather/kphx.xml b/tests/data/aviationweather/kphx.xml new file mode 100644 index 00000000..87daf648 --- /dev/null +++ b/tests/data/aviationweather/kphx.xml @@ -0,0 +1,34 @@ + + + 30141982 + + + + + 4 + + + KPHX 021651Z 33009KT 10SM FEW160 FEW210 SCT250 36/08 A2991 RMK AO2 SLP105 T03560078 + KPHX + 2020-06-02T16:51:00Z + 33.43 + -112.02 + 35.6 + 7.8 + 330 + 9 + 10.0 + 29.911417 + 1010.5 + + TRUE + + + + + VFR + METAR + 336.0 + + +