create(); $collection = Collection::factory()->for($user)->create([ 'workflow_state' => Collection::WORKFLOW_DRAFT, ]); $service = app(CollectionWorkflowService::class); expect(fn () => $service->update($collection, [ 'workflow_state' => Collection::WORKFLOW_ARCHIVED, ], $user))->toThrow(ValidationException::class); }); it('allows approved collections to become programmed', function (): void { $user = User::factory()->create(['role' => 'admin']); $collection = Collection::factory()->for($user)->create([ 'workflow_state' => Collection::WORKFLOW_APPROVED, 'visibility' => Collection::VISIBILITY_PUBLIC, 'lifecycle_state' => Collection::LIFECYCLE_PUBLISHED, ]); $service = app(CollectionWorkflowService::class); $updated = $service->update($collection, [ 'workflow_state' => Collection::WORKFLOW_PROGRAMMED, 'program_key' => 'frontpage-hero', ], $user); expect($updated->workflow_state)->toBe(Collection::WORKFLOW_PROGRAMMED); expect($updated->program_key)->toBe('frontpage-hero'); });