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;
use App\Exceptions\AuditionAdminException;
use App\Exceptions\ManageEntryException;
use App\Models\Audition;
use App\Models\AuditLogEntry;
@ -83,29 +84,29 @@ class CreateEntry
{
// Make sure it's a valid student
if (! $student || ! $student->exists()) {
throw new ManageEntryException('Invalid student provided');
throw new AuditionAdminException('Invalid student provided');
}
// Make sure the audition is valid
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
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
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')) {
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
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) {
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;
use App\Actions\Entries\CreateEntry;
use App\Exceptions\ManageEntryException;
use App\Exceptions\AuditionAdminException;
use App\Models\Audition;
use App\Models\AuditLogEntry;
use App\Models\Entry;
@ -57,7 +57,7 @@ class EntryController extends Controller
try {
$creator($validData['student_id'], $validData['audition_id'], $enter_for);
} catch (ManageEntryException $ex) {
} catch (AuditionAdminException $ex) {
return redirect()->route('entries.index')->with('error', $ex->getMessage());
}

View File

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

View File

@ -12,7 +12,6 @@ use Illuminate\Support\Facades\Artisan;
uses(RefreshDatabase::class);
it('throws an exception if an invalid mode is called for', function () {
$calculator = app(CalculateScoreSheetTotal::class);
$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()
->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
loadSampleAudition();
$judge = User::factory()->create();
@ -184,7 +184,7 @@ it('throws an exception of the entry already has a score by the judge', function
// Assert
enterScore($judge, $entry, $scores);
})->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
loadSampleAudition();
$judge = User::factory()->create();

View File

@ -1,6 +1,5 @@
<?php
use App\Actions\Tabulation\AllowForOlympicScoring;
use App\Actions\Tabulation\RankAuditionEntries;
use App\Exceptions\TabulationException;
use App\Models\Audition;
@ -14,13 +13,13 @@ use Illuminate\Support\Facades\Artisan;
uses(RefreshDatabase::class);
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->rank('wrong', Audition::factory()->create());
})->throws(TabulationException::class, 'Mode must be seating or advancement');
it('throws an exception if an invalid audition is provided', function () {
// Arrange
#$ranker = new RankAuditionEntries(new AllJudgesCount());
//$ranker = new RankAuditionEntries(new AllJudgesCount());
$ranker = App::make(RankAuditionEntries::class);
// Act & Assert
$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();
$entries = Entry::factory()->seatingOnly()->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);
// Act
$return = $ranker->rank('seating', $audition);

View File

@ -9,7 +9,7 @@ uses(RefreshDatabase::class);
it('has auditions', function () {
$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]);
expect($event->auditions->count())->toBe(8)

View File

@ -19,7 +19,7 @@ beforeEach(function () {
it('has an audition', function () {
expect($this->seatingLimit->audition->name)->toBe($this->audition->name)
->and($this->seatingLimit)->toBeInstanceOf(SeatingLimit::class);
->and($this->seatingLimit)->toBeInstanceOf(SeatingLimit::class);
});
it('has an ensemble', function () {

View File

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

View File

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

View File

@ -4,12 +4,11 @@ use App\Models\Entry;
use App\Models\School;
use App\Models\Student;
use App\Models\User;
use App\Services\EntryService;
use App\Services\Invoice\InvoiceOneFeePerEntry;
use App\Settings;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\App;
use function Pest\Laravel\actingAs;
use function Pest\Laravel\get;
@ -65,7 +64,7 @@ it('has a new school link', function () {
});
it('shows school data', function () {
// 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);
Settings::set('school_fees', 1000);
Settings::set('late_fee', 2500);

View File

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

View File

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

View File

@ -11,6 +11,7 @@ use App\Settings;
use Database\Seeders\ScoreAllAuditions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Artisan;
use function Pest\Laravel\actingAs;
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;
});
});
it('shows seating auditions', function() {
it('shows seating auditions', function () {
$audition = Audition::factory()->create();
actAsAdmin();
get(route('seating.status'))
->assertOk()
->assertSee($audition->name);
});
it('does not show advancement only auditions', function() {
it('does not show advancement only auditions', function () {
$audition = Audition::factory()->advancementOnly()->create();
actAsAdmin();
get(route('seating.status'))

View File

@ -3,7 +3,6 @@
use App\Models\Audition;
use App\Models\Entry;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Log;
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
$audition = Audition::factory()->hasEntries(10)->create();
Entry::all()->each(fn ($entry) => expect($entry->draw_number)->toBeNull());
#$drawService = new DrawService();
//$drawService = new DrawService();
$drawService = App::make(DrawService::class);
$drawService->runOneDraw($audition);
// Act & Assert
@ -88,7 +88,7 @@ it('only sets draw numbers in the specified audition', function () {
// Arrange
$audition = Audition::factory()->hasEntries(10)->create();
$bonusEntry = Entry::factory()->create();
#$drawService = new DrawService();
//$drawService = new DrawService();
$drawService = App::make(DrawService::class);
$drawService->runOneDraw($audition);
// Act & Assert

View File

@ -86,12 +86,12 @@ it('posts to entry-flags.undoNoShow and has a remove button if the entry is alre
it('shows a box with scores if the entry is scored', function () {
// Arrange
$judges = User::factory()->count(3)->create();
$room = Room::factory()->create();
$judges->each(fn($judge) => $room->addJudge($judge->id));
$room = Room::factory()->create();
$judges->each(fn ($judge) => $room->addJudge($judge->id));
$scoringGuide = ScoringGuide::factory()->create();
SubscoreDefinition::factory()->count(5)->create(['scoring_guide_id' => $scoringGuide->id]);
$audition = Audition::factory()->create(['room_id' => $room->id, 'scoring_guide_id' => $scoringGuide->id]);
$entry = Entry::factory()->create(['audition_id' => $audition->id]);
$entry = Entry::factory()->create(['audition_id' => $audition->id]);
// Run the ScoreAllAuditions seeder
Artisan::call('db:seed', ['--class' => 'ScoreAllAuditions']);
// Act & Assert
@ -100,6 +100,6 @@ it('shows a box with scores if the entry is scored', function () {
$response->assertOk()
->assertSee('WARNING')
->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);
beforeEach(function() {
beforeEach(function () {
$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()]);
$closedAudition = Audition::factory()->create(['entry_deadline' => Carbon::yesterday()]);

View File

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

View File

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