From dc8ad3a90568d7b4a63b27c509698e50f1681dc5 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Wed, 2 Jul 2025 23:28:15 -0500 Subject: [PATCH] Create tests for app/helpers --- app/helpers.php | 3 ++ tests/Feature/app/helpersTest.php | 47 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tests/Feature/app/helpersTest.php diff --git a/app/helpers.php b/app/helpers.php index ae6332d..47d3e56 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -8,6 +8,9 @@ use App\Models\User; use App\Settings; use Illuminate\Support\Facades\App; +/** + * @codeCoverageIgnore + */ function tw_max_width_class_array(): array { $return = [ diff --git a/tests/Feature/app/helpersTest.php b/tests/Feature/app/helpersTest.php new file mode 100644 index 0000000..280296f --- /dev/null +++ b/tests/Feature/app/helpersTest.php @@ -0,0 +1,47 @@ +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); +});