create($tenant, $snapshot, $user); $second = $service->create($tenant, $snapshot, $user); expect((int) $second->getKey())->toBe((int) $first->getKey()) ->and((int) $second->operation_run_id)->toBe((int) $first->operation_run_id); Queue::assertPushed(ComposeEnvironmentReviewJob::class, 1); }); it('reuses the existing mutable review for repeated Spec359 refresh triggers', function (): void { Queue::fake(); [$user, $tenant] = createUserWithTenant(role: 'owner'); $snapshot = seedEnvironmentReviewEvidence($tenant); /** @var EnvironmentReviewService $service */ $service = app(EnvironmentReviewService::class); $review = $service->create($tenant, $snapshot, $user)->refresh(); $reused = $service->refresh($review, $user, $snapshot); expect((int) $reused->getKey())->toBe((int) $review->getKey()) ->and((int) $reused->operation_run_id)->toBe((int) $review->operation_run_id); Queue::assertPushed(ComposeEnvironmentReviewJob::class, 1); }); it('enforces the Spec359 mutable fingerprint uniqueness contract on PostgreSQL', function (): void { [$user, $tenant] = createUserWithTenant(role: 'owner'); $snapshot = seedEnvironmentReviewEvidence($tenant); $fingerprint = app(EnvironmentReviewFingerprint::class)->forSnapshot($tenant, $snapshot); EnvironmentReview::factory()->create([ 'workspace_id' => (int) $tenant->workspace_id, 'managed_environment_id' => (int) $tenant->getKey(), 'evidence_snapshot_id' => (int) $snapshot->getKey(), 'initiated_by_user_id' => (int) $user->getKey(), 'fingerprint' => $fingerprint, 'status' => EnvironmentReviewStatus::Draft->value, ]); expect(fn () => EnvironmentReview::factory()->ready()->create([ 'workspace_id' => (int) $tenant->workspace_id, 'managed_environment_id' => (int) $tenant->getKey(), 'evidence_snapshot_id' => (int) $snapshot->getKey(), 'initiated_by_user_id' => (int) $user->getKey(), 'fingerprint' => $fingerprint, ]))->toThrow(QueryException::class); })->group('pgsql');