+ [misc] Add unit tests for tutorialModel::getTestReports() 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 ae8d5d7813
commit af7a37ba26
2 changed files with 48 additions and 0 deletions
@@ -616,4 +616,19 @@ class tutorialTest
return $result;
}
/**
* 测试获取新手模式测试报告列表。
* Test get testreports.
*
* @access public
* @return array
*/
public function getTestReportsTest(): array
{
$result = $this->objectModel->getTestReports();
if(dao::isError()) return dao::getError();
return $result;
}
}
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env php
<?php
/**
title=测试 tutorialModel::getTestReports();
timeout=0
cid=0
- 步骤1:验证返回数组包含1个元素 @1
- 步骤2:验证包含ID为1的测试报告第1条的id属性 @1
- 步骤3:验证测试报告标题第1条的title属性 @Test testreport
- 步骤4:验证对象类型第1条的objectType属性 @execution
- 步骤5:验证对象ID第1条的objectID属性 @3
*/
// 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->getTestReportsTest())) && p() && e('1'); // 步骤1:验证返回数组包含1个元素
r($tutorialTest->getTestReportsTest()) && p('1:id') && e('1'); // 步骤2:验证包含ID为1的测试报告
r($tutorialTest->getTestReportsTest()) && p('1:title') && e('Test testreport'); // 步骤3:验证测试报告标题
r($tutorialTest->getTestReportsTest()) && p('1:objectType') && e('execution'); // 步骤4:验证对象类型
r($tutorialTest->getTestReportsTest()) && p('1:objectID') && e('3'); // 步骤5:验证对象ID