Create tests for app/helpers
This commit is contained in:
parent
bd14c10b93
commit
dc8ad3a905
|
|
@ -8,6 +8,9 @@ use App\Models\User;
|
||||||
use App\Settings;
|
use App\Settings;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
function tw_max_width_class_array(): array
|
function tw_max_width_class_array(): array
|
||||||
{
|
{
|
||||||
$return = [
|
$return = [
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?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);
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue