entry = Entry::factory()->create(); }); afterEach(function () { Cache::flush(); }); it('it throws an exception if we try to add a declined flag while seats are published', function () { $this->entry->audition->addFlag('seats_published'); $this->entry->refresh(); $this->entry->addFlag('declined'); })->throws(AuditionAdminException::class, 'Cannot change flag for published auditions'); it('it throws an exception if we try to add a no_show flag while seats are published', function () { $this->entry->audition->addFlag('seats_published'); $this->entry->refresh(); $this->entry->addFlag('no_show'); })->throws(AuditionAdminException::class, 'Cannot change flag for published auditions'); it('it throws an exception if we try to add a failed_prelim flag while seats are published', function () { $this->entry->audition->addFlag('seats_published'); $this->entry->refresh(); $this->entry->addFlag('failed_prelim'); })->throws(AuditionAdminException::class, 'Cannot change flag for published auditions'); it('it throws an exception if we try to add a declined flag while advancement is published', function () { $this->entry->audition->addFlag('advancement_published'); $this->entry->refresh(); $this->entry->addFlag('declined'); })->throws(AuditionAdminException::class, 'Cannot change flag for published auditions'); it('it throws an exception if we try to add a no_show flag while advancement is published', function () { $this->entry->audition->addFlag('advancement_published'); $this->entry->refresh(); $this->entry->addFlag('no_show'); })->throws(AuditionAdminException::class, 'Cannot change flag for published auditions'); it('it throws an exception if we try to add a failed_prelim flag while advancement is published', function () { $this->entry->audition->addFlag('advancement_published'); $this->entry->refresh(); $this->entry->addFlag('failed_prelim'); })->throws(AuditionAdminException::class, 'Cannot change flag for published auditions'); it('clears caches when adding a flag', function () { Cache::put('rank_advancement_'.$this->entry->audition_id, 'test', 60); Cache::put('rank_seating_'.$this->entry->audition_id, 'test', 60); expect(Cache::has('rank_advancement_'.$this->entry->audition_id))->toBeTrue() ->and(Cache::has('rank_seating_'.$this->entry->audition_id))->toBeTrue(); $this->entry->addFlag('declined'); expect(Cache::has('rank_advancement_'.$this->entry->audition_id))->toBeFalse() ->and(Cache::has('rank_seating_'.$this->entry->audition_id))->toBeFalse(); }); it('it throws an exception if we try to delete a declined flag while seats are published', function () { $this->entry->addFlag('declined'); $this->entry->audition->addFlag('seats_published'); $this->entry->refresh(); $this->entry->removeFlag('declined'); })->throws(AuditionAdminException::class, 'Cannot change flag for published auditions'); it('it throws an exception if we try to delete a no_show flag while seats are published', function () { $this->entry->addFlag('no_show'); $this->entry->audition->addFlag('seats_published'); $this->entry->refresh(); $this->entry->removeFlag('no_show'); })->throws(AuditionAdminException::class, 'Cannot change flag for published auditions'); it('it throws an exception if we try to delete a failed_prelim flag while seats are published', function () { $this->entry->addFlag('failed_prelim'); $this->entry->audition->addFlag('seats_published'); $this->entry->refresh(); $this->entry->removeFlag('failed_prelim'); })->throws(AuditionAdminException::class, 'Cannot change flag for published auditions'); it('it throws an exception if we try to delete a declined flag while advancement is published', function () { $this->entry->addFlag('declined'); $this->entry->audition->addFlag('advancement_published'); $this->entry->refresh(); $this->entry->removeFlag('declined'); })->throws(AuditionAdminException::class, 'Cannot change flag for published auditions'); it('it throws an exception if we try to delete a no_show flag while advancement is published', function () { $this->entry->addFlag('no_show'); $this->entry->audition->addFlag('advancement_published'); $this->entry->refresh(); $this->entry->removeFlag('no_show'); })->throws(AuditionAdminException::class, 'Cannot change flag for published auditions'); it('it throws an exception if we try to delete a failed_prelim flag while advancement is published', function () { $this->entry->addFlag('failed_prelim'); $this->entry->audition->addFlag('advancement_published'); $this->entry->refresh(); $this->entry->removeFlag('failed_prelim'); })->throws(AuditionAdminException::class, 'Cannot change flag for published auditions'); it('clears caches when deleting a flag', function () { $this->entry->addFlag('no_show'); Cache::put('rank_advancement_'.$this->entry->audition_id, 'test', 60); Cache::put('rank_seating_'.$this->entry->audition_id, 'test', 60); expect(Cache::has('rank_advancement_'.$this->entry->audition_id))->toBeTrue() ->and(Cache::has('rank_seating_'.$this->entry->audition_id))->toBeTrue(); EntryFlag::first()->delete(); expect(Cache::has('rank_advancement_'.$this->entry->audition_id))->toBeFalse() ->and(Cache::has('rank_seating_'.$this->entry->audition_id))->toBeFalse(); });