Create tests for app/Models/HistoricalSeat
This commit is contained in:
parent
731a6440b1
commit
50cefdc05d
|
|
@ -2,14 +2,11 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class HistoricalSeat extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function student(): BelongsTo
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
use App\Models\HistoricalSeat;
|
||||
use App\Models\Student;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
$this->student = Student::factory()->create();
|
||||
HistoricalSeat::create([
|
||||
'student_id' => $this->student->id,
|
||||
'year' => 8,
|
||||
'seat_description' => 'First Seat',
|
||||
]);
|
||||
});
|
||||
|
||||
it('Returns its student', function () {
|
||||
expect(HistoricalSeat::first()->student->id)->toEqual($this->student->id)
|
||||
->and(HistoricalSeat::first()->student)->toBeInstanceOf(Student::class);
|
||||
});
|
||||
Loading…
Reference in New Issue