true, 'ai-editing.outputs.allowed_hosts' => ['cdn.runware.ai'], 'filesystems.default' => 'public', 'watermark.base.asset' => 'branding/test-watermark.png', ]); Storage::fake('public'); Storage::disk('public')->put('branding/test-watermark.png', $this->tinyPngBinary()); Http::fake([ 'https://cdn.runware.ai/*' => Http::response($this->tinyPngBinary(), 200, [ 'Content-Type' => 'image/png', ]), ]); [$request, $output] = $this->createOutputWithoutStoragePath(); $this->artisan('ai-edits:backfill-storage --limit=50') ->assertExitCode(0); $request->refresh(); $output->refresh(); $this->assertNotNull($output->storage_disk); $this->assertNotNull($output->storage_path); $this->assertNotSame('', trim((string) $output->storage_path)); $this->assertTrue(Storage::disk((string) $output->storage_disk)->exists((string) $output->storage_path)); } public function test_it_supports_pretend_mode_without_writing_changes(): void { config([ 'ai-editing.outputs.enabled' => true, 'ai-editing.outputs.allowed_hosts' => ['cdn.runware.ai'], 'filesystems.default' => 'public', ]); [, $output] = $this->createOutputWithoutStoragePath(); $this->artisan('ai-edits:backfill-storage --pretend --limit=10') ->assertExitCode(0); $output->refresh(); $this->assertNull($output->storage_disk); $this->assertNull($output->storage_path); } /** * @return array{0: AiEditRequest, 1: AiEditOutput} */ private function createOutputWithoutStoragePath(): array { $event = Event::factory()->create(['status' => 'published']); $photo = Photo::factory()->for($event)->create([ 'tenant_id' => $event->tenant_id, 'status' => 'approved', ]); $style = AiStyle::query()->create([ 'key' => 'backfill-style', 'name' => 'Backfill Style', 'provider' => 'runware', 'provider_model' => 'runware-default', 'requires_source_image' => true, 'is_active' => true, ]); $request = AiEditRequest::query()->create([ 'tenant_id' => $event->tenant_id, 'event_id' => $event->id, 'photo_id' => $photo->id, 'style_id' => $style->id, 'provider' => 'runware', 'provider_model' => 'runware-default', 'status' => AiEditRequest::STATUS_SUCCEEDED, 'safety_state' => 'passed', 'prompt' => 'Transform image style.', 'idempotency_key' => 'backfill-request-1', 'queued_at' => now()->subMinutes(2), 'started_at' => now()->subMinute(), 'completed_at' => now()->subSeconds(20), ]); $output = AiEditOutput::query()->create([ 'request_id' => $request->id, 'provider_asset_id' => 'backfill-asset-1', 'provider_url' => 'https://cdn.runware.ai/outputs/backfill-image.png', 'is_primary' => true, 'safety_state' => 'passed', 'generated_at' => now(), ]); return [$request, $output]; } private function tinyPngBinary(): string { return (string) base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+XnV0AAAAASUVORK5CYII='); } }