42 lines
1.5 KiB
PHP
42 lines
1.5 KiB
PHP
<?php
|
|
|
|
use App\Models\Audition;
|
|
use App\Models\Entry;
|
|
use App\Models\ScoreSheet;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
$this->judge = User::factory()->create();
|
|
$this->entry = Entry::factory()->create();
|
|
DB::table('score_sheets')->insert([
|
|
'user_id' => $this->judge->id,
|
|
'entry_id' => $this->entry->id,
|
|
'subscores' => '{"1": {"score": 3, "subscore_id": 1, "subscore_name": "Etude 1"}, "2": {"score": 68, "subscore_id": 2, "subscore_name": "Etude 2"}, "3": {"score": 21, "subscore_id": 3, "subscore_name": "Sightreading"}, "4": {"score": 6, "subscore_id": 4, "subscore_name": "Scale"}, "5": {"score": 79, "subscore_id": 5, "subscore_name": "Tone"}}',
|
|
'seating_total' => 3,
|
|
'advancement_total' => 4,
|
|
]);
|
|
$this->scoreSheet = ScoreSheet::first();
|
|
});
|
|
|
|
it('returns its entry', function () {
|
|
expect($this->scoreSheet->entry->id)->toEqual($this->entry->id)
|
|
->and($this->scoreSheet->entry)->toBeInstanceOf(Entry::class);
|
|
});
|
|
|
|
it('returns its judge', function () {
|
|
expect($this->scoreSheet->judge->id)->toEqual($this->judge->id)
|
|
->and($this->scoreSheet->judge)->toBeInstanceOf(User::class);
|
|
});
|
|
|
|
it('returns its audition', function () {
|
|
expect($this->scoreSheet->audition->id)->toEqual($this->entry->audition->id)
|
|
->and($this->scoreSheet->audition)->toBeInstanceOf(Audition::class);
|
|
});
|
|
|
|
it('can return a specified subscore', function () {
|
|
expect($this->scoreSheet->getSubscore(2))->toEqual(68);
|
|
});
|