SchoreSheet Test

This commit is contained in:
Matt Young 2024-07-01 12:28:31 -05:00
parent c3d7a7293b
commit 218d7bc142
2 changed files with 39 additions and 5 deletions

View File

@ -38,11 +38,6 @@ class ScoreSheet extends Model
);
}
public function getSubscore($id)
{
return $this->subscores[$id]['score'] ?? false;
}
public function isValid()
{
// TODO move to either TabulationService or a specific service for scoreValidation

View File

@ -0,0 +1,39 @@
<?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();
$this->scoreSheet = ScoreSheet::create([
'user_id' => $this->judge->id,
'entry_id' => $this->entry->id,
'subscores' => [
1 => ['score' => 10],
2 => ['score' => 20],
3 => ['score' => 30],
],
]);
});
it('has an entry', function () {
expect($this->scoreSheet->entry->id)->toBe($this->entry->id)
->and($this->scoreSheet->entry)->toBeInstanceOf(Entry::class);
});
it('has a judge', function () {
expect($this->scoreSheet->judge->id)->toBe($this->judge->id)
->and($this->scoreSheet->judge)->toBeInstanceOf(User::class);
});
it('has an audition', function () {
expect($this->scoreSheet->audition->id)->toBe($this->entry->audition->id)
->and($this->scoreSheet->audition)->toBeInstanceOf(Audition::class);
});