b2in/tests/Unit/NamespacePathCaseTest.php
Kevin Adametz a661a68913 Hotfix: Livewire-UI-Komponenten im Ordner Ui (wie der Namespace)
Der Ordner hieß im Repository UI, der Namespace App\Livewire\Web\Components\Ui. Auf dem
Mac fällt das nicht auf, auf Linux findet der Autoloader die Klassen nicht: Header,
Footer usw. rendern ohne Klasse (500, Undefined variable $logoPath). Wächtertest prüft
Pfad und Namespace auf gleiche Schreibweise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 09:11:39 +00:00

33 lines
1.3 KiB
PHP

<?php
/**
* Der Live-Server (Linux) unterscheidet Groß- und Kleinschreibung, macOS nicht. Weicht ein
* Ordnername nur in der Schreibweise vom Namespace ab (UI statt Ui), findet der Autoloader die
* Klasse lokal, auf Live aber nicht (09.10.2026: Header ohne Klasse, 500 nach dem Deploy).
*/
it('keeps every class path in the exact case of its namespace', function () {
$root = dirname(__DIR__, 2);
exec('git -C '.escapeshellarg($root).' ls-files app database/seeders database/factories', $files);
$roots = ['app/' => 'App/', 'database/seeders/' => 'Database/Seeders/', 'database/factories/' => 'Database/Factories/'];
$mismatches = [];
foreach ($files as $file) {
if (! str_ends_with($file, '.php') || ! preg_match('/^namespace\s+([^;]+);/m', (string) file_get_contents($root.'/'.$file), $match)) {
continue;
}
foreach ($roots as $path => $namespacePath) {
if (str_starts_with($file, $path)) {
$expected = dirname($namespacePath.substr($file, strlen($path)));
$declared = str_replace('\\', '/', $match[1]);
if ($declared !== $expected && strcasecmp($declared, $expected) === 0) {
$mismatches[] = "{$file} → {$match[1]}";
}
}
}
}
expect($mismatches)->toBe([]);
});