2017-06-10 03:47:02 +08:00
|
|
|
<?php
|
|
|
|
|
2017-06-10 11:19:17 +08:00
|
|
|
use App\Models\Aircraft;
|
2017-06-10 03:47:02 +08:00
|
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
|
|
|
|
|
|
|
|
|
|
class AircraftTest extends TestCase
|
|
|
|
{
|
2017-06-10 11:19:17 +08:00
|
|
|
protected $aircraft,
|
|
|
|
$aircraft_class;
|
2017-06-10 03:47:02 +08:00
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
2017-06-10 11:19:17 +08:00
|
|
|
$this->aircraft = $this->createRepository('AircraftRepository');
|
|
|
|
$this->aircraft_class = $this->createRepository('AircraftClassRepository');
|
2017-06-10 03:47:02 +08:00
|
|
|
}
|
2017-06-10 11:19:17 +08:00
|
|
|
|
|
|
|
public function testAircraftClasses()
|
2017-06-10 03:47:02 +08:00
|
|
|
{
|
2017-06-10 11:19:17 +08:00
|
|
|
factory(App\Models\AircraftClass::class)->create();
|
|
|
|
|
|
|
|
$this->aircraft->create([
|
|
|
|
'aircraft_class_id' => 1,
|
|
|
|
'icao' => 'B744',
|
|
|
|
'name' => 'Boeing 747',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$aircraft = App\Models\Aircraft::where('icao', 'B744')->first();
|
|
|
|
$this->assertEquals('B744', $aircraft->icao, 'ICAO matching');
|
|
|
|
$this->assertEquals('H', $aircraft->class->code, 'Check belongsTo relationship');
|
2017-06-10 03:47:02 +08:00
|
|
|
}
|
|
|
|
}
|