htmlContent = file_get_contents($singleFile); } if (file_exists($mobileSingleFile)) { $this->mobileHtmlContent = file_get_contents($mobileSingleFile); } if (file_exists($cssFile)) { $this->cssContent = file_get_contents($cssFile); } } public function run() { echo "=== 开始执行关于我们独立页设计规范与内容完整性测试 (TDD) ===\n"; // 1. 品牌名称必须为纳海川 $this->testBrandName(); // 2. 必备板块测试:品牌、团队、资质 (AGENTS.md 规范) $this->testEssentialSections(); // 3. 去除 AI 味道:真实工程哲学、技术委员会成员、具体软著资质 $this->testNoAiCharacteristics(); // 4. 禁止项测试(严禁 emoji) $this->testForbiddenElements(); // 5. 色彩与设计规范 $this->testDesignTokens(); // 6. 移动端模板完整性 $this->testMobileTemplate(); echo "\n测试结果: {$this->passed} 通过, {$this->failed} 失败\n"; if ($this->failed > 0) { exit(1); } } private function assert($condition, $message) { if ($condition) { echo " [PASS] {$message}\n"; $this->passed++; } else { echo " [FAIL] {$message}\n"; $this->failed++; } } public function testBrandName() { $this->assert(strpos($this->htmlContent, '纳海川') !== false, "关于我们页面必须明确包含品牌名称【纳海川】"); $hasWrongAbbr = preg_match('/纳川(?![海])/u', $this->htmlContent); $this->assert(!$hasWrongAbbr, "关于我们页面严禁错误简称为【纳川】"); } public function testEssentialSections() { // 按照 AGENTS.md 规范:关于我们含品牌、团队、资质 $hasBrand = (strpos($this->htmlContent, 'nhc-about-brand') !== false || strpos($this->htmlContent, '品牌') !== false || strpos($this->htmlContent, '工程哲学') !== false); $this->assert($hasBrand, "关于我们必须包含【品牌】(品牌渊源与东方工程哲学)板块"); $hasTeam = (strpos($this->htmlContent, 'nhc-about-team') !== false || strpos($this->htmlContent, '技术委员会') !== false || strpos($this->htmlContent, '核心团队') !== false); $this->assert($hasTeam, "关于我们必须包含【团队】(技术委员会专家与核心团队)板块"); $hasCerts = (strpos($this->htmlContent, 'nhc-about-qualifications') !== false || strpos($this->htmlContent, '软件著作权') !== false || strpos($this->htmlContent, '合规体系') !== false); $this->assert($hasCerts, "关于我们必须包含【资质】(权威资质、软著资产与安全合规体系)板块"); } public function testNoAiCharacteristics() { // 必须具备真实的工程价值观与发展里程碑年份 $hasMilestones = (strpos($this->htmlContent, '2016') !== false || strpos($this->htmlContent, '2019') !== false || strpos($this->htmlContent, '2024') !== false || strpos($this->htmlContent, '发展历程') !== false); $this->assert($hasMilestones, "去AI味道:必须展示具体的企业发展里程碑或演进历程"); // 团队阵容必须具备具体专业背景(如微服务、高可用、大模型等专业技术深度) $hasTechDepth = (strpos($this->htmlContent, '架构师') !== false || strpos($this->htmlContent, '全栈') !== false || strpos($this->htmlContent, '智能体') !== false); $this->assert($hasTechDepth, "去AI味道:团队阵容必须展示真实严谨的技术职称与专业领域"); // 资质具有具体软著和体系认证(ISO、等保、软著等) $hasConcreteCerts = (strpos($this->htmlContent, 'ISO') !== false || strpos($this->htmlContent, '著作权') !== false || strpos($this->htmlContent, '等保') !== false); $this->assert($hasConcreteCerts, "去AI味道:资质板块必须展示具体真实的行业认证体系与软著资产"); } public function testForbiddenElements() { $hasEmoji = preg_match('/[\x{1F600}-\x{1F64F}\x{1F300}-\x{1F5FF}\x{1F680}-\x{1F6FF}\x{2600}-\x{26FF}\x{2700}-\x{27BF}]/u', $this->htmlContent); $this->assert(!$hasEmoji, "关于我们页面严禁使用任何 emoji 表情符号"); } public function testDesignTokens() { $hasSerif = (stripos($this->cssContent, 'SimSun') !== false || stripos($this->cssContent, 'Songti') !== false || stripos($this->cssContent, 'Noto Serif SC') !== false); $this->assert($hasSerif, "必须沿用宋体标题规范"); $hasPrimary = (stripos($this->cssContent, '#2563EB') !== false || stripos($this->cssContent, '#2563eb') !== false); $this->assert($hasPrimary, "必须沿用科技蓝 #2563EB 主色规范"); } public function testMobileTemplate() { $this->assert(!empty($this->mobileHtmlContent), "移动端关于我们模板 single_e.html 文件必须存在"); $this->assert(strpos($this->mobileHtmlContent, '纳海川') !== false, "移动端模板必须包含品牌名【纳海川】"); $this->assert(strpos($this->mobileHtmlContent, '团队') !== false || strpos($this->mobileHtmlContent, '专家') !== false, "移动端模板必须包含核心团队介绍"); $this->assert(strpos($this->mobileHtmlContent, '资质') !== false || strpos($this->mobileHtmlContent, '著作权') !== false, "移动端模板必须包含资质认证板块"); } } $test = new AboutPageTest(); $test->run();