optimizations

This commit is contained in:
2026-03-28 19:15:39 +01:00
parent 0b25d9570a
commit cab4fbd83e
509 changed files with 1016804 additions and 1605 deletions

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
use App\Models\Collection;
use App\Models\User;
use App\Services\CollectionWorkflowService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Validation\ValidationException;
use Tests\TestCase;
uses(TestCase::class, RefreshDatabase::class);
it('rejects invalid workflow transitions', function (): void {
$user = User::factory()->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');
});