Write tests - Write tests for what was done to this point that will be kept #11

Merged
okorpheus merged 61 commits from write-tests into master 2024-07-05 21:21:32 +00:00
2 changed files with 39 additions and 5 deletions
Showing only changes of commit 218d7bc142 - Show all commits

View File

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