5 char ICAO support #1052 (#1198)

pull/1200/head
Nabeel S 3 years ago committed by GitHub
parent ede5b74383
commit d3ec0f4de3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,7 +11,7 @@ if (!function_exists('createFactoryICAO')) {
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$max = strlen($characters) - 1;
$string = '';
for ($i = 0; $i < 4; $i++) {
for ($i = 0; $i < 5; $i++) {
try {
$string .= $characters[random_int(0, $max)];
} catch (Exception $e) {

@ -0,0 +1,26 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Increase Airport ICAO size to 5 chars
* https://github.com/nabeelio/phpvms/issues/1052
*/
class IncreaseIcaoSizes extends Migration
{
public function up()
{
Schema::table('airports', function (Blueprint $table) {
$table->string('iata', 5)->change();
$table->string('icao', 5)->change();
});
Schema::table('pireps', function (Blueprint $table) {
$table->string('dpt_airport_id', 5)->change();
$table->string('arr_airport_id', 5)->change();
$table->string('alt_airport_id', 5)->change();
});
}
}

@ -4,9 +4,6 @@ namespace Tests;
use App\Models\Airport;
/**
* Test the parsing/support class of the metar
*/
class AirportTest extends TestCase
{
public function testSavingAirportFromApiResponse()

@ -166,6 +166,24 @@ class ApiTest extends TestCase
$this->get('/api/airports/UNK')->assertStatus(404);
}
/**
* Make sure the airport data is returned
*/
public function testAirportRequest5Char()
{
$this->user = factory(User::class)->create();
/** @var Airport $airport */
$airport = factory(Airport::class)->create(['icao' => '5Char']);
$response = $this->get('/api/airports/'.$airport->icao);
$response->assertStatus(200);
$response->assertJson(['data' => ['icao' => $airport->icao]]);
$this->get('/api/airports/UNK')->assertStatus(404);
}
/**
* Get all the airports, test the pagination
*/

Loading…
Cancel
Save