event = Event::factory()->create(); $this->audition = Audition::factory()->create(['event_id' => $this->event->id]); $this->entries = Entry::factory()->count(3)->create(['audition_id' => $this->audition->id]); $score = 100; foreach ($this->entries as $entry) { EntryTotalScore::create([ 'entry_id' => $entry->id, 'seating_total' => $score, 'advancement_total' => $score, 'seating_subscore_totals' => json_encode([$score, $score]), 'advancement_subscore_totals' => json_encode([$score, $score]), ]); $score--; } $this->ensemble1 = Ensemble::factory()->create(['event_id' => $this->event->id, 'rank' => 1]); $this->ensemble2 = Ensemble::factory()->create(['event_id' => $this->event->id, 'rank' => 2]); $this->ensemble3 = Ensemble::factory()->create(['event_id' => $this->event->id, 'rank' => 3]); }); it('saves proposed seating to the session', function () { actAsAdmin(); $response = $this->post(route('seating.audition.draftSeats', $this->audition), [ 'ensemble' => [ $this->ensemble1->id => 2, $this->ensemble2->id => 2, ], ]); $response->assertRedirect(route('seating.audition', $this->audition)); $sessionKey = 'proposedSeatingArray-'.$this->audition->id; $response->assertSessionHas($sessionKey, [ 1 => [ 'ensemble_id' => $this->ensemble1->id, 'ensemble_name' => $this->ensemble1->name, 'accept_count' => 2, 'seats' => [ 1 => [ 'seat' => 1, 'entry_id' => $this->entries[0]->id, 'entry_name' => $this->entries[0]->student->full_name(), 'entry_school' => $this->entries[0]->student->school->name, ], 2 => [ 'seat' => 2, 'entry_id' => $this->entries[1]->id, 'entry_name' => $this->entries[1]->student->full_name(), 'entry_school' => $this->entries[1]->student->school->name, ], ], ], 2 => [ 'ensemble_id' => $this->ensemble2->id, 'ensemble_name' => $this->ensemble2->name, 'accept_count' => 2, 'seats' => [ 1 => [ 'seat' => 1, 'entry_id' => $this->entries[2]->id, 'entry_name' => $this->entries[2]->student->full_name(), 'entry_school' => $this->entries[2]->student->school->name, ], ], ], ]); }); it('can clear proposed seats', function () { actAsAdmin(); $response = $this->post(route('seating.audition.draftSeats', $this->audition), [ 'ensemble' => [ $this->ensemble1->id => 2, $this->ensemble2->id => 2, ], ]); $response->assertRedirect(route('seating.audition', $this->audition)); $sessionKey = 'proposedSeatingArray-'.$this->audition->id; $response->assertSessionHas($sessionKey); $response2 = $this->post(route('seating.audition.clearDraft', $this->audition)); $response2->assertRedirect(route('seating.audition', $this->audition)); $response2->assertSessionMissing($sessionKey); });