phpvms/tests/AircraftTest.php

34 lines
957 B
PHP
Raw Normal View History

2017-06-10 03:47:02 +08:00
<?php
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
{
protected $aircraft,
$aircraft_class;
2017-06-10 03:47:02 +08:00
public function setUp() {
parent::setUp();
$this->aircraft = $this->createRepository('AircraftRepository');
$this->aircraft_class = $this->createRepository('AircraftClassRepository');
2017-06-10 03:47:02 +08:00
}
public function testAircraftClasses()
2017-06-10 03:47:02 +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
}
}