Fix IDE flags
This commit is contained in:
parent
89dd6a9a0e
commit
8d9bbf31d5
|
|
@ -13,6 +13,7 @@ use Sinnbeck\DomAssertions\Asserts\AssertElement;
|
|||
use Sinnbeck\DomAssertions\Asserts\AssertForm;
|
||||
use Sinnbeck\DomAssertions\Asserts\AssertSelect;
|
||||
|
||||
use function Pest\Laravel\delete;
|
||||
use function Pest\Laravel\get;
|
||||
use function Pest\Laravel\patch;
|
||||
|
||||
|
|
@ -55,17 +56,15 @@ it('has a delete link', function () {
|
|||
get(route('admin.entries.edit', $this->entry))
|
||||
->assertSee('<input type="hidden" name="_method" value="DELETE">', false);
|
||||
});
|
||||
|
||||
it('has a dropdown for all auditions appropriate to the students grade', function () {
|
||||
// Arrange
|
||||
$auditions = Audition::factory()->count(5)->create(['minimum_grade' => 1, 'maximum_grade' => 20]);
|
||||
/** @noinspection PhpPossiblePolymorphicInvocationInspection */
|
||||
$oldAudition = Audition::factory()->create(['minimum_grade' => $this->entry->grade + 1]);
|
||||
/** @noinspection PhpPossiblePolymorphicInvocationInspection */
|
||||
$youngAudition = Audition::factory()->create(['maximum_grade' => $this->entry->grade - 1]);
|
||||
actAsAdmin();
|
||||
$auditionsArray = [];
|
||||
foreach ($auditions as $audition) {
|
||||
$auditionsArray[] = ['value' => $audition->id, 'text' => $audition->name];
|
||||
break;
|
||||
}
|
||||
$response = get(route('admin.entries.edit', $this->entry));
|
||||
$response->assertOk();
|
||||
// Act & Assert
|
||||
|
|
@ -129,6 +128,7 @@ it('does not let a normal user update an entry', function () {
|
|||
$newAudition = Audition::factory()->create();
|
||||
actAsNormal();
|
||||
// Act & Assert
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
patch(route('admin.entries.update', $this->entry), ['audition_id' => $newAudition->id])
|
||||
->assertSessionHasNoErrors()
|
||||
->assertSessionHas('error', 'You are not authorized to perform this action')
|
||||
|
|
@ -139,6 +139,7 @@ it('allows an admin to update an entry', function () {
|
|||
$newAudition = Audition::factory()->create();
|
||||
actAsAdmin();
|
||||
// Act & Assert
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
patch(route('admin.entries.update', $this->entry), ['audition_id' => $newAudition->id])
|
||||
->assertSessionHasNoErrors()
|
||||
->assertSessionHas('success', 'Entry updated successfully')
|
||||
|
|
@ -154,6 +155,7 @@ it('does not allow an administrator to update an entry in a published audition',
|
|||
actAsAdmin();
|
||||
$this->entry->audition->addFlag('seats_published');
|
||||
// Act & Assert
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
patch(route('admin.entries.update', $this->entry), ['audition_id' => $newAudition->id])
|
||||
->assertSessionHasNoErrors()
|
||||
->assertSessionHas('error', 'Entries in auditions with seats published cannot be modified')
|
||||
|
|
@ -171,6 +173,7 @@ it('does not allow an administrator to update an entry in an audition with publi
|
|||
actAsAdmin();
|
||||
$this->entry->audition->addFlag('advancement_published');
|
||||
// Act & Assert
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
patch(route('admin.entries.update', $this->entry), ['audition_id' => $newAudition->id])
|
||||
->assertSessionHasNoErrors()
|
||||
->assertSessionHas('error', 'Entries in auditions with advancement results published cannot be modified')
|
||||
|
|
@ -188,6 +191,7 @@ it('always sets for_seating to true if advancement is not enabled', function ()
|
|||
$newAudition = Audition::factory()->create();
|
||||
actAsAdmin();
|
||||
// Act & Assert
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
patch(route('admin.entries.update', $this->entry), ['audition_id' => $newAudition->id])
|
||||
->assertSessionHasNoErrors()
|
||||
->assertSessionHas('success', 'Entry updated successfully')
|
||||
|
|
@ -216,3 +220,50 @@ it('displays scores', function () {
|
|||
$response->assertSee($subscore->name);
|
||||
}
|
||||
});
|
||||
|
||||
// Delete tests
|
||||
it('does not allow a normal user to delete an entry', function () {
|
||||
// Arrange
|
||||
actAsNormal();
|
||||
// Act & Assert
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
delete(route('admin.entries.destroy', $this->entry), ['_method' => 'DELETE'])
|
||||
->assertSessionHasNoErrors()
|
||||
->assertSessionHas('error', 'You are not authorized to perform this action')
|
||||
->assertRedirect(route('dashboard'));
|
||||
});
|
||||
it('allows an admin to delete an entry', function () {
|
||||
// Arrange
|
||||
actAsAdmin();
|
||||
// Act & Assert
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
delete(route('admin.entries.destroy', $this->entry), ['_method' => 'DELETE'])
|
||||
->assertSessionHasNoErrors()
|
||||
->assertSessionHas('success', 'Entry Deleted')
|
||||
->assertRedirect(route('admin.entries.index'));
|
||||
expect(Entry::find($this->entry->id))->toBeNull();
|
||||
});
|
||||
it('does not allow an admin to delete an entry if that entries audition seats are published', function () {
|
||||
// Arrange
|
||||
actAsAdmin();
|
||||
// Act & Assert
|
||||
$this->entry->audition->addFlag('seats_published');
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
delete(route('admin.entries.destroy', $this->entry), ['_method' => 'DELETE'])
|
||||
->assertSessionHasNoErrors()
|
||||
->assertSessionHas('error', 'Entries in auditions with seats published cannot be deleted')
|
||||
->assertRedirect(route('admin.entries.index'));
|
||||
expect(Entry::find($this->entry->id))->not->toBeNull();
|
||||
});
|
||||
it('does not allow an admin to delete an entry if that entries advancement is published', function () {
|
||||
// Arrange
|
||||
actAsAdmin();
|
||||
// Act & Assert
|
||||
$this->entry->audition->addFlag('advancement_published');
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
delete(route('admin.entries.destroy', $this->entry), ['_method' => 'DELETE'])
|
||||
->assertSessionHasNoErrors()
|
||||
->assertSessionHas('error', 'Entries in auditions with advancement results published cannot be deleted')
|
||||
->assertRedirect(route('admin.entries.index'));
|
||||
expect(Entry::find($this->entry->id))->not->toBeNull();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue