Save airport timezone (#1112)

* Fix airport timezone lookup

* Save timezone to the airport when importing
pull/1103/head^2
Nabeel S 4 years ago committed by GitHub
parent 9c4aced837
commit 96fff0248d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -46,6 +46,7 @@ class Airport extends Model
'lon',
'hub',
'timezone',
'tz',
'ground_handling_cost',
'fuel_100ll_cost',
'fuel_jeta_cost',

@ -2,7 +2,7 @@
namespace App\Services;
use App\Contracts\AirportLookup as AirportLookupProvider;
use App\Contracts\AirportLookup;
use App\Contracts\Metar as MetarProvider;
use App\Contracts\Service;
use App\Exceptions\AirportNotFound;
@ -23,7 +23,7 @@ class AirportService extends Service
private $metarProvider;
public function __construct(
AirportLookupProvider $lookupProvider,
AirportLookup $lookupProvider,
AirportRepository $airportRepo,
MetarProvider $metarProvider
) {

@ -0,0 +1,30 @@
<?php
namespace Tests;
use App\Models\Airport;
/**
* Test the parsing/support class of the metar
*/
class AirportTest extends TestCase
{
public function testSavingAirportFromApiResponse()
{
// This is the response from the API
$airportResponse = [
'icao' => 'KJFK',
'iata' => 'JFK',
'name' => 'John F Kennedy International Airport',
'city' => 'New York',
'country' => 'United States',
'tz' => 'America/New_York',
'lat' => 40.63980103,
'lon' => -73.77890015,
];
$airport = new Airport($airportResponse);
$this->assertEquals($airportResponse['icao'], $airport->icao);
$this->assertEquals($airportResponse['tz'], $airport->timezone);
}
}

@ -88,6 +88,16 @@ abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
});
}
/**
* @param $mocks
*/
protected function addMocks($mocks)
{
$handler = HandlerStack::create($mocks);
$client = new Client(['handler' => $handler]);
$this->client->httpClient = $client;
}
/**
* @param $user
* @param array $headers

Loading…
Cancel
Save