39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
use App\Models\Audition;
|
|
use App\Models\Entry;
|
|
use App\Models\Room;
|
|
use App\Models\ScoreSheet;
|
|
use App\Models\User;
|
|
use App\Services\ScoreService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\App;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
//$this->scoreService = new ScoreService();
|
|
$this->scoreService = App::make(ScoreService::class);
|
|
});
|
|
|
|
it('can check if an entry is fully scored', function () {
|
|
$room = Room::factory()->create();
|
|
$judges = User::factory()->count(2)->create();
|
|
$judges->each(fn ($judge) => $room->addJudge($judge));
|
|
$audition = Audition::factory()->create(['room_id' => $room->id]);
|
|
$entry = Entry::factory()->create(['audition_id' => $audition->id]);
|
|
expect($this->scoreService->isEntryFullyScored($entry))->toBeFalse();
|
|
ScoreSheet::create([
|
|
'user_id' => $judges->first()->id,
|
|
'entry_id' => $entry->id,
|
|
'subscores' => 7,
|
|
]);
|
|
expect($this->scoreService->isEntryFullyScored($entry))->toBeFalse();
|
|
ScoreSheet::create([
|
|
'user_id' => $judges->last()->id,
|
|
'entry_id' => $entry->id,
|
|
'subscores' => 7,
|
|
]);
|
|
expect($this->scoreService->isEntryFullyScored($entry))->toBeTrue();
|
|
});
|