+ [misc] Add unit tests for tutorialModel::getCommits() 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:27 +08:00
co-authored by Claude
parent a41b45a807
commit 1688e44cbd
2 changed files with 47 additions and 0 deletions
@@ -1334,4 +1334,18 @@ class tutorialTest
return $result;
}
/**
* Test getCommits method.
*
* @access public
* @return array
*/
public function getCommitsTest(): array
{
$result = $this->objectModel->getCommits();
if(dao::isError()) return dao::getError();
return $result;
}
}
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env php
<?php
/**
title=测试 tutorialModel::getCommits();
timeout=0
cid=0
- 步骤1:验证返回数组长度为1 @1
- 步骤2:验证提交记录ID第bedeaaf39ef7084b9a455b9d9dba71e2db357201条的id属性 @1
- 步骤3:验证代码库ID第bedeaaf39ef7084b9a455b9d9dba71e2db357201条的repo属性 @1
- 步骤4:验证提交者第bedeaaf39ef7084b9a455b9d9dba71e2db357201条的committer属性 @admin
- 步骤5:验证提交注释第bedeaaf39ef7084b9a455b9d9dba71e2db357201条的comment属性 @Git comment.
*/
// 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->getCommitsTest())) && p() && e('1'); // 步骤1:验证返回数组长度为1
r($tutorialTest->getCommitsTest()) && p('bedeaaf39ef7084b9a455b9d9dba71e2db357201:id') && e('1'); // 步骤2:验证提交记录ID
r($tutorialTest->getCommitsTest()) && p('bedeaaf39ef7084b9a455b9d9dba71e2db357201:repo') && e('1'); // 步骤3:验证代码库ID
r($tutorialTest->getCommitsTest()) && p('bedeaaf39ef7084b9a455b9d9dba71e2db357201:committer') && e('admin'); // 步骤4:验证提交者
r($tutorialTest->getCommitsTest()) && p('bedeaaf39ef7084b9a455b9d9dba71e2db357201:comment') && e('Git comment.'); // 步骤5:验证提交注释