+ [misc] Add unit tests for tutorialModel::getReviews() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-15 15:06:26 +08:00
co-authored by Claude
parent bd71bda884
commit 6c74369be4
2 changed files with 48 additions and 0 deletions
@@ -766,4 +766,19 @@ class tutorialTest
return $result;
}
/**
* 测试获取新手模式评审列表。
* Test get reviews.
*
* @access public
* @return array
*/
public function getReviewsTest(): array
{
$result = $this->objectModel->getReviews();
if(dao::isError()) return dao::getError();
return $result;
}
}
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env php
<?php
/**
title=测试 tutorialModel::getReviews();
timeout=0
cid=0
- 步骤1:正常调用返回数组长度 @1
- 步骤2:验证评审ID第1条的id属性 @1
- 步骤3:验证评审标题第1条的title属性 @Test Review
- 步骤4:验证评审状态第1条的status属性 @pass
- 步骤5:验证评审产品ID第1条的product属性 @1
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/tutorial.unittest.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$tutorialTest = new tutorialTest();
// 4. 🔴 强制要求:必须包含至少5个测试步骤
r(count($tutorialTest->getReviewsTest())) && p() && e('1'); // 步骤1:正常调用返回数组长度
r($tutorialTest->getReviewsTest()) && p('1:id') && e('1'); // 步骤2:验证评审ID
r($tutorialTest->getReviewsTest()) && p('1:title') && e('Test Review'); // 步骤3:验证评审标题
r($tutorialTest->getReviewsTest()) && p('1:status') && e('pass'); // 步骤4:验证评审状态
r($tutorialTest->getReviewsTest()) && p('1:product') && e('1'); // 步骤5:验证评审产品ID