'42', 'attivo' => true]); return TerritorioMappa::create([ 'territorio_id' => $territorio->id, 'geojson' => self::GEOMETRIA, ]); } public function test_un_rendering_riuscito_salva_il_png_e_aggiorna_la_mappa(): void { Http::fake(['*/render' => Http::response("\x89PNG\r\n\x1a\ncontenuto-finto")]); $mappa = $this->mappa(); $path = (new PiantinaRenderer())->render($mappa); Storage::disk('public')->assertExists($path); $mappa->refresh(); $this->assertSame($path, $mappa->image_path); $this->assertNotNull($mappa->rendered_at); } public function test_un_errore_del_renderer_diventa_un_messaggio_leggibile(): void { Http::fake(['*/render' => Http::response(['error' => 'area troppo estesa'], 413)]); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('area troppo estesa'); (new PiantinaRenderer())->render($this->mappa()); } public function test_una_risposta_che_non_e_un_png_viene_rifiutata(): void { Http::fake(['*/render' => Http::response('proxy error')]); $this->expectException(RuntimeException::class); (new PiantinaRenderer())->render($this->mappa()); } public function test_una_geometria_corrotta_blocca_prima_di_chiamare_il_renderer(): void { Http::fake(); $mappa = $this->mappa(); $mappa->update(['geojson' => 'non-json']); $this->expectException(RuntimeException::class); (new PiantinaRenderer())->render($mappa->refresh()); Http::assertNothingSent(); } }