feat: festival/series model with sub-events, cross-event sections, tab navigation, SectionsShiftsPanel extraction
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -284,4 +284,122 @@ class EventTest extends TestCase
|
||||
|
||||
$response->assertUnauthorized();
|
||||
}
|
||||
|
||||
// --- DESTROY ---
|
||||
|
||||
public function test_org_admin_can_soft_delete_event(): void
|
||||
{
|
||||
$event = Event::factory()->create(['organisation_id' => $this->organisation->id]);
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$event->id}");
|
||||
|
||||
$response->assertOk();
|
||||
$this->assertSoftDeleted('events', ['id' => $event->id]);
|
||||
}
|
||||
|
||||
public function test_org_admin_can_soft_delete_sub_event(): void
|
||||
{
|
||||
$festival = Event::factory()->festival()->create([
|
||||
'organisation_id' => $this->organisation->id,
|
||||
]);
|
||||
$subEvent = Event::factory()->subEvent($festival)->create();
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$subEvent->id}");
|
||||
|
||||
$response->assertOk();
|
||||
$this->assertSoftDeleted('events', ['id' => $subEvent->id]);
|
||||
$this->assertNotSoftDeleted('events', ['id' => $festival->id]);
|
||||
}
|
||||
|
||||
public function test_event_manager_can_delete_event(): void
|
||||
{
|
||||
$event = Event::factory()->create(['organisation_id' => $this->organisation->id]);
|
||||
$eventManager = User::factory()->create();
|
||||
$this->organisation->users()->attach($eventManager, ['role' => 'org_member']);
|
||||
$event->users()->attach($eventManager, ['role' => 'event_manager']);
|
||||
|
||||
Sanctum::actingAs($eventManager);
|
||||
|
||||
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$event->id}");
|
||||
|
||||
$response->assertOk();
|
||||
$this->assertSoftDeleted('events', ['id' => $event->id]);
|
||||
}
|
||||
|
||||
public function test_org_member_cannot_delete_event(): void
|
||||
{
|
||||
$event = Event::factory()->create(['organisation_id' => $this->organisation->id]);
|
||||
|
||||
Sanctum::actingAs($this->orgMember);
|
||||
|
||||
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$event->id}");
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_outsider_cannot_delete_event(): void
|
||||
{
|
||||
$event = Event::factory()->create(['organisation_id' => $this->organisation->id]);
|
||||
|
||||
Sanctum::actingAs($this->outsider);
|
||||
|
||||
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$event->id}");
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_unauthenticated_user_cannot_delete_event(): void
|
||||
{
|
||||
$event = Event::factory()->create(['organisation_id' => $this->organisation->id]);
|
||||
|
||||
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$event->id}");
|
||||
|
||||
$response->assertUnauthorized();
|
||||
}
|
||||
|
||||
public function test_delete_event_from_other_org_is_blocked(): void
|
||||
{
|
||||
$otherOrg = Organisation::factory()->create();
|
||||
$event = Event::factory()->create(['organisation_id' => $otherOrg->id]);
|
||||
|
||||
Sanctum::actingAs($this->admin);
|
||||
|
||||
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$event->id}");
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_soft_deleted_event_not_in_index(): void
|
||||
{
|
||||
$event = Event::factory()->create(['organisation_id' => $this->organisation->id]);
|
||||
$event->delete();
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events");
|
||||
|
||||
$response->assertOk();
|
||||
$this->assertCount(0, $response->json('data'));
|
||||
}
|
||||
|
||||
public function test_soft_delete_does_not_cascade_to_related_data(): void
|
||||
{
|
||||
$event = Event::factory()->create(['organisation_id' => $this->organisation->id]);
|
||||
$section = $event->festivalSections()->create([
|
||||
'name' => 'Stage A',
|
||||
'sort_order' => 1,
|
||||
]);
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$event->id}");
|
||||
|
||||
$response->assertOk();
|
||||
$this->assertSoftDeleted('events', ['id' => $event->id]);
|
||||
$this->assertDatabaseHas('festival_sections', ['id' => $section->id, 'deleted_at' => null]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user