QA-Luecke geschlossen: Legacy-Medien-URLs redirecten wieder (301)
Die Scope-Doku fuehrte den /thumbnails-Redirect als "ANGEPASST", im Code existierte er nicht — alte Symfony-Bild-URLs (/thumbnails/..., /uploads/ ...) liefen ins 404. Neuer LegacyMediaRedirectController mappt den Original-Dateinamen (bleibt beim Medien-Import erhalten) auf die neue Storage-URL fuer PM-Bilder und Firmenlogos; unbekannte Dateien bleiben 404. Gefunden bei der R6.1-Vorpruefung. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
90fd171e37
commit
d754ef4bef
3 changed files with 120 additions and 0 deletions
56
tests/Feature/Web/LegacyMediaRedirectTest.php
Normal file
56
tests/Feature/Web/LegacyMediaRedirectTest.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Portal;
|
||||
use App\Models\Company;
|
||||
use App\Models\PressRelease;
|
||||
use App\Models\PressReleaseImage;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
test('old thumbnail and upload image urls redirect to the new storage url', function (string $prefix, string $dir) {
|
||||
/** @var TestCase $this */
|
||||
$release = PressRelease::factory()
|
||||
->published()
|
||||
->forPortal(Portal::Businessportal24)
|
||||
->create(['published_at' => now()->subDay()]);
|
||||
|
||||
$image = PressReleaseImage::query()->create([
|
||||
'press_release_id' => $release->id,
|
||||
'disk' => 'public',
|
||||
'path' => "press-releases/{$release->id}/images/altes-pressebild.jpg",
|
||||
]);
|
||||
|
||||
$this->get("https://businessportal24.test/{$prefix}/{$dir}/altes-pressebild.jpg")
|
||||
->assertStatus(301)
|
||||
->assertRedirect($image->url());
|
||||
})->with([
|
||||
'thumbnails' => ['thumbnails', 'pressreleaseimage'],
|
||||
'uploads' => ['uploads', 'pressreleaseimage'],
|
||||
'uploads underscore variant' => ['uploads', 'pressreleaseimage_'],
|
||||
]);
|
||||
|
||||
test('old company logo urls redirect to the new logo url', function () {
|
||||
/** @var TestCase $this */
|
||||
// logoUrl() prüft die Existenz auf der Disk — Datei real anlegen.
|
||||
Storage::fake('public');
|
||||
|
||||
$company = Company::factory()->create([
|
||||
'portal' => Portal::Businessportal24,
|
||||
'logo_path' => 'company-logos/businessportal24/1/firmenlogo.png',
|
||||
]);
|
||||
Storage::disk('public')->put($company->logo_path, 'png');
|
||||
|
||||
$this->get('https://businessportal24.test/thumbnails/company/firmenlogo.png')
|
||||
->assertStatus(301)
|
||||
->assertRedirect($company->logoUrl());
|
||||
});
|
||||
|
||||
test('unknown legacy media files stay 404', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->get('https://businessportal24.test/thumbnails/pressreleaseimage/gibt-es-nicht.jpg')
|
||||
->assertNotFound();
|
||||
|
||||
// Andere Verzeichnisse werden nicht angefasst.
|
||||
$this->get('https://businessportal24.test/thumbnails/sonstwas/datei.jpg')
|
||||
->assertNotFound();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue