fix(issue-80): show all 13 house images + 3D floor plans
All checks were successful
Lint / PHP Syntax Check (push) Successful in 57s
PHPUnit / PHP Unit Tests (push) Successful in 1m7s
Lint / HTML Lint (htmlhint) (push) Successful in 1m38s
Lint / CSS Lint (stylelint) (push) Successful in 1m42s
Lint / PHP Syntax Check (pull_request) Successful in 58s
PHPUnit / PHP Unit Tests (pull_request) Successful in 1m3s
Lint / HTML Lint (htmlhint) (pull_request) Successful in 1m36s
Lint / CSS Lint (stylelint) (pull_request) Successful in 1m41s
All checks were successful
Lint / PHP Syntax Check (push) Successful in 57s
PHPUnit / PHP Unit Tests (push) Successful in 1m7s
Lint / HTML Lint (htmlhint) (push) Successful in 1m38s
Lint / CSS Lint (stylelint) (push) Successful in 1m42s
Lint / PHP Syntax Check (pull_request) Successful in 58s
PHPUnit / PHP Unit Tests (pull_request) Successful in 1m3s
Lint / HTML Lint (htmlhint) (pull_request) Successful in 1m36s
Lint / CSS Lint (stylelint) (pull_request) Successful in 1m41s
This commit is contained in:
@@ -69,6 +69,10 @@ return [
|
||||
'gallery.kid1' => 'Kinderzimmer 1 · 21,7 m²',
|
||||
'gallery.kid2' => 'Kinderzimmer 2 · 15,7 m²',
|
||||
'gallery.kid_detail' => 'Kinderzimmer Detail',
|
||||
'gallery.kid_extra' => 'Kinderzimmer · Spielbereich',
|
||||
'gallery.bath2' => 'Badezimmer · 6,4 m²',
|
||||
'gallery.bath3' => 'Badezimmer · 5,8 m²',
|
||||
'gallery.bath4' => 'Badezimmer · Wellness',
|
||||
'gallery.guest' => 'Gästezimmer · 11,5 m²',
|
||||
'gallery.area1' => 'Wohnbereich',
|
||||
'gallery.area2' => 'Wohnbereich Detail',
|
||||
@@ -80,9 +84,11 @@ return [
|
||||
'gallery.alt.kid1' => 'Kinderzimmer 1 mit 21,7 m²',
|
||||
'gallery.alt.kid2' => 'Kinderzimmer 2 mit 15,7 m²',
|
||||
'gallery.alt.kid_detail' => 'Detailansicht Kinderzimmer',
|
||||
'gallery.alt.kid_extra' => 'Spielbereich im Kinderzimmer',
|
||||
'gallery.alt.guest' => 'Gästezimmer mit 11,5 m²',
|
||||
'gallery.alt.bath2' => 'Zweites Badezimmer im Haus',
|
||||
'gallery.alt.bath3' => 'Drittes Badezimmer im Haus',
|
||||
'gallery.alt.bath4' => 'Viertes Badezimmer im Haus',
|
||||
'gallery.alt.exterior' => 'Außenansicht des Einfamilienhauses',
|
||||
|
||||
// ─── Floor plans (Grundriss) ────────────────────────────────────────
|
||||
@@ -120,6 +126,10 @@ return [
|
||||
'floors.alt.og1' => 'Grundriss 1. Obergeschoss',
|
||||
'floors.alt.og2' => 'Grundriss 2. Obergeschoss',
|
||||
'floors.alt.attic' => 'Grundriss Dachboden',
|
||||
'floors.alt.eg_3d' => '3D-Ansicht Erdgeschoss',
|
||||
'floors.alt.og1_3d' => '3D-Ansicht 1. Obergeschoss',
|
||||
'floors.alt.og2_3d' => '3D-Ansicht 2. Obergeschoss',
|
||||
'floors.alt.attic_2' => 'Alternative Ansicht Dachboden',
|
||||
|
||||
// ─── Rent (Miete) ────────────────────────────────────────────────────
|
||||
'rent.eyebrow' => 'Mietkonditionen',
|
||||
|
||||
@@ -59,6 +59,10 @@ return [
|
||||
'gallery.kid1' => 'Child\'s room 1 · 21.7 m²',
|
||||
'gallery.kid2' => 'Child\'s room 2 · 15.7 m²',
|
||||
'gallery.kid_detail' => 'Child\'s room detail',
|
||||
'gallery.kid_extra' => 'Child\'s room · play area',
|
||||
'gallery.bath2' => 'Bathroom · 6.4 m²',
|
||||
'gallery.bath3' => 'Bathroom · 5.8 m²',
|
||||
'gallery.bath4' => 'Bathroom · wellness',
|
||||
'gallery.guest' => 'Guest room · 11.5 m²',
|
||||
'gallery.area1' => 'Living area',
|
||||
'gallery.area2' => 'Living area detail',
|
||||
@@ -70,9 +74,11 @@ return [
|
||||
'gallery.alt.kid1' => 'Child\'s room 1 with 21.7 m²',
|
||||
'gallery.alt.kid2' => 'Child\'s room 2 with 15.7 m²',
|
||||
'gallery.alt.kid_detail' => 'Child\'s room detail view',
|
||||
'gallery.alt.kid_extra' => 'Play area in the child\'s room',
|
||||
'gallery.alt.guest' => 'Guest room with 11.5 m²',
|
||||
'gallery.alt.bath2' => 'Second bathroom in the house',
|
||||
'gallery.alt.bath3' => 'Third bathroom in the house',
|
||||
'gallery.alt.bath4' => 'Fourth bathroom in the house',
|
||||
'gallery.alt.exterior' => 'Exterior view of the detached house',
|
||||
|
||||
'floors.eyebrow' => 'Layout',
|
||||
@@ -109,6 +115,10 @@ return [
|
||||
'floors.alt.og1' => 'Floor plan 1st upper floor',
|
||||
'floors.alt.og2' => 'Floor plan 2nd upper floor',
|
||||
'floors.alt.attic' => 'Floor plan attic',
|
||||
'floors.alt.eg_3d' => '3D view ground floor',
|
||||
'floors.alt.og1_3d' => '3D view 1st upper floor',
|
||||
'floors.alt.og2_3d' => '3D view 2nd upper floor',
|
||||
'floors.alt.attic_2' => 'Alternative view of the attic',
|
||||
|
||||
'rent.eyebrow' => 'Rental terms',
|
||||
'rent.aria' => 'Rental terms',
|
||||
|
||||
@@ -59,6 +59,10 @@ return [
|
||||
'gallery.kid1' => 'Детская 1 · 21,7 м²',
|
||||
'gallery.kid2' => 'Детская 2 · 15,7 м²',
|
||||
'gallery.kid_detail' => 'Деталь детской',
|
||||
'gallery.kid_extra' => 'Детская · игровая зона',
|
||||
'gallery.bath2' => 'Ванная · 6,4 м²',
|
||||
'gallery.bath3' => 'Ванная · 5,8 м²',
|
||||
'gallery.bath4' => 'Ванная · велнес',
|
||||
'gallery.guest' => 'Гостевая комната · 11,5 м²',
|
||||
'gallery.area1' => 'Жилая зона',
|
||||
'gallery.area2' => 'Деталь жилой зоны',
|
||||
@@ -70,9 +74,11 @@ return [
|
||||
'gallery.alt.kid1' => 'Детская комната 1 — 21,7 м²',
|
||||
'gallery.alt.kid2' => 'Детская комната 2 — 15,7 м²',
|
||||
'gallery.alt.kid_detail' => 'Детальный вид детской комнаты',
|
||||
'gallery.alt.kid_extra' => 'Игровая зона в детской комнате',
|
||||
'gallery.alt.guest' => 'Гостевая комната 11,5 м²',
|
||||
'gallery.alt.bath2' => 'Вторая ванная комната в доме',
|
||||
'gallery.alt.bath3' => 'Третья ванная комната в доме',
|
||||
'gallery.alt.bath4' => 'Четвертая ванная комната в доме',
|
||||
'gallery.alt.exterior' => 'Внешний вид частного дома',
|
||||
|
||||
'floors.eyebrow' => 'Планировка',
|
||||
@@ -109,6 +115,10 @@ return [
|
||||
'floors.alt.og1' => 'План второго этажа',
|
||||
'floors.alt.og2' => 'План третьего этажа',
|
||||
'floors.alt.attic' => 'План чердака',
|
||||
'floors.alt.eg_3d' => '3D-вид первого этажа',
|
||||
'floors.alt.og1_3d' => '3D-вид второго этажа',
|
||||
'floors.alt.og2_3d' => '3D-вид третьего этажа',
|
||||
'floors.alt.attic_2' => 'Альтернативный вид чердака',
|
||||
|
||||
'rent.eyebrow' => 'Условия аренды',
|
||||
'rent.aria' => 'Условия аренды',
|
||||
|
||||
@@ -59,6 +59,10 @@ return [
|
||||
'gallery.kid1' => 'Дитяча кімната 1 · 21,7 м²',
|
||||
'gallery.kid2' => 'Дитяча кімната 2 · 15,7 м²',
|
||||
'gallery.kid_detail' => 'Деталь дитячої кімнати',
|
||||
'gallery.kid_extra' => 'Дитяча кімната · ігрова зона',
|
||||
'gallery.bath2' => 'Ванна кімната · 6,4 м²',
|
||||
'gallery.bath3' => 'Ванна кімната · 5,8 м²',
|
||||
'gallery.bath4' => 'Ванна кімната · велнес',
|
||||
'gallery.guest' => 'Гостьова кімната · 11,5 м²',
|
||||
'gallery.area1' => 'Житлова зона',
|
||||
'gallery.area2' => 'Деталь житлової зони',
|
||||
@@ -70,9 +74,11 @@ return [
|
||||
'gallery.alt.kid1' => 'Дитяча кімната 1 — 21,7 м²',
|
||||
'gallery.alt.kid2' => 'Дитяча кімната 2 — 15,7 м²',
|
||||
'gallery.alt.kid_detail' => 'Детальний вигляд дитячої кімнати',
|
||||
'gallery.alt.kid_extra' => 'Ігрова зона в дитячій кімнаті',
|
||||
'gallery.alt.guest' => 'Гостьова кімната 11,5 м²',
|
||||
'gallery.alt.bath2' => 'Друга ванна кімната в будинку',
|
||||
'gallery.alt.bath3' => 'Третя ванна кімната в будинку',
|
||||
'gallery.alt.bath4' => 'Четверта ванна кімната в будинку',
|
||||
'gallery.alt.exterior' => 'Зовнішній вигляд приватного будинку',
|
||||
|
||||
'floors.eyebrow' => 'Планування',
|
||||
@@ -109,6 +115,10 @@ return [
|
||||
'floors.alt.og1' => 'План другого поверху',
|
||||
'floors.alt.og2' => 'План третього поверху',
|
||||
'floors.alt.attic' => 'План горища',
|
||||
'floors.alt.eg_3d' => '3D-вигляд першого поверху',
|
||||
'floors.alt.og1_3d' => '3D-вигляд другого поверху',
|
||||
'floors.alt.og2_3d' => '3D-вигляд третього поверху',
|
||||
'floors.alt.attic_2' => 'Альтернативний вигляд горища',
|
||||
|
||||
'rent.eyebrow' => 'Умови оренди',
|
||||
'rent.aria' => 'Умови оренди',
|
||||
|
||||
@@ -23,9 +23,13 @@ $gridItems = [
|
||||
['img' => 'bilder/Küche 1.jpg', 'key' => 'gallery.kitchen', 'alt' => 'gallery.alt.kitchen', 'class' => ''],
|
||||
['img' => 'bilder/schlafzimmer.png', 'key' => 'gallery.bedroom', 'alt' => 'gallery.alt.bedroom', 'class' => ''],
|
||||
['img' => 'bilder/Bad.jpg', 'key' => 'gallery.bath', 'alt' => 'gallery.alt.bath', 'class' => ''],
|
||||
['img' => 'bilder/Bad-2.jpeg', 'key' => 'gallery.bath2', 'alt' => 'gallery.alt.bath2', 'class' => ''],
|
||||
['img' => 'bilder/Bad-3.jpeg', 'key' => 'gallery.bath3', 'alt' => 'gallery.alt.bath3', 'class' => ''],
|
||||
['img' => 'bilder/Bad-4.jpeg', 'key' => 'gallery.bath4', 'alt' => 'gallery.alt.bath4', 'class' => ''],
|
||||
['img' => 'bilder/Kinderzimmer 2.jpg', 'key' => 'gallery.kid1', 'alt' => 'gallery.alt.kid1', 'class' => ''],
|
||||
['img' => 'bilder/Kinderzimmer 3.jpg', 'key' => 'gallery.kid2', 'alt' => 'gallery.alt.kid2', 'class' => ''],
|
||||
['img' => 'bilder/kinderzimmer 2 2.webp', 'key' => 'gallery.kid_detail', 'alt' => 'gallery.alt.kid_detail', 'class' => 'span-2 row-1'],
|
||||
['img' => 'bilder/Kinderzimmer.png', 'key' => 'gallery.kid_extra', 'alt' => 'gallery.alt.kid_extra', 'class' => ''],
|
||||
['img' => 'bilder/Außenansicht-2.png', 'key' => 'gallery.area3', 'alt' => 'gallery.alt.exterior', 'class' => 'span-2 row-1'],
|
||||
];
|
||||
?>
|
||||
@@ -112,6 +116,13 @@ $gridItems = [
|
||||
'attic' => 'bilder/grundrisse/Dachboden unten.png',
|
||||
];
|
||||
|
||||
$floorImageMapExtra = [
|
||||
'eg' => ['img' => 'bilder/grundrisse/EG 3D.png', 'altKey' => 'floors.alt.eg_3d'],
|
||||
'og1' => ['img' => 'bilder/grundrisse/OG 1 3D.png', 'altKey' => 'floors.alt.og1_3d'],
|
||||
'og2' => ['img' => 'bilder/grundrisse/OG 2 3D.png', 'altKey' => 'floors.alt.og2_3d'],
|
||||
'attic' => ['img' => 'bilder/grundrisse/Dachboden unten 2.png', 'altKey' => 'floors.alt.attic_2'],
|
||||
];
|
||||
|
||||
$floors = [
|
||||
['id' => 'eg', 'titleKey' => 'floors.eg.title', 'areaKey' => 'floors.eg.area', 'altKey' => 'floors.alt.eg',
|
||||
'rooms' => [
|
||||
@@ -155,10 +166,27 @@ $gridItems = [
|
||||
<span class="floor-area"><?= htmlspecialchars($t($floor['areaKey']), ENT_QUOTES) ?></span>
|
||||
</summary>
|
||||
<div class="floor-body">
|
||||
<img src="/<?= htmlspecialchars($floorImageMap[$floor['id']] ?? 'bilder/grundrisse/EG.png', ENT_QUOTES) ?>"
|
||||
alt="<?= htmlspecialchars($t($floor['altKey']), ENT_QUOTES) ?>"
|
||||
loading="lazy" decoding="async"
|
||||
class="floor-plan-img">
|
||||
<?php
|
||||
$primaryImg = $floorImageMap[$floor['id']] ?? 'bilder/grundrisse/EG.png';
|
||||
$extra = $floorImageMapExtra[$floor['id']] ?? null;
|
||||
$imgWrapperClass = $extra ? 'floor-plan-multi' : '';
|
||||
?>
|
||||
<?php if ($imgWrapperClass !== ''): ?>
|
||||
<div class="<?= htmlspecialchars($imgWrapperClass, ENT_QUOTES) ?>">
|
||||
<?php endif; ?>
|
||||
<img src="/<?= htmlspecialchars($primaryImg, ENT_QUOTES) ?>"
|
||||
alt="<?= htmlspecialchars($t($floor['altKey']), ENT_QUOTES) ?>"
|
||||
loading="lazy" decoding="async"
|
||||
class="floor-plan-img">
|
||||
<?php if ($extra !== null): ?>
|
||||
<img src="/<?= htmlspecialchars($extra['img'], ENT_QUOTES) ?>"
|
||||
alt="<?= htmlspecialchars($t($extra['altKey']), ENT_QUOTES) ?>"
|
||||
loading="lazy" decoding="async"
|
||||
class="floor-plan-img">
|
||||
<?php endif; ?>
|
||||
<?php if ($imgWrapperClass !== ''): ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<ul class="room-list">
|
||||
<?php foreach ($floor['rooms'] as $room): ?>
|
||||
<li>
|
||||
|
||||
178
tests/Views/HomeGalleryInventoryTest.php
Normal file
178
tests/Views/HomeGalleryInventoryTest.php
Normal file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Views;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Regression test for issue #80: all house images in public/bilder/ must be
|
||||
* referenced from the home view. Catches drift when new photos are added to
|
||||
* disk but not yet wired into the gallery or floor-plan map.
|
||||
*/
|
||||
final class HomeGalleryInventoryTest extends TestCase
|
||||
{
|
||||
private const VIEW_PATH = __DIR__ . '/../../app/views/home/index.php';
|
||||
private const BILDER_DIR = __DIR__ . '/../../public/bilder';
|
||||
|
||||
/** @var list<string> Files that may exist on disk but are intentionally NOT shown on the page. */
|
||||
private const ALLOWED_UNUSED = [
|
||||
// Hero / page background uses a .webp variant; the .png in bilder/ is the
|
||||
// gallery source. Hero-bg is referenced separately in the <header>.
|
||||
'favicon/',
|
||||
// -small.* variants are served as thumb hints by JS lazy-load optimization.
|
||||
'*-small.*',
|
||||
];
|
||||
|
||||
public function testAllBilderFilesAreReferencedInHomeView(): void
|
||||
{
|
||||
$view = file_get_contents(self::VIEW_PATH);
|
||||
self::assertNotFalse($view, 'Could not read home view');
|
||||
|
||||
$diskFiles = $this->listBilderFiles();
|
||||
self::assertNotEmpty($diskFiles, 'No files found in public/bilder/');
|
||||
|
||||
// Group files by base name (filename without extension) so the
|
||||
// .jpg/.png/.jpeg source + auto-generated .webp variant count as ONE image.
|
||||
$groups = [];
|
||||
foreach ($diskFiles as $relPath) {
|
||||
if ($this->isAllowedUnused($relPath)) {
|
||||
continue;
|
||||
}
|
||||
$groups[$this->baseOf($relPath)][] = $relPath;
|
||||
}
|
||||
|
||||
$missing = [];
|
||||
foreach ($groups as $base => $variants) {
|
||||
$hit = false;
|
||||
foreach ($variants as $v) {
|
||||
// View may reference raw or with leading slash.
|
||||
if (str_contains($view, $v) || str_contains($view, '/' . ltrim($v, '/'))) {
|
||||
$hit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$hit) {
|
||||
$missing[] = $base . ' (' . implode(', ', $variants) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
self::assertSame(
|
||||
[],
|
||||
$missing,
|
||||
sprintf(
|
||||
"These image groups exist in public/bilder/ but are NOT referenced anywhere in the home view:\n - %s\n\nFix: add them to \$gridItems (gallery) or \$floorImageMap / \$floorImageMapExtra (floor plans), and add the matching Locale keys.",
|
||||
implode("\n - ", $missing),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGalleryContainsAllRequiredImages(): void
|
||||
{
|
||||
$view = file_get_contents(self::VIEW_PATH);
|
||||
self::assertNotFalse($view, 'Could not read home view');
|
||||
|
||||
$required = [
|
||||
// Bathrooms (3 new ones in addition to the existing Bad.jpg)
|
||||
'bilder/Bad.jpg',
|
||||
'bilder/Bad-2.jpeg',
|
||||
'bilder/Bad-3.jpeg',
|
||||
'bilder/Bad-4.jpeg',
|
||||
// Kids room extras
|
||||
'bilder/Kinderzimmer.png',
|
||||
// Floor plans 2D
|
||||
'bilder/grundrisse/EG.png',
|
||||
'bilder/grundrisse/OG 1 2.png',
|
||||
'bilder/grundrisse/OG 2 grundriss.png',
|
||||
'bilder/grundrisse/Dachboden unten.png',
|
||||
// Floor plans 3D / alternate
|
||||
'bilder/grundrisse/EG 3D.png',
|
||||
'bilder/grundrisse/OG 1 3D.png',
|
||||
'bilder/grundrisse/OG 2 3D.png',
|
||||
'bilder/grundrisse/Dachboden unten 2.png',
|
||||
];
|
||||
|
||||
$missing = array_values(array_filter($required, static fn (string $img) => !str_contains($view, $img)));
|
||||
|
||||
self::assertSame(
|
||||
[],
|
||||
$missing,
|
||||
sprintf(
|
||||
"Required images missing from home view:\n - %s",
|
||||
implode("\n - ", $missing),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testFloorPlanMapsCoverAllFloors(): void
|
||||
{
|
||||
$view = file_get_contents(self::VIEW_PATH);
|
||||
self::assertNotFalse($view, 'Could not read home view');
|
||||
|
||||
// Each floor in the $floors array must have an entry in BOTH maps
|
||||
// (primary 2D + extra 3D/alternate) so the floor body renders both.
|
||||
foreach (['eg', 'og1', 'og2', 'attic'] as $floorId) {
|
||||
self::assertStringContainsString(
|
||||
"'{$floorId}'",
|
||||
$view,
|
||||
"Floor '{$floorId}' not declared in home view",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string> relative paths (forward-slash, e.g. "grundrisse/EG.png")
|
||||
*/
|
||||
private function listBilderFiles(): array
|
||||
{
|
||||
$files = [];
|
||||
$iter = new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator(self::BILDER_DIR, \FilesystemIterator::SKIP_DOTS),
|
||||
);
|
||||
|
||||
foreach ($iter as $file) {
|
||||
if (!$file->isFile()) {
|
||||
continue;
|
||||
}
|
||||
$rel = substr($file->getPathname(), strlen(self::BILDER_DIR) + 1);
|
||||
$rel = str_replace(DIRECTORY_SEPARATOR, '/', $rel);
|
||||
$files[] = $rel;
|
||||
}
|
||||
|
||||
sort($files);
|
||||
return $files;
|
||||
}
|
||||
|
||||
private function isAllowedUnused(string $relPath): bool
|
||||
{
|
||||
foreach (self::ALLOWED_UNUSED as $pattern) {
|
||||
if (str_ends_with($pattern, '/')) {
|
||||
// Directory prefix
|
||||
if (str_starts_with($relPath, $pattern)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Glob-style match (only `*` supported, for `-small.*` variants)
|
||||
$regex = '#^' . str_replace('\\*', '.*', preg_quote($pattern, '#')) . '$#';
|
||||
if (preg_match($regex, $relPath) === 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base name = path minus extension. So "grundrisse/EG 3D.png" → "grundrisse/EG 3D",
|
||||
* and "Küche 1.jpg" → "Küche 1". Used to group source + auto-generated variants.
|
||||
*/
|
||||
private function baseOf(string $relPath): string
|
||||
{
|
||||
$dot = strrpos($relPath, '.');
|
||||
if ($dot === false || $dot === 0) {
|
||||
return $relPath;
|
||||
}
|
||||
return substr($relPath, 0, $dot);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user