83 lines
2.7 KiB
PHP
83 lines
2.7 KiB
PHP
<?php
|
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */
|
|
|
|
use App\Actions\Tabulation\PublishSeats;
|
|
use App\Actions\Tabulation\UnpublishSeats;
|
|
use App\Models\Audition;
|
|
use App\Models\Ensemble;
|
|
use App\Models\Entry;
|
|
use App\Models\Seat;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
$this->audition = Audition::factory()->create(['minimum_grade' => 1, 'maximum_grade' => 14]);
|
|
$this->windEnsemble = Ensemble::create([
|
|
'event_id' => $this->audition->event_id,
|
|
'name' => 'Wind Ensemble',
|
|
'code' => 'we',
|
|
'rank' => 1,
|
|
]);
|
|
$this->alternates = Ensemble::create([
|
|
'event_id' => $this->audition->event_id,
|
|
'name' => 'Alternates',
|
|
'code' => 'alt',
|
|
'rank' => 2,
|
|
]);
|
|
$this->entries = Entry::factory()->count(10)->create(['audition_id' => $this->audition->id]);
|
|
$this->seatingArray = [
|
|
1 => [
|
|
'ensemble_id' => $this->windEnsemble->id,
|
|
'audition_id' => $this->audition->id,
|
|
'entry_id' => $this->entries[0]->id,
|
|
'seat' => 1,
|
|
],
|
|
2 => [
|
|
'ensemble_id' => $this->windEnsemble->id,
|
|
'audition_id' => $this->audition->id,
|
|
'entry_id' => $this->entries[1]->id,
|
|
'seat' => 2,
|
|
],
|
|
3 => [
|
|
'ensemble_id' => $this->windEnsemble->id,
|
|
'audition_id' => $this->audition->id,
|
|
'entry_id' => $this->entries[2]->id,
|
|
'seat' => 3,
|
|
],
|
|
4 => [
|
|
'ensemble_id' => $this->alternates->id,
|
|
'audition_id' => $this->audition->id,
|
|
'entry_id' => $this->entries[3]->id,
|
|
'seat' => 1,
|
|
],
|
|
5 => [
|
|
'ensemble_id' => $this->alternates->id,
|
|
'audition_id' => $this->audition->id,
|
|
'entry_id' => $this->entries[4]->id,
|
|
'seat' => 2,
|
|
],
|
|
];
|
|
$this->publisher = app(PublishSeats::class);
|
|
$this->unpublisher = app(UnpublishSeats::class);
|
|
($this->publisher)($this->audition, $this->seatingArray);
|
|
$this->get(route('results'));
|
|
});
|
|
|
|
it('marks an auditions seats unpublished', function () {
|
|
($this->unpublisher)($this->audition);
|
|
expect($this->audition->hasFlag('seats_published'))->toBeFalse();
|
|
});
|
|
|
|
it('removes seats from the ensembles', function () {
|
|
($this->unpublisher)($this->audition);
|
|
expect(Seat::where('audition_id', $this->audition->id)->count())->toBe(0);
|
|
});
|
|
|
|
it('clears results and set list cache', function () {
|
|
($this->unpublisher)($this->audition);
|
|
expect(Cache::has('publicResultsPage'))->toBeFalse()
|
|
->and(Cache::has('resultsSeatList'))->toBeFalse();
|
|
});
|