Stash old tests

This commit is contained in:
Matt Young 2025-06-30 15:04:47 -05:00
parent e0c3a26411
commit b32ade6c7f
85 changed files with 44 additions and 44 deletions

View File

@ -2,6 +2,7 @@
namespace App\Actions\Entries; namespace App\Actions\Entries;
use App\Exceptions\AuditionAdminException;
use App\Exceptions\ManageEntryException; use App\Exceptions\ManageEntryException;
use App\Models\Audition; use App\Models\Audition;
use App\Models\AuditLogEntry; use App\Models\AuditLogEntry;
@ -83,29 +84,29 @@ class CreateEntry
{ {
// Make sure it's a valid student // Make sure it's a valid student
if (! $student || ! $student->exists()) { if (! $student || ! $student->exists()) {
throw new ManageEntryException('Invalid student provided'); throw new AuditionAdminException('Invalid student provided');
} }
// Make sure the audition is valid // Make sure the audition is valid
if (! $audition || ! $audition->exists()) { if (! $audition || ! $audition->exists()) {
throw new ManageEntryException('Invalid audition provided'); throw new AuditionAdminException('Invalid audition provided');
} }
// A student can't enter the same audition twice // A student can't enter the same audition twice
if (Entry::where('student_id', $student->id)->where('audition_id', $audition->id)->exists()) { if (Entry::where('student_id', $student->id)->where('audition_id', $audition->id)->exists()) {
throw new ManageEntryException('That student is already entered in that audition'); throw new AuditionAdminException('That student is already entered in that audition');
} }
// Can't enter a published audition // Can't enter a published audition
if ($audition->hasFlag('seats_published')) { if ($audition->hasFlag('seats_published')) {
throw new ManageEntryException('Cannot add an entry to an audition where seats are published'); throw new AuditionAdminException('Cannot add an entry to an audition where seats are published');
} }
if ($audition->hasFlag('advancement_published')) { if ($audition->hasFlag('advancement_published')) {
throw new ManageEntryException('Cannot add an entry to an audition where advancement is published'); throw new AuditionAdminException('Cannot add an entry to an audition where advancement is published');
} }
// Verify the grade of the student is in range for the audition // Verify the grade of the student is in range for the audition
if ($student->grade > $audition->maximum_grade) { if ($student->grade > $audition->maximum_grade) {
throw new ManageEntryException('The grade of the student exceeds the maximum for that audition'); throw new AuditionAdminException('The grade of the student exceeds the maximum for that audition');
} }
if ($student->grade < $audition->minimum_grade) { if ($student->grade < $audition->minimum_grade) {
throw new ManageEntryException('The grade of the student does not meet the minimum for that audition'); throw new AuditionAdminException('The grade of the student does not meet the minimum for that audition');
} }
} }
} }

View File

@ -3,7 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Actions\Entries\CreateEntry; use App\Actions\Entries\CreateEntry;
use App\Exceptions\ManageEntryException; use App\Exceptions\AuditionAdminException;
use App\Models\Audition; use App\Models\Audition;
use App\Models\AuditLogEntry; use App\Models\AuditLogEntry;
use App\Models\Entry; use App\Models\Entry;
@ -57,7 +57,7 @@ class EntryController extends Controller
try { try {
$creator($validData['student_id'], $validData['audition_id'], $enter_for); $creator($validData['student_id'], $validData['audition_id'], $enter_for);
} catch (ManageEntryException $ex) { } catch (AuditionAdminException $ex) {
return redirect()->route('entries.index')->with('error', $ex->getMessage()); return redirect()->route('entries.index')->with('error', $ex->getMessage());
} }

View File

@ -13,14 +13,14 @@ use Illuminate\Support\Facades\App;
uses(RefreshDatabase::class); uses(RefreshDatabase::class);
it('throws an exception if mode is not seating or advancement', function () { it('throws an exception if mode is not seating or advancement', function () {
#$calculator = new AllJudgesCount(); //$calculator = new AllJudgesCount();
$calculator = App::make(AllowForOlympicScoring::class); $calculator = App::make(AllowForOlympicScoring::class);
$calculator->calculate('WRONG', Entry::factory()->create()); $calculator->calculate('WRONG', Entry::factory()->create());
})->throws(TabulationException::class, 'Mode must be seating or advancement'); })->throws(TabulationException::class, 'Mode must be seating or advancement');
it('throws an exception if entry is not valid', function () { it('throws an exception if entry is not valid', function () {
// Arrange // Arrange
#$calculator = new AllJudgesCount(); //$calculator = new AllJudgesCount();
$calculator = App::make(AllowForOlympicScoring::class); $calculator = App::make(AllowForOlympicScoring::class);
// Act // Act
$calculator->calculate('seating', Entry::factory()->make()); $calculator->calculate('seating', Entry::factory()->make());
@ -41,7 +41,7 @@ it('throws an exception if entry is missing judge scores', function () {
1004 => 80, 1004 => 80,
1005 => 90, 1005 => 90,
]; ];
#$calculator = new AllJudgesCount(); //$calculator = new AllJudgesCount();
$calculator = App::make(AllowForOlympicScoring::class); $calculator = App::make(AllowForOlympicScoring::class);
enterScore($judge1, $entry, $scores); enterScore($judge1, $entry, $scores);
// Act // Act
@ -65,7 +65,7 @@ it('throws an exception if a score exists from an invalid judge', function () {
1004 => 80, 1004 => 80,
1005 => 90, 1005 => 90,
]; ];
#$calculator = new AllJudgesCount(); //$calculator = new AllJudgesCount();
$calculator = App::make(AllowForOlympicScoring::class); $calculator = App::make(AllowForOlympicScoring::class);
enterScore($judge1, $entry, $scores); enterScore($judge1, $entry, $scores);
$scoreSheetToSpoof = enterScore($judge2, $entry, $scores); $scoreSheetToSpoof = enterScore($judge2, $entry, $scores);
@ -97,7 +97,7 @@ it('correctly calculates scores for seating', function () {
1004 => 85, 1004 => 85,
1005 => 95, 1005 => 95,
]; ];
#$calculator = new AllJudgesCount(); //$calculator = new AllJudgesCount();
$calculator = App::make(AllowForOlympicScoring::class); $calculator = App::make(AllowForOlympicScoring::class);
enterScore($judge1, $entry, $scores); enterScore($judge1, $entry, $scores);
enterScore($judge2, $entry, $scores2); enterScore($judge2, $entry, $scores2);

View File

@ -12,7 +12,6 @@ use Illuminate\Support\Facades\Artisan;
uses(RefreshDatabase::class); uses(RefreshDatabase::class);
it('throws an exception if an invalid mode is called for', function () { it('throws an exception if an invalid mode is called for', function () {
$calculator = app(CalculateScoreSheetTotal::class); $calculator = app(CalculateScoreSheetTotal::class);
$calculator('anything', Entry::factory()->create(), User::factory()->create()); $calculator('anything', Entry::factory()->create(), User::factory()->create());

View File

@ -1,6 +1,5 @@
<?php <?php
use App\Actions\Tabulation\AllowForOlympicScoring;
use App\Actions\Tabulation\RankAuditionEntries; use App\Actions\Tabulation\RankAuditionEntries;
use App\Exceptions\TabulationException; use App\Exceptions\TabulationException;
use App\Models\Audition; use App\Models\Audition;
@ -14,13 +13,13 @@ use Illuminate\Support\Facades\Artisan;
uses(RefreshDatabase::class); uses(RefreshDatabase::class);
it('throws an exception if an invalid mode is specified', function () { it('throws an exception if an invalid mode is specified', function () {
#$ranker = new RankAuditionEntries(new AllJudgesCount()); //$ranker = new RankAuditionEntries(new AllJudgesCount());
$ranker = App::make(RankAuditionEntries::class); $ranker = App::make(RankAuditionEntries::class);
$ranker->rank('wrong', Audition::factory()->create()); $ranker->rank('wrong', Audition::factory()->create());
})->throws(TabulationException::class, 'Mode must be seating or advancement'); })->throws(TabulationException::class, 'Mode must be seating or advancement');
it('throws an exception if an invalid audition is provided', function () { it('throws an exception if an invalid audition is provided', function () {
// Arrange // Arrange
#$ranker = new RankAuditionEntries(new AllJudgesCount()); //$ranker = new RankAuditionEntries(new AllJudgesCount());
$ranker = App::make(RankAuditionEntries::class); $ranker = App::make(RankAuditionEntries::class);
// Act & Assert // Act & Assert
$ranker->rank('seating', Audition::factory()->make()); $ranker->rank('seating', Audition::factory()->make());
@ -29,7 +28,7 @@ it('includes all entries of the given mode in the return', function () {
$audition = Audition::factory()->create(); $audition = Audition::factory()->create();
$entries = Entry::factory()->seatingOnly()->count(10)->create(['audition_id' => $audition->id]); $entries = Entry::factory()->seatingOnly()->count(10)->create(['audition_id' => $audition->id]);
$otherEntries = Entry::factory()->advanceOnly()->count(10)->create(['audition_id' => $audition->id]); $otherEntries = Entry::factory()->advanceOnly()->count(10)->create(['audition_id' => $audition->id]);
#$ranker = new RankAuditionEntries(new AllJudgesCount()); //$ranker = new RankAuditionEntries(new AllJudgesCount());
$ranker = App::make(RankAuditionEntries::class); $ranker = App::make(RankAuditionEntries::class);
// Act // Act
$return = $ranker->rank('seating', $audition); $return = $ranker->rank('seating', $audition);

View File

@ -2,6 +2,7 @@
use App\Models\User; use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
use function Pest\Laravel\actingAs; use function Pest\Laravel\actingAs;
use function Pest\Laravel\get; use function Pest\Laravel\get;

View File

@ -3,6 +3,7 @@
use App\Models\School; use App\Models\School;
use App\Models\User; use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
use function Pest\Laravel\actingAs; use function Pest\Laravel\actingAs;
use function Pest\Laravel\get; use function Pest\Laravel\get;
use function Pest\Laravel\post; use function Pest\Laravel\post;

View File

@ -4,12 +4,11 @@ use App\Models\Entry;
use App\Models\School; use App\Models\School;
use App\Models\Student; use App\Models\Student;
use App\Models\User; use App\Models\User;
use App\Services\EntryService;
use App\Services\Invoice\InvoiceOneFeePerEntry; use App\Services\Invoice\InvoiceOneFeePerEntry;
use App\Settings; use App\Settings;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\App;
use function Pest\Laravel\actingAs; use function Pest\Laravel\actingAs;
use function Pest\Laravel\get; use function Pest\Laravel\get;
@ -65,7 +64,7 @@ it('has a new school link', function () {
}); });
it('shows school data', function () { it('shows school data', function () {
// Arrange // Arrange
#$invoiceDataService = new App\Services\Invoice\InvoiceOneFeePerEntry(new App\Services\EntryService(new App\Services\AuditionService())); //$invoiceDataService = new App\Services\Invoice\InvoiceOneFeePerEntry(new App\Services\EntryService(new App\Services\AuditionService()));
$invoiceDataService = App::make(InvoiceOneFeePerEntry::class); $invoiceDataService = App::make(InvoiceOneFeePerEntry::class);
Settings::set('school_fees', 1000); Settings::set('school_fees', 1000);
Settings::set('late_fee', 2500); Settings::set('late_fee', 2500);

View File

@ -1,6 +1,5 @@
<?php <?php
use App\Models\Entry;
use App\Models\School; use App\Models\School;
use App\Models\SchoolEmailDomain; use App\Models\SchoolEmailDomain;
use App\Models\Student; use App\Models\Student;

View File

@ -4,6 +4,7 @@ use App\Models\School;
use App\Models\Student; use App\Models\Student;
use App\Models\User; use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
use function Pest\Laravel\actingAs; use function Pest\Laravel\actingAs;
use function Pest\Laravel\get; use function Pest\Laravel\get;
use function Pest\Laravel\post; use function Pest\Laravel\post;

View File

@ -11,6 +11,7 @@ use App\Settings;
use Database\Seeders\ScoreAllAuditions; use Database\Seeders\ScoreAllAuditions;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use function Pest\Laravel\actingAs; use function Pest\Laravel\actingAs;
uses(RefreshDatabase::class); uses(RefreshDatabase::class);

View File

@ -3,7 +3,6 @@
use App\Models\Audition; use App\Models\Audition;
use App\Models\Entry; use App\Models\Entry;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Log;
uses(RefreshDatabase::class); uses(RefreshDatabase::class);

View File

@ -78,7 +78,7 @@ it('sets the draw_number column on each entry in the audition based on the rando
// Arrange // Arrange
$audition = Audition::factory()->hasEntries(10)->create(); $audition = Audition::factory()->hasEntries(10)->create();
Entry::all()->each(fn ($entry) => expect($entry->draw_number)->toBeNull()); Entry::all()->each(fn ($entry) => expect($entry->draw_number)->toBeNull());
#$drawService = new DrawService(); //$drawService = new DrawService();
$drawService = App::make(DrawService::class); $drawService = App::make(DrawService::class);
$drawService->runOneDraw($audition); $drawService->runOneDraw($audition);
// Act & Assert // Act & Assert
@ -88,7 +88,7 @@ it('only sets draw numbers in the specified audition', function () {
// Arrange // Arrange
$audition = Audition::factory()->hasEntries(10)->create(); $audition = Audition::factory()->hasEntries(10)->create();
$bonusEntry = Entry::factory()->create(); $bonusEntry = Entry::factory()->create();
#$drawService = new DrawService(); //$drawService = new DrawService();
$drawService = App::make(DrawService::class); $drawService = App::make(DrawService::class);
$drawService->runOneDraw($audition); $drawService->runOneDraw($audition);
// Act & Assert // Act & Assert

View File

@ -12,7 +12,7 @@ use Illuminate\Support\Facades\App;
uses(RefreshDatabase::class); uses(RefreshDatabase::class);
beforeEach(function () { beforeEach(function () {
#$this->scoreService = new ScoreService(); //$this->scoreService = new ScoreService();
$this->scoreService = App::make(ScoreService::class); $this->scoreService = App::make(ScoreService::class);
}); });