2017-06-20 00:30:39 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
class FlightTest extends TestCase
|
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
2017-08-15 12:36:49 +08:00
|
|
|
$this->addData('base');
|
2017-06-20 00:30:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function addFlight()
|
|
|
|
{
|
|
|
|
$flight = new App\Models\Flight;
|
|
|
|
$flight->airline_id = 1;
|
2017-08-15 12:36:49 +08:00
|
|
|
$flight->flight_number = 10;
|
2017-12-12 20:48:04 +08:00
|
|
|
$flight->dpt_airport_id = 'KAUS';
|
|
|
|
$flight->arr_airport_id = 'KJFK';
|
2017-06-20 00:30:39 +08:00
|
|
|
$flight->save();
|
2017-12-12 20:48:04 +08:00
|
|
|
|
2017-08-15 12:36:49 +08:00
|
|
|
return $flight->id;
|
|
|
|
}
|
|
|
|
|
2017-11-23 01:52:02 +08:00
|
|
|
public function testGetFlight()
|
2017-08-15 12:36:49 +08:00
|
|
|
{
|
|
|
|
$flight_id = $this->addFlight();
|
2017-12-12 21:25:11 +08:00
|
|
|
$this->get('/api/flights/'.$flight_id, self::$auth_headers)
|
|
|
|
->assertStatus(200)
|
|
|
|
->assertJson(['dpt_airport_id' => 'KAUS']);
|
|
|
|
|
|
|
|
$this->get('/api/flights/INVALID', self::$auth_headers)
|
|
|
|
->assertStatus(404);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Search based on all different criteria
|
|
|
|
*/
|
|
|
|
public function testSearchFlight()
|
|
|
|
{
|
|
|
|
$flight_id = $this->addFlight();
|
|
|
|
|
|
|
|
# search specifically for a flight ID
|
|
|
|
$query = 'flight_id='.$flight_id;
|
|
|
|
$req = $this->get('/api/flights/search?' . $query, self::$auth_headers);
|
|
|
|
$req->assertStatus(200);
|
2017-06-20 00:30:39 +08:00
|
|
|
}
|
|
|
|
}
|