Files
preland/tests/check-preland-footer.php
T

21 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
$root = dirname(__DIR__);
foreach (['abcd1','abcd2','abcd0','invalid'] as $part) foreach (['light', 'dark'] as $theme) foreach ([
'zoomstage.online' => 'zoomstage.online',
'New-Preland.example:8080' => 'new-preland.example',
'www.example.test.' => 'www.example.test',
'<script>alert(1)</script>' => 'fixture.local',
] as $host => $expected) {
$html = shell_exec(PHP_BINARY . ' ' . escapeshellarg(__DIR__ . '/render-preland.php') . ' ' . escapeshellarg($host) . ' ' . escapeshellarg($theme) . ' ' . escapeshellarg($part));
if (!preg_match('~<footer\b.*?</footer>~s', $html, $match)) throw new RuntimeException('Подвал не найден');
$footer = $match[0];
foreach (['Наши реквизиты', 'payment.svg', 'ИНН:', 'ОГРНИП:', 'ИП Иванов', 'ИП Кардаполова', 'Для бизнеса', '/public/api-pricing'] as $forbidden) {
if (str_contains($footer, $forbidden)) throw new RuntimeException('В подвале остался ' . $forbidden);
}
if (!str_contains($footer, date('Y') . '© ' . $expected)) throw new RuntimeException('Неправильный домен копирайта: ' . $host);
if (substr_count($footer, '<img ') !== 2) throw new RuntimeException('Нужны только два тематических SVG логотипа');
if (str_contains($footer, '<script>')) throw new RuntimeException('Host попал в HTML без проверки');
}
echo "OK: минимальный подвал, две темы, перенос домена/порт/trailing-dot и invalid-host\n";