htmlContent = file_get_contents($contactFile); } if (file_exists($mobileContactFile)) { $this->mobileHtmlContent = file_get_contents($mobileContactFile); } 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 规范:联系我们含表单、地图、电话 $hasForm = (strpos($this->htmlContent, '