73 lines
2.8 KiB
PHP
73 lines
2.8 KiB
PHP
<?php
|
|
|
|
use App\Actions\Entries\CreateEntry;
|
|
use App\Models\Audition;
|
|
use App\Models\Ensemble;
|
|
use App\Models\Event;
|
|
use App\Models\Seat;
|
|
use App\Models\SeatingLimit;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
$this->event = Event::factory()->create();
|
|
$this->ensemble = Ensemble::factory()->create([
|
|
'event_id' => $this->event->id, 'name' => 'Test Ensemble',
|
|
]);
|
|
$this->audition = Audition::factory()->create([
|
|
'event_id' => $this->event->id, 'minimum_grade' => 1, 'maximum_grade' => 12,
|
|
]);
|
|
$this->student = \App\Models\Student::factory()->create(['grade' => 12]);
|
|
$this->entry = app(CreateEntry::class)($this->student, $this->audition);
|
|
$this->seatingLimit = SeatingLimit::create([
|
|
'ensemble_id' => $this->ensemble->id,
|
|
'audition_id' => $this->audition->id,
|
|
'maximum_accepted' => 3,
|
|
]);
|
|
$this->seat = Seat::create([
|
|
'ensemble_id' => $this->ensemble->id,
|
|
'audition_id' => $this->audition->id,
|
|
'seat' => 1,
|
|
'entry_id' => $this->entry->id,
|
|
]);
|
|
|
|
});
|
|
|
|
it('can return its event', function () {
|
|
expect($this->ensemble->event->id)->toEqual($this->event->id);
|
|
});
|
|
|
|
it('can return its auditions', function () {
|
|
expect($this->ensemble->auditions()->count())->toEqual(1)
|
|
->and($this->ensemble->auditions()->first())->toBeInstanceOf(\App\Models\Audition::class);
|
|
});
|
|
|
|
it('can return its seating limits', function () {
|
|
expect($this->ensemble->seatingLimits()->count())->toEqual(1)
|
|
->and($this->ensemble->seatingLimits()->first())->toBeInstanceOf(\App\Models\SeatingLimit::class);
|
|
});
|
|
|
|
it('can return its seats', function () {
|
|
expect($this->ensemble->seats()->count())->toEqual(1)
|
|
->and($this->ensemble->seats()->first())->toBeInstanceOf(\App\Models\Seat::class);
|
|
});
|
|
|
|
it('can return ensembles for a given auditions event', function () {
|
|
$newEvent = \App\Models\Event::factory()->create();
|
|
$newEnsemble = Ensemble::factory()->create(['event_id' => $newEvent->id]);
|
|
expect(Ensemble::forAudition($this->audition->id)->count())->toBe(1)
|
|
->and(Ensemble::forAudition($this->audition->id)->first())->toBeInstanceOf(Ensemble::class)
|
|
->and(Ensemble::forAudition($this->audition->id)->first()->id)->toEqual($this->ensemble->id)
|
|
->and(Ensemble::count())->toBe(2);
|
|
});
|
|
|
|
it('can return ensembles for a given event', function () {
|
|
$newEvent = \App\Models\Event::factory()->create();
|
|
$newEnsemble = Ensemble::factory()->create(['event_id' => $newEvent->id]);
|
|
expect(Ensemble::forEvent($this->event->id)->count())->toBe(1)
|
|
->and(Ensemble::forEvent($this->event->id)->first())->toBeInstanceOf(Ensemble::class)
|
|
->and(Ensemble::forEvent($this->event->id)->first()->id)->toEqual($this->ensemble->id)
|
|
->and(Ensemble::count())->toBe(2);
|
|
});
|