Write tests - Write tests for what was done to this point that will be kept #11
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
});
|
||||
Loading…
Reference in New Issue