From 0af15bf7533b1297cde65ca17791b845c871fdbd Mon Sep 17 00:00:00 2001 From: Matt Young Date: Tue, 15 Jul 2025 09:56:34 -0500 Subject: [PATCH] Tets for BonusScoreController --- .../Tabulation/BonusScoreControllerTest.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/Feature/app/Http/Controllers/Tabulation/BonusScoreControllerTest.php b/tests/Feature/app/Http/Controllers/Tabulation/BonusScoreControllerTest.php index abf481d..9f00e97 100644 --- a/tests/Feature/app/Http/Controllers/Tabulation/BonusScoreControllerTest.php +++ b/tests/Feature/app/Http/Controllers/Tabulation/BonusScoreControllerTest.php @@ -201,4 +201,38 @@ describe('BonusScoreController::saveEntryBonusScoreSheet', function () { expect(BonusScore::all())->toHaveCount(0); }); + it('passes exceptions from the enter bonus score action', function () { + $ASbonusScoreRecorded = BonusScore::create([ + 'entry_id' => $this->ASentry->id, + 'user_id' => $this->judge1->id, + 'originally_scored_entry' => $this->ASentry->id, + 'score' => 2, + ]); + $TSbonusScoreRecorded = BonusScore::create([ + 'entry_id' => $this->TSentry->id, + 'user_id' => $this->judge1->id, + 'originally_scored_entry' => $this->ASentry->id, + 'score' => 2, + ]); + $BSbonusScoreRecorded = BonusScore::create([ + 'entry_id' => $this->BSentry->id, + 'user_id' => $this->judge1->id, + 'originally_scored_entry' => $this->ASentry->id, + 'score' => 2, + ]); + actAsAdmin(); + $response = $this->post(route('bonus-scores.saveEntryBonusScoreSheet', $this->TSentry), [ + 'judge_id' => $this->judge1->id, + 'entry_id' => $this->TSentry->id, + 'score' => 908556, + ]); + $response->assertRedirect(route('bonus-scores.entryBonusScoreSheet', ['entry_id' => $this->TSentry->id])) + ->assertSessionHas('error'); + foreach (Entry::all() as $entry) { + $bs = $entry->bonusScores()->first(); + expect($bs->score)->toEqual(2) + ->and($bs->originallyScoredEntry->id)->toEqual($this->ASentry->id); + } + }); + });