48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
use App\Models\Audition;
|
|
use App\Models\AuditLogEntry;
|
|
use App\Models\Entry;
|
|
use App\Models\Room;
|
|
use App\Models\ScoreSheet;
|
|
use App\Models\ScoringGuide;
|
|
use App\Models\Student;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('can retrieve an audition setting', function () {
|
|
expect(auditionSetting('registrationCode'))->toBe('secret');
|
|
});
|
|
|
|
it('can create an AuditLog entry', function () {
|
|
actAsAdmin();
|
|
auditionLog('This is the message', ['users' => [1, 2, 3], 'entries' => [4, 5, 6]]);
|
|
$logEntry = AuditLogEntry::first();
|
|
expect($logEntry->user)->toBe(auth()->user()->email)
|
|
->and($logEntry->message)->toBe('This is the message')
|
|
->and($logEntry->affected)->toEqual(['users' => [1, 2, 3], 'entries' => [4, 5, 6]]);
|
|
});
|
|
|
|
it('can enter a score', function () {
|
|
$room = Room::factory()->create();
|
|
$scoringGuide = ScoringGuide::factory()->create();
|
|
$audition = Audition::factory()->create([
|
|
'room_id' => $room->id, 'order_in_room' => 1, 'maximum_grade' => 15,
|
|
'minimum_grade' => 1, 'scoring_guide_id' => $scoringGuide->id,
|
|
]);
|
|
$student = Student::factory()->create();
|
|
$entry = Entry::create(['audition_id' => $audition->id, 'student_id' => $student->id]);
|
|
$judge = User::factory()->create();
|
|
$room->judges()->attach($judge);
|
|
enterScore($judge, $entry, [
|
|
1 => 10,
|
|
2 => 10,
|
|
3 => 4,
|
|
4 => 10,
|
|
5 => 10,
|
|
]);
|
|
expect(ScoreSheet::count())->toBe(1);
|
|
});
|