+ [misc] Add unit tests for tutorialModel::getRisks() 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 311a03a5c3
commit cdf6578f83
2 changed files with 48 additions and 0 deletions
@@ -706,4 +706,19 @@ class tutorialTest
return $result;
}
/**
* 测试获取新手模式风险列表。
* Test get risks.
*
* @access public
* @return array
*/
public function getRisksTest(): array
{
$result = $this->objectModel->getRisks();
if(dao::isError()) return dao::getError();
return $result;
}
}
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env php
<?php
/**
title=测试 tutorialModel::getRisks();
timeout=0
cid=0
- 步骤1:获取风险列表,验证数组长度 @1
- 步骤2:验证第一个风险对象的ID第1条的id属性 @1
- 步骤3:验证第一个风险对象的名称第1条的name属性 @Test risk
- 步骤4:验证第一个风险对象的状态第1条的status属性 @active
- 步骤5:验证第一个风险对象的项目ID第1条的project属性 @2
*/
// 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. 执行测试步骤
r(count($tutorialTest->getRisksTest())) && p() && e('1'); // 步骤1:获取风险列表,验证数组长度
r($tutorialTest->getRisksTest()) && p('1:id') && e('1'); // 步骤2:验证第一个风险对象的ID
r($tutorialTest->getRisksTest()) && p('1:name') && e('Test risk'); // 步骤3:验证第一个风险对象的名称
r($tutorialTest->getRisksTest()) && p('1:status') && e('active'); // 步骤4:验证第一个风险对象的状态
r($tutorialTest->getRisksTest()) && p('1:project') && e('2'); // 步骤5:验证第一个风险对象的项目ID