Cleanup tests to automatically inject proper headers when needed

This commit is contained in:
Nabeel Shahzad
2018-01-06 12:07:22 -06:00
parent 60256ab213
commit 46a411e27b
6 changed files with 125 additions and 78 deletions

View File

@@ -29,7 +29,7 @@ class FlightTest extends TestCase
{
$flight = $this->addFlight();
$req = $this->get('/api/flights/'.$flight->id, self::$auth_headers);
$req = $this->get('/api/flights/' . $flight->id);
$req->assertStatus(200);
$body = $req->json();
@@ -50,10 +50,22 @@ class FlightTest extends TestCase
# search specifically for a flight ID
$query = 'flight_id=' . $flight->id;
$req = $this->get('/api/flights/search?' . $query, self::$auth_headers);
$req = $this->get('/api/flights/search?' . $query);
$req->assertStatus(200);
}
public function testFlightSearchApi()
{
$flights = factory(App\Models\Flight::class, 100)->create();
$flight = $flights->random();
$query = 'flight_id=' . $flight->id;
$req = $this->get('/api/flights/search?' . $query);
$body = $req->json();
$this->assertEquals($flight->id, $body['data'][0]['id']);
}
/**
* Add/remove a bid, test the API, etc
* @throws \App\Services\Exception