Create tests for app/Models/BonusScore
This commit is contained in:
parent
1466cc8c32
commit
c1f7d58efb
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Audition;
|
||||||
|
use App\Models\BonusScore;
|
||||||
|
use App\Models\BonusScoreDefinition;
|
||||||
|
use App\Models\Entry;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
$this->audition = Audition::factory()->create();
|
||||||
|
$this->judge = User::factory()->create();
|
||||||
|
$this->bonusScoreDefinition = BonusScoreDefinition::factory()->create();
|
||||||
|
$this->bonusScoreDefinition->auditions()->attach($this->audition);
|
||||||
|
$this->bonusScoreDefinition->judges()->attach($this->judge);
|
||||||
|
$this->entry = Entry::factory()->create(['audition_id' => $this->audition->id]);
|
||||||
|
DB::table('bonus_scores')->insert([
|
||||||
|
'entry_id' => $this->entry->id,
|
||||||
|
'user_id' => $this->judge->id,
|
||||||
|
'originally_scored_entry' => $this->entry->id,
|
||||||
|
'score' => 28,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can return its entry', function () {
|
||||||
|
expect(BonusScore::first()->entry->id)->toEqual($this->entry->id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can return its judge', function () {
|
||||||
|
expect(BonusScore::first()->judge->id)->toEqual($this->judge->id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can return its originally scored entry', function () {
|
||||||
|
expect(BonusScore::first()->originallyScoredEntry->id)->toEqual($this->entry->id);
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue