Stash old tests

This commit is contained in:
Matt Young 2025-06-30 15:04:47 -05:00
parent 4faeb63c95
commit 9bbcb2fae3
86 changed files with 47 additions and 47 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

@ -5,7 +5,7 @@ namespace App\Http\Controllers\Admin;
use App\Actions\Entries\CreateEntry; use App\Actions\Entries\CreateEntry;
use App\Actions\Entries\UpdateEntry; use App\Actions\Entries\UpdateEntry;
use App\Actions\Tabulation\CalculateScoreSheetTotal; use App\Actions\Tabulation\CalculateScoreSheetTotal;
use App\Exceptions\ManageEntryException; use App\Exceptions\AuditionAdminException;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Audition; use App\Models\Audition;
use App\Models\AuditLogEntry; use App\Models\AuditLogEntry;
@ -133,7 +133,7 @@ class EntryController extends Controller
try { try {
$entry = $creator($validData['student_id'], $validData['audition_id'], $enter_for); $entry = $creator($validData['student_id'], $validData['audition_id'], $enter_for);
} catch (ManageEntryException $ex) { } catch (AuditionAdminException $ex) {
return redirect()->route('admin.entries.index')->with('error', $ex->getMessage()); return redirect()->route('admin.entries.index')->with('error', $ex->getMessage());
} }
if ($validData['late_fee_waived']) { if ($validData['late_fee_waived']) {
@ -193,7 +193,7 @@ class EntryController extends Controller
} }
try { try {
$updater($entry, $validData); $updater($entry, $validData);
} catch (ManageEntryException $e) { } catch (AuditionAdminException $e) {
return redirect()->route('admin.entries.index')->with('error', $e->getMessage()); return redirect()->route('admin.entries.index')->with('error', $e->getMessage());
} }
if ($validData['late_fee_waived']) { if ($validData['late_fee_waived']) {

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

@ -165,7 +165,7 @@ it('saves the score with a properly formatted subscore object', function () {
expect($checkScoreSheet->exists())->toBeTrue() expect($checkScoreSheet->exists())->toBeTrue()
->and($checkScoreSheet->subscores)->toBe($desiredReturn); ->and($checkScoreSheet->subscores)->toBe($desiredReturn);
}); });
it('throws an exception of the entry already has a score by the judge', function() { it('throws an exception of the entry already has a score by the judge', function () {
// Arrange // Arrange
loadSampleAudition(); loadSampleAudition();
$judge = User::factory()->create(); $judge = User::factory()->create();
@ -184,7 +184,7 @@ it('throws an exception of the entry already has a score by the judge', function
// Assert // Assert
enterScore($judge, $entry, $scores); enterScore($judge, $entry, $scores);
})->throws(ScoreEntryException::class, 'That judge has already entered scores for that entry'); })->throws(ScoreEntryException::class, 'That judge has already entered scores for that entry');
it('allows an existing sore sheet to be updated', function() { it('allows an existing sore sheet to be updated', function () {
// Arrange // Arrange
loadSampleAudition(); loadSampleAudition();
$judge = User::factory()->create(); $judge = 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

@ -9,7 +9,7 @@ uses(RefreshDatabase::class);
it('has auditions', function () { it('has auditions', function () {
$event = Event::factory()->create(); $event = Event::factory()->create();
Audition::factory()->create(['event_id' => $event->id, 'name' => 'Digereedoo','score_order' => 0]); Audition::factory()->create(['event_id' => $event->id, 'name' => 'Digereedoo', 'score_order' => 0]);
Audition::factory()->count(7)->create(['event_id' => $event->id]); Audition::factory()->count(7)->create(['event_id' => $event->id]);
expect($event->auditions->count())->toBe(8) expect($event->auditions->count())->toBe(8)

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

@ -146,14 +146,14 @@ it('correctly shows a flag when the audition is flagged as seated', function ()
return $viewAuditionData[$audition->id]['seatsPublished'] === true; return $viewAuditionData[$audition->id]['seatsPublished'] === true;
}); });
}); });
it('shows seating auditions', function() { it('shows seating auditions', function () {
$audition = Audition::factory()->create(); $audition = Audition::factory()->create();
actAsAdmin(); actAsAdmin();
get(route('seating.status')) get(route('seating.status'))
->assertOk() ->assertOk()
->assertSee($audition->name); ->assertSee($audition->name);
}); });
it('does not show advancement only auditions', function() { it('does not show advancement only auditions', function () {
$audition = Audition::factory()->advancementOnly()->create(); $audition = Audition::factory()->advancementOnly()->create();
actAsAdmin(); actAsAdmin();
get(route('seating.status')) get(route('seating.status'))

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

@ -87,7 +87,7 @@ it('shows a box with scores if the entry is scored', function () {
// Arrange // Arrange
$judges = User::factory()->count(3)->create(); $judges = User::factory()->count(3)->create();
$room = Room::factory()->create(); $room = Room::factory()->create();
$judges->each(fn($judge) => $room->addJudge($judge->id)); $judges->each(fn ($judge) => $room->addJudge($judge->id));
$scoringGuide = ScoringGuide::factory()->create(); $scoringGuide = ScoringGuide::factory()->create();
SubscoreDefinition::factory()->count(5)->create(['scoring_guide_id' => $scoringGuide->id]); SubscoreDefinition::factory()->count(5)->create(['scoring_guide_id' => $scoringGuide->id]);
$audition = Audition::factory()->create(['room_id' => $room->id, 'scoring_guide_id' => $scoringGuide->id]); $audition = Audition::factory()->create(['room_id' => $room->id, 'scoring_guide_id' => $scoringGuide->id]);
@ -100,6 +100,6 @@ it('shows a box with scores if the entry is scored', function () {
$response->assertOk() $response->assertOk()
->assertSee('WARNING') ->assertSee('WARNING')
->assertSee('existing scores'); ->assertSee('existing scores');
$judges->each(fn($judge) => $response->assertSee($judge->full_name())); $judges->each(fn ($judge) => $response->assertSee($judge->full_name()));
}); });

View File

@ -9,11 +9,11 @@ use Illuminate\Support\Facades\App;
uses(RefreshDatabase::class); uses(RefreshDatabase::class);
beforeEach(function() { beforeEach(function () {
$this->entryService = App::make(EntryService::class); $this->entryService = App::make(EntryService::class);
}); });
it('checks if an entry is late', function() { it('checks if an entry is late', function () {
$openAudition = Audition::factory()->create(['entry_deadline' => Carbon::tomorrow()]); $openAudition = Audition::factory()->create(['entry_deadline' => Carbon::tomorrow()]);
$closedAudition = Audition::factory()->create(['entry_deadline' => Carbon::yesterday()]); $closedAudition = Audition::factory()->create(['entry_deadline' => Carbon::yesterday()]);

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);
}); });

View File

@ -7,13 +7,13 @@ use Illuminate\Support\Facades\App;
uses(RefreshDatabase::class); uses(RefreshDatabase::class);
beforeEach(function() { beforeEach(function () {
$this->userService = App::make(UserService::class); $this->userService = App::make(UserService::class);
}); });
it('checks if a user exists', function() { it('checks if a user exists', function () {
$realUser = User::factory()->create(); $realUser = User::factory()->create();
$fakeUser = User::factory()->make(); $fakeUser = User::factory()->make();
expect ($this->userService->userExists($realUser))->toBeTrue(); expect($this->userService->userExists($realUser))->toBeTrue();
expect ($this->userService->userExists($fakeUser))->toBeFalse(); expect($this->userService->userExists($fakeUser))->toBeFalse();
}); });