文件
nahaichuan/tests/ProductsPageTest.php

138 行
6.7 KiB
PHP

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
/**
* 产品独立页改版规范与内容完整性测试 (TDD 模式)
* 验证产品页必备板块:矩阵、功能、版本、定价、演示,以及色彩体系、去AI味道与禁止项
*/
class ProductsPageTest
{
private $passed = 0;
private $failed = 0;
private $htmlContent = '';
private $cssContent = '';
public function __construct()
{
$baseDir = dirname(__DIR__);
$productFile = $baseDir . '/addons/official/view/web/official_product/product_page.html';
$listFile = $baseDir . '/addons/official/view/web/official_product/list.html';
$cssFile = $baseDir . '/public/assets/addons/official/css/modern_nhc.css';
$this->htmlContent = '';
if (file_exists($productFile)) {
$this->htmlContent .= file_get_contents($productFile) . "\n";
}
if (file_exists($listFile)) {
$this->htmlContent .= file_get_contents($listFile) . "\n";
}
if (file_exists($cssFile)) {
$this->cssContent = file_get_contents($cssFile);
}
}
public function run()
{
echo "=== 开始执行产品独立页设计规范与内容完整性测试 (TDD) ===\n";
// 1. 品牌名称必须为纳海川
$this->testBrandName();
// 2. 必备四大产品线
$this->testProductLines();
// 3. 必备板块测试:矩阵、功能、版本、定价、演示 (AGENTS.md 规范)
$this->testEssentialSections();
// 4. 去除 AI 味道:真实具体的业务参数与商业能力
$this->testNoAiCharacteristics();
// 5. 禁止项测试(严禁 emoji)
$this->testForbiddenElements();
// 6. 色彩与设计规范
$this->testDesignTokens();
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 testProductLines()
{
$this->assert(strpos($this->htmlContent, '商城') !== false, "必须深度包含【商城系统】产品线");
$this->assert(strpos($this->htmlContent, '收银') !== false, "必须深度包含【智能收银系统】产品线");
$this->assert(strpos($this->htmlContent, '进销存') !== false, "必须深度包含【进销存系统】产品线");
$this->assert(strpos($this->htmlContent, 'SaaS') !== false, "必须深度包含【SaaS版本/云原生平台】产品线");
}
public function testEssentialSections()
{
// 按照 AGENTS.md 规范:产品页含矩阵、功能、版本、定价、演示
$hasMatrix = (strpos($this->htmlContent, 'nhc-product-matrix') !== false || strpos($this->htmlContent, '产品矩阵') !== false || strpos($this->htmlContent, '商业矩阵') !== false);
$this->assert($hasMatrix, "产品页必须包含【矩阵】(产品矩阵全景)板块");
$hasFeatures = (strpos($this->htmlContent, 'nhc-product-features') !== false || strpos($this->htmlContent, '功能架构') !== false || strpos($this->htmlContent, '核心功能') !== false);
$this->assert($hasFeatures, "产品页必须包含【功能】(功能深度架构与模块拆解)板块");
$hasEditions = (strpos($this->htmlContent, 'nhc-product-editions') !== false || strpos($this->htmlContent, '版本对比') !== false || strpos($this->htmlContent, '版本选型') !== false);
$this->assert($hasEditions, "产品页必须包含【版本】(多商业版本功能对比)板块");
$hasPricing = (strpos($this->htmlContent, 'nhc-product-pricing') !== false || strpos($this->htmlContent, '定价') !== false || strpos($this->htmlContent, '部署模式') !== false || strpos($this->htmlContent, '商业授权') !== false);
$this->assert($hasPricing, "产品页必须包含【定价】(部署模式与商业合作/定价策略)板块");
$hasDemo = (strpos($this->htmlContent, 'nhc-product-demo') !== false || strpos($this->htmlContent, '在线演示') !== false || strpos($this->htmlContent, '预约演示') !== false || strpos($this->htmlContent, '申请演示') !== false);
$this->assert($hasDemo, "产品页必须包含【演示】(在线体验/沙箱演示预约)板块");
}
public function testNoAiCharacteristics()
{
// 真实具体参数:多商户、离线记账、批次批号、多租户等
$hasRealParams = (strpos($this->htmlContent, '多商户') !== false || strpos($this->htmlContent, '分销') !== false)
&& (strpos($this->htmlContent, '离线') !== false || strpos($this->htmlContent, '扫码') !== false)
&& (strpos($this->htmlContent, '批次') !== false || strpos($this->htmlContent, '盘点') !== false)
&& (strpos($this->htmlContent, '多租户') !== false || strpos($this->htmlContent, '隔离') !== false);
$this->assert($hasRealParams, "去AI味道:必须展示具体的商业系统功能参数与落地特性,拒绝假大空套话");
// 商业版本清晰边界
$hasVersions = (strpos($this->htmlContent, '标准版') !== false || strpos($this->htmlContent, '企业版') !== false || strpos($this->htmlContent, '旗舰版') !== false || strpos($this->htmlContent, '定制') !== false);
$this->assert($hasVersions, "去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 主色规范");
}
}
$test = new ProductsPageTest();
$test->run();