|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
$root = dirname(__DIR__, 2);
|
|
|
|
|
$read = static function (string $path) use ($root): string {
|
|
|
|
|
$content = file_get_contents($root . '/' . $path);
|
|
|
|
|
if ($content === false) throw new RuntimeException('Cannot read ' . $path);
|
|
|
|
|
return $content;
|
|
|
|
|
};
|
|
|
|
|
$assert = static function (bool $condition, string $message): void {
|
|
|
|
|
if (!$condition) throw new RuntimeException($message);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$routes = $read('web/config/routes.php');
|
|
|
|
|
$assert(str_contains($routes, "'/terms', 'App\\Controllers\\LegalController:terms'")
|
|
|
|
|
&& str_contains($routes, "'/privacy', 'App\\Controllers\\LegalController:privacy'"),
|
|
|
|
|
'Public legal routes are missing.');
|
|
|
|
|
foreach (['draft', 'publish'] as $action) {
|
|
|
|
|
$pattern = "#post\\('/legal/\\{slug:terms\\|privacy\\}/{$action}'.*?LegalController:{$action}'\\)->add\\(new SuperAdmin\\(\\)\\)#";
|
|
|
|
|
$assert(preg_match($pattern, $routes) === 1, "{$action} route is not protected by SuperAdmin middleware.");
|
|
|
|
|
}
|
|
|
|
|
$assert(str_contains($routes, "LegalController:preview") && !str_contains($routes, '/legal/{domain}'),
|
|
|
|
|
'Legal preview is missing or legal content became domain scoped.');
|
|
|
|
|
|
|
|
|
|
$migration = $read('web/sql/legal_documents.sql');
|
|
|
|
|
$fresh = $read('web/sql/ss.sql');
|
|
|
|
|
foreach (['legal_documents', 'legal_document_revisions'] as $table) {
|
|
|
|
|
$assert(str_contains($migration, "`{$table}`") && str_contains($fresh, "CREATE TABLE `{$table}`"),
|
|
|
|
|
"{$table} is absent from migration or fresh schema.");
|
|
|
|
|
}
|
|
|
|
|
$assert(!preg_match('/`(?:domain|host|hostname)`/i', $migration), 'Legal schema is incorrectly partitioned by domain.');
|
|
|
|
|
$assert(str_contains($migration, 'uniq_legal_document_slug_locale')
|
|
|
|
|
&& str_contains($migration, 'uniq_legal_document_revision'), 'Legal uniqueness contracts are missing.');
|
|
|
|
|
|
|
|
|
|
$admin = $read('web/resources/views/venix/admin/legal.tpl');
|
|
|
|
|
$adminJs = $read('web/public/theme/venix/js/admin-legal.js');
|
|
|
|
|
$sidebar = $read('web/resources/views/venix/admin/static_header.tpl');
|
|
|
|
|
$assert(str_contains($sidebar, 'href="/admin/legal"') && str_contains($sidebar, '法律页面'),
|
|
|
|
|
'Admin navigation does not expose legal content.');
|
|
|
|
|
$assert(str_contains($admin, '草稿不会自动公开') && str_contains($admin, '发布历史')
|
|
|
|
|
&& str_contains($admin, '所有配置域名共享同一份内容') && str_contains($admin, 'sandbox=""'),
|
|
|
|
|
'Admin editor does not communicate or enforce the publishing model.');
|
|
|
|
|
$assert(str_contains($adminJs, "'/preview'") && str_contains($adminJs, "write('draft')")
|
|
|
|
|
&& str_contains($adminJs, "write('publish')") && str_contains($adminJs, '请求结果未确认'),
|
|
|
|
|
'Admin editor runtime is missing preview, write, or uncertain-result handling.');
|
|
|
|
|
|
|
|
|
|
$landing = $read('web/resources/views/venix/index.tpl');
|
|
|
|
|
$legal = $read('web/resources/views/venix/legal.tpl');
|
|
|
|
|
$footer = $read('web/resources/views/venix/home/site_footer.tpl');
|
|
|
|
|
$css = $read('web/public/theme/venix/css/home.css');
|
|
|
|
|
$assert(str_contains($landing, 'landing-console') && str_contains($landing, 'id="capabilities"')
|
|
|
|
|
&& str_contains($landing, 'landing-workflow') && str_contains($css, '.landing-hero'),
|
|
|
|
|
'The approved console-led landing page was not integrated.');
|
|
|
|
|
$assert(preg_match('/\.landing-site-header\s*\{[^}]*position:\s*fixed;/s', $css) === 1
|
|
|
|
|
&& preg_match('/\.landing-main-nav\s*\{[^}]*margin-left:\s*auto;[^}]*justify-content:\s*flex-end;/s', $css) === 1,
|
|
|
|
|
'Landing navigation is not fixed to the top and right aligned.');
|
|
|
|
|
$assert(str_contains($legal, '{$legal_document.content_html nofilter}')
|
|
|
|
|
&& str_contains($legal, 'legal_document.outline') && str_contains($css, '.legal-layout'),
|
|
|
|
|
'Published legal content or its responsive information architecture is missing.');
|
|
|
|
|
$assert(preg_match('/\.legal-page\s*\{[^}]*padding-bottom:\s*0;/s', $css) === 1
|
|
|
|
|
&& preg_match('/\.legal-contact\s*\{[^}]*width:\s*100%;[^}]*margin:\s*100px 0 0;[^}]*border-radius:\s*0;/s', $css) === 1
|
|
|
|
|
&& !preg_match('/\.legal-fallback-notice,\s*\.legal-layout,\s*\.legal-contact\s*\{[^}]*width:\s*calc\(100% - 32px\);/s', $css),
|
|
|
|
|
'The legal-page contact band is not full bleed across desktop and mobile layouts.');
|
|
|
|
|
$assert(str_contains($footer, "public.shell.footer.copyright")
|
|
|
|
|
&& str_contains($footer, 'href="/terms') && str_contains($footer, 'href="/privacy')
|
|
|
|
|
&& !str_contains($footer, '?lang=en'),
|
|
|
|
|
'Landing footer lacks dynamic copyright or legal links.');
|
|
|
|
|
|
|
|
|
|
$register = $read('web/resources/views/venix/auth/register.tpl');
|
|
|
|
|
$auth = $read('web/app/Controllers/AuthController.php');
|
|
|
|
|
$assert(str_contains($register, 'id="accept_legal"') && str_contains($register, 'accept_legal:')
|
|
|
|
|
&& str_contains($register, 'href="/terms') && str_contains($register, 'href="/privacy'),
|
|
|
|
|
'Registration does not collect explicit legal consent.');
|
|
|
|
|
$assert(!str_contains($register, 'termsModal') && !str_contains($register, 'openTerms()'),
|
|
|
|
|
'The retired hard-coded terms modal remains.');
|
|
|
|
|
$assert(str_contains($auth, "Config::get('tos_reg') === 'true'")
|
|
|
|
|
&& str_contains($auth, "\$read('accept_legal') !== 'true'"),
|
|
|
|
|
'Legal consent is only client-side and can be bypassed.');
|
|
|
|
|
|
|
|
|
|
$assets = $read('web/resources/views/venix/layout_assets.tpl');
|
|
|
|
|
$assert(preg_match("/venix_asset_version value='([0-9]+)'/", $assets, $assetVersion) === 1
|
|
|
|
|
&& (int) $assetVersion[1] >= 2026102804
|
|
|
|
|
&& str_contains($admin, '?v={$venix_asset_version}')
|
|
|
|
|
&& str_contains($read('web/resources/views/venix/home/layout_header.tpl'), '?v={$venix_asset_version}'),
|
|
|
|
|
'Shared browser asset version was not coupled to the new assets.');
|
|
|
|
|
|
|
|
|
|
$deployment = $read('docs/DEPLOYMENT.md');
|
|
|
|
|
$pruning = $read('docs/PRUNING_REPORT.md');
|
|
|
|
|
$assert(str_contains($deployment, 'web/sql/legal_documents.sql')
|
|
|
|
|
&& str_contains($deployment, '不按域名拆分') && str_contains($pruning, '全局服务条款'),
|
|
|
|
|
'Deployment or retained-feature documentation is stale.');
|
|
|
|
|
|
|
|
|
|
echo "Legal pages contract tests passed.\n";
|