create(); post(route('entry-flags.enterNoShow', $entry)) ->assertRedirect(route('home')); actAsAdmin(); /** @noinspection PhpUnhandledExceptionInspection */ post(route('entry-flags.enterNoShow', $entry)) ->assertSessionHasNoErrors() ->assertSessionHas('success', 'No Show has been entered for '.$entry->audition->name.' #'.$entry->draw_number.' (ID: '.$entry->id.').') ->assertRedirect(route('entry-flags.noShowSelect')); actAsTab(); /** @noinspection PhpUnhandledExceptionInspection */ post(route('entry-flags.enterNoShow', $entry)) ->assertSessionHasNoErrors() ->assertSessionHas('success', 'No Show has been entered for '.$entry->audition->name.' #'.$entry->draw_number.' (ID: '.$entry->id.').') ->assertRedirect(route('entry-flags.noShowSelect')); }); it('will not record an entry in a published audition as a no show', function () { $entry1 = Entry::factory()->create(); $entry2 = Entry::factory()->create(); $entry1->audition->addFlag('seats_published'); $entry2->audition->addFlag('advancement_published'); actAsAdmin(); post(route('entry-flags.enterNoShow', $entry1)) ->assertRedirect(route('entry-flags.noShowSelect')) ->assertSessionHas('error', 'Cannot enter a no-show for an entry in an audition where seats are published'); post(route('entry-flags.enterNoShow', $entry2)) ->assertRedirect(route('entry-flags.noShowSelect')) ->assertSessionHas('error', 'Cannot enter a no-show for an entry in an audition where advancement is published'); }); it('deletes all scores for an entry when a no-show is entered', function () { $entry = Entry::factory()->create(); $judges = User::factory()->count(3)->create(); $entry->scoreSheets()->create(['user_id' => $judges[0]->id, 'subscores' => 10]); $entry->scoreSheets()->create(['user_id' => $judges[1]->id, 'subscores' => 10]); $entry->scoreSheets()->create(['user_id' => $judges[2]->id, 'subscores' => 10]); expect($entry->scoreSheets()->count())->toBe(3); actAsAdmin(); post(route('entry-flags.enterNoShow', $entry)); expect($entry->scoreSheets()->count())->toBe(0); }); it('adds a no_show flag to the entry', function () { // Arrange $entry = Entry::factory()->create(); // Act & Assert actAsAdmin(); post(route('entry-flags.enterNoShow', $entry)); expect(Entry::find($entry->id)->hasFlag('no_show'))->toBeTrue(); });