Save airport timezone (#1112)
* Fix airport timezone lookup * Save timezone to the airport when importing
This commit is contained in:
parent
9c4aced837
commit
96fff0248d
@ -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
|
||||
) {
|
||||
|
30
tests/AirportTest.php
Normal file
30
tests/AirportTest.php
Normal file
@ -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…
Reference in New Issue
Block a user