calculator = new CalculateScoreSheetTotal(); }); it('throws an exception if an invalid mode is called for', function () { $calculator = new CalculateScoreSheetTotal(); $calculator('anything', Entry::factory()->create(), User::factory()->create()); })->throws(TabulationException::class, 'Invalid mode requested. Mode must be seating or advancement'); it('throws an exception if an invalid judge is provided', function () { $calculator = new CalculateScoreSheetTotal(); $calculator('seating', Entry::factory()->create(), User::factory()->make()); })->throws(TabulationException::class, 'Invalid judge provided'); it('throws an exception if an invalid entry is provided', function () { $calculator = new CalculateScoreSheetTotal(); $calculator('advancement', Entry::factory()->make(), User::factory()->create()); })->throws(TabulationException::class, 'Invalid entry provided'); it('throws an exception if the specified judge has not scored the entry', function () { // Arrange $calculator = new CalculateScoreSheetTotal(); // Act $calculator('seating', Entry::factory()->create(), User::factory()->create()); //Assert })->throws(TabulationException::class, 'No score sheet by that judge for that entry'); it('correctly calculates final score for seating', function () { loadSampleAudition(); $judge = User::factory()->create(); Room::find(1000)->addJudge($judge); $entry = Entry::factory()->create(['audition_id' => 1000]); $scores = [ 1001 => 50, 1002 => 60, 1003 => 70, 1004 => 80, 1005 => 90, ]; enterScore($judge, $entry, $scores); $calculator = new CalculateScoreSheetTotal(); $total = $calculator('seating', $entry, $judge); expect($total[0])->toBe(68.75); $expectedArray = [68.75, 80, 60, 70, 50]; expect($total)->toBe($expectedArray); }); it('correctly calculates final score for advancement', function () { loadSampleAudition(); $judge = User::factory()->create(); Room::find(1000)->addJudge($judge); $entry = Entry::factory()->create(['audition_id' => 1000]); $scores = [ 1001 => 50, 1002 => 60, 1003 => 70, 1004 => 80, 1005 => 90, ]; enterScore($judge, $entry, $scores); $calculator = new CalculateScoreSheetTotal(); $total = $calculator('advancement', $entry, $judge); expect($total[0])->toBe(73.75); $expectedArray = [73.75, 90, 80, 60, 70]; expect($total)->toBe($expectedArray); });