getPdo(); } catch (\Throwable) { $this->markTestSkipped('Database driver is not available in this environment.'); } if (Schema::hasTable('stored_files')) { $this->markTestSkipped('stored_files already exists; skipping isolated route fixture setup.'); } Schema::create('stored_files', function (Blueprint $table): void { $table->string('id')->primary(); $table->string('storage_key'); $table->string('original_filename'); $table->string('mime_type')->nullable(); $table->unsignedBigInteger('file_size_bytes')->default(1); $table->timestamp('deleted_at')->nullable(); $table->timestamps(); }); } public function test_signed_stream_route_returns_inline_file_response(): void { config(['app.key' => 'test-signing-key']); Storage::disk('local')->put('testing/file-123.txt', 'hello'); \DB::table('stored_files')->insert([ 'id' => 'file-123', 'storage_key' => 'testing/file-123.txt', 'original_filename' => 'hello.txt', 'mime_type' => 'text/plain', 'file_size_bytes' => 5, 'created_at' => now(), 'updated_at' => now(), ]); $url = URL::temporarySignedRoute('applicant.files.stream', now()->addMinutes(10), [ 'fileId' => 'file-123', ], false); $response = $this->get($url); $response->assertOk(); $this->assertStringContainsString('inline', $response->headers->get('content-disposition')); $this->assertSame('hello', $response->getContent()); } }