Die Theme-Sitzung wartete darauf: Seebad ruft schon ortsneutrale Plätze über `partials/motif` auf und behilft sich mit einem eigenen `motifs/`- Ordner. Der Kommentar dort sagt es selbst – „so a later picture-world system can replace the mapping below". Das System gibt es jetzt. **Bildwelten** (A18–A20) sind Pakete wie Themes: `resources/image-worlds/ <key>/` mit `world.json` und `svg/`. Eine Website wählt eine Bildwelt, eine Wohnung darf eine andere tragen – das ist der Platz für die Bergwohnung auf einer Küsten-Website. Vorlagen fragen über `$theme->motif($slot)` nach einem Platz, nie nach einer Datei. Die Render-Logik ist aus Seebads Partial in die Anwendung gewandert, damit jedes Theme sie bekommt: Inline-SVG (nimmt die Textfarbe an, kein zweiter Request), Titel und ARIA entfernt, und die internen Ids je Aufruf eindeutig gemacht – zwei Kopien derselben Grafik auf einer Seite würden sonst auf denselben Verlauf zeigen und eine davon verlöre ihre Farben. Ein leerer Platz ist kein Fehler: die Vorlage bekommt schlicht keine Dekoration. Weil das leicht zu übersehen ist, meldet `php artisan image-worlds:check`, welcher Platz ohne Datei dasteht. **Marke je Website** (A14/A22): Logo, Favicon und ein Logo für E-Mail und Vertrag als Medien der Website. Der Mietvertrag bettet die Datei ein statt eine URL zu holen – er wird auf dem Server gerendert und darf nicht davon abhängen, dass dieser sich selbst erreicht. Ohne Logo bleibt der Vertrag wie bisher. `resources/themes/**` ist unberührt: die Ostsee-Grafiken sind kopiert, nicht verschoben. Was die Theme-Sitzung nun tun kann, steht in ZUSAMMENARBEIT.md §6; ihr Wunsch aus §5 ist als erledigt vermerkt. 272 Feature-Tests grün. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
100 lines
3.5 KiB
PHP
100 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Documents\RentalContract;
|
|
use App\Models\Booking;
|
|
use App\Models\Property;
|
|
use App\Models\Site;
|
|
use App\Models\Tenant;
|
|
use App\Tenancy\TenantContext;
|
|
use App\Themes\Theme;
|
|
use App\Themes\ThemeFactory;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Http\UploadedFile;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* The brand (A14/A22): logo, favicon and the logo for mail and contract belong to the website, not to the
|
|
* installation. Without this, a second landlord would carry the first one's logo in their rental contract.
|
|
*/
|
|
class SiteBrandTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_each_website_carries_its_own_brand(): void
|
|
{
|
|
Storage::fake('public');
|
|
|
|
$first = $this->website('Nordhaus');
|
|
$second = $this->website('Südheim');
|
|
|
|
$first->addMedia(UploadedFile::fake()->image('nord.png'))->toMediaCollection(Site::BRAND_LOGO);
|
|
|
|
$this->assertNotNull($first->fresh()->brandUrl(Site::BRAND_LOGO));
|
|
$this->assertNull($second->fresh()->brandUrl(Site::BRAND_LOGO), 'Ohne eigenes Logo erbt niemand ein fremdes.');
|
|
$this->assertNull($first->fresh()->brandUrl(Site::BRAND_FAVICON));
|
|
}
|
|
|
|
public function test_the_contract_shows_the_logo_of_its_own_website(): void
|
|
{
|
|
Storage::fake('public');
|
|
Storage::fake('local');
|
|
|
|
$site = $this->website('Nordhaus');
|
|
$site->addMedia(UploadedFile::fake()->image('vertrag.png', 300, 100))->toMediaCollection(Site::BRAND_DOCUMENT_LOGO);
|
|
|
|
$booking = app(TenantContext::class)->run($site->tenant, fn (): Booking => Booking::factory()
|
|
->for(Property::factory()->create(['site_id' => $site->id]))
|
|
->create());
|
|
|
|
$path = app(TenantContext::class)->run($site->tenant, fn (): string => app(RentalContract::class)->generate($booking, draft: true));
|
|
|
|
Storage::disk('local')->assertExists($path);
|
|
$this->assertGreaterThan(1000, strlen(Storage::disk('local')->get($path)));
|
|
}
|
|
|
|
public function test_a_website_without_a_document_logo_still_renders_its_contract(): void
|
|
{
|
|
Storage::fake('public');
|
|
Storage::fake('local');
|
|
|
|
$site = $this->website('Ohne Marke');
|
|
|
|
$booking = app(TenantContext::class)->run($site->tenant, fn (): Booking => Booking::factory()
|
|
->for(Property::factory()->create(['site_id' => $site->id]))
|
|
->create());
|
|
|
|
$path = app(TenantContext::class)->run($site->tenant, fn (): string => app(RentalContract::class)->generate($booking, draft: false));
|
|
|
|
Storage::disk('local')->assertExists($path);
|
|
}
|
|
|
|
public function test_the_theme_hands_the_brand_to_the_templates(): void
|
|
{
|
|
Storage::fake('public');
|
|
|
|
$site = $this->website('Nordhaus');
|
|
$site->addMedia(UploadedFile::fake()->image('logo.png'))->toMediaCollection(Site::BRAND_LOGO);
|
|
|
|
$theme = app(TenantContext::class)->run(
|
|
$site->tenant,
|
|
fn (): Theme => app(ThemeFactory::class)->forSite($site->fresh()),
|
|
);
|
|
|
|
$this->assertStringContainsString('logo', (string) $theme->brand(Site::BRAND_LOGO));
|
|
$this->assertNull($theme->brand(Site::BRAND_FAVICON));
|
|
}
|
|
|
|
private function website(string $name): Site
|
|
{
|
|
$tenant = Tenant::factory()->create(['name' => $name]);
|
|
|
|
return app(TenantContext::class)->run($tenant, fn (): Site => Site::factory()->create([
|
|
'name' => $name,
|
|
'is_default' => false,
|
|
]));
|
|
}
|
|
}
|