116 lines
3.6 KiB
PHP
116 lines
3.6 KiB
PHP
<?php
|
|
|
|
use App\Models\Audition;
|
|
use App\Models\Entry;
|
|
use App\Settings;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
use function Pest\Laravel\get;
|
|
|
|
uses(RefreshDatabase::class);
|
|
beforeEach(function () {
|
|
|
|
$this->entry = Entry::factory()->create();
|
|
});
|
|
|
|
it('does not respond to an ordinary user', function () {
|
|
actAsNormal();
|
|
get(route('admin.entries.edit', $this->entry))
|
|
->assertRedirect(route('dashboard'));
|
|
});
|
|
it('does not respond to a guest', function () {
|
|
// Act & Assert
|
|
get(route('admin.entries.edit', $this->entry))
|
|
->assertRedirect(route('home'));
|
|
});
|
|
it('does not respond if the audition is published', function () {
|
|
// Arrange
|
|
actAsAdmin();
|
|
$this->entry->audition->addFlag('seats_published');
|
|
get(route('admin.entries.edit', $this->entry))
|
|
->assertRedirect(route('admin.entries.index'))
|
|
->assertSessionHas('error', 'Entries in auditions with seats published cannot be modified');
|
|
});
|
|
it('does not respond if advancement for the audition is published', function () {
|
|
// Arrange
|
|
actAsAdmin();
|
|
$this->entry->audition->addFlag('advancement_published');
|
|
get(route('admin.entries.edit', $this->entry))
|
|
->assertRedirect(route('admin.entries.index'))
|
|
->assertSessionHas('error', 'Entries in auditions with advancement results published cannot be modified');
|
|
});
|
|
it('has a delete link', function () {
|
|
// Arrange
|
|
actAsAdmin();
|
|
// Act & Assert
|
|
get(route('admin.entries.edit', $this->entry))
|
|
->assertSee('<input type="hidden" name="_method" value="DELETE">', false);
|
|
});
|
|
it('has a dropdown for all auditions', function () {
|
|
// Arrange
|
|
$auditions = Audition::factory()->count(5)->create();
|
|
actAsAdmin();
|
|
$response = get(route('admin.entries.edit', $this->entry));
|
|
foreach ($auditions as $audition) {
|
|
$response->assertSeeInOrder([
|
|
'option',
|
|
'value=',
|
|
$audition->id,
|
|
'option',
|
|
], false);
|
|
$response->assertSeeInOrder([
|
|
'option',
|
|
'value=',
|
|
$this->entry->audition->id,
|
|
'selected',
|
|
'option',
|
|
], false);
|
|
}
|
|
});
|
|
it('shows checkboxes for entry types only if advancement is enabled', function () {
|
|
actAsAdmin();
|
|
get(route('admin.entries.edit', $this->entry))
|
|
->assertSee('Enter for '.auditionSetting('auditionAbbreviation'))
|
|
->assertSee('Enter for '.auditionSetting('advanceTo'));
|
|
Settings::set('advanceTo', '');
|
|
get(route('admin.entries.edit', $this->entry))
|
|
->assertDontSee('Enter for '.auditionSetting('auditionAbbreviation'))
|
|
->assertDontSee('Enter for '.auditionSetting('advanceTo'));
|
|
});
|
|
it('properly checks boxes based on entries settings', function () {
|
|
actAsAdmin();
|
|
get(route('admin.entries.edit', $this->entry))
|
|
->assertSeeInOrder([
|
|
'input',
|
|
'name=',
|
|
'for_seating',
|
|
'checked',
|
|
auditionSetting('auditionAbbreviation'),
|
|
])
|
|
->assertSeeInOrder([
|
|
'input',
|
|
'name=',
|
|
'for_advancement',
|
|
'checked',
|
|
auditionSetting('advanceTo'),
|
|
]);
|
|
$entry2 = Entry::factory()->advanceOnly()->create();
|
|
get(route('admin.entries.edit', $entry2))
|
|
->assertSeeInOrder([
|
|
'input',
|
|
'name=',
|
|
'for_seating',
|
|
'checked',
|
|
auditionSetting('auditionAbbreviation'),
|
|
])
|
|
->assertSeeInOrder([
|
|
'input',
|
|
'name=',
|
|
'for_advancement',
|
|
'checked',
|
|
auditionSetting('advanceTo'),
|
|
]);
|
|
|
|
});
|
|
// Submission tests
|