Create Model Event test

This commit is contained in:
Matt Young 2024-07-01 10:23:13 -05:00
parent f95b89c7ac
commit 0c1a157a94
2 changed files with 28 additions and 46 deletions

View File

@ -1,46 +0,0 @@
<?php
use App\Models\Entry;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('only returns entries for seating with forSeating scope', function () {
// Arrange
Entry::factory()->advanceOnly()->create();
$seatingEntry = Entry::factory()->create();
// Act & Assert
expect(Entry::forSeating()->get())
->toHaveCount(1)
->first()->id->toEqual($seatingEntry->id);
});
it('only returns entries for advancement with for forAdvancement scope', function () {
// Arrange
Entry::factory()->seatingOnly()->create();
$advancementEntry = Entry::factory()->create();
// Act & Assert
expect(Entry::forAdvancement()->get())
->toHaveCount(1)
->first()->id->toEqual($advancementEntry->id);
});
it('only returns entries that do not have a declined, no-show, or failed-prelim flag with available scope',
function () {
// Arrange
$availableEntry = Entry::factory()->create();
$declinedEntry = Entry::factory()->create();
$noShowEntry = Entry::factory()->create();
$failedPrelimEntry = Entry::factory()->create();
$declinedEntry->addFlag('declined');
$noShowEntry->addFlag('no-show');
$failedPrelimEntry->addFlag('failed-prelim');
// Act & Assert
expect(Entry::available()->get())
->toHaveCount(1)
->first()->id->toEqual($availableEntry->id);
});

View File

@ -0,0 +1,28 @@
<?php
use App\Models\Audition;
use App\Models\Ensemble;
use App\Models\Event;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('has auditions', function () {
$event = Event::factory()->create();
$ddAudition = Audition::factory()->create(['event_id' => $event->id, 'name' => 'Digereedoo']);
Audition::factory()->count(7)->create(['event_id' => $event->id]);
expect($event->auditions->count())->toBe(8)
->and($event->auditions->first()->name)->toBe('Digereedoo');
});
it('has ensembles', function () {
// Arrange
$event = Event::factory()->create();
$ensemble = Ensemble::factory()->create(['event_id' => $event->id, 'name' => 'Symphonic Concert Wind Band']);
Ensemble::factory()->count(7)->create();
// Act & Assert
expect($event->ensembles->count())->toBe(1)
->and($event->ensembles->first()->name)->toBe('Symphonic Concert Wind Band');
});