+ [misc] Add unit tests for storyModel::getLinkedCommits() 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:24 +08:00
co-authored by Claude
parent 3abfaa43fc
commit ac6ccbace1
5 changed files with 156 additions and 0 deletions
@@ -1578,4 +1578,20 @@ class storyTest
return $result;
}
/**
* Test getLinkedCommits method.
*
* @param int $repoID
* @param array $revisions
* @access public
* @return mixed
*/
public function getLinkedCommitsTest(int $repoID, array $revisions)
{
$result = $this->objectModel->getLinkedCommits($repoID, $revisions);
if(dao::isError()) return dao::getError();
return count($result);
}
}
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env php
<?php
/**
title=测试 storyModel::getLinkedCommits();
timeout=0
cid=0
- 执行storyTest模块的getLinkedCommitsTest方法,参数是1, array @0
- 执行storyTest模块的getLinkedCommitsTest方法,参数是999, array @0
- 执行storyTest模块的getLinkedCommitsTest方法,参数是1, array @0
- 执行storyTest模块的getLinkedCommitsTest方法,参数是0, array @0
- 执行storyTest模块的getLinkedCommitsTest方法,参数是1, array @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/story.unittest.class.php';
zendata('repohistory')->loadYaml('repohistory_getlinkedcommits', false, 2)->gen(5);
zendata('relation')->loadYaml('relation_getlinkedcommits', false, 2)->gen(5);
zendata('story')->loadYaml('story_getlinkedcommits', false, 2)->gen(5);
su('admin');
$storyTest = new storyTest();
r($storyTest->getLinkedCommitsTest(1, array('abc123', 'def456'))) && p() && e('0');
r($storyTest->getLinkedCommitsTest(999, array('abc123'))) && p() && e('0');
r($storyTest->getLinkedCommitsTest(1, array())) && p() && e('0');
r($storyTest->getLinkedCommitsTest(0, array('abc123'))) && p() && e('0');
r($storyTest->getLinkedCommitsTest(1, array('abc123', 'def456', 'ghi789'))) && p() && e('0');
@@ -0,0 +1,41 @@
---
title: 关系表数据定义
desc: 用于getLinkedCommits方法测试的关系表数据
fields:
- field: id
note: 关系ID
range: 1-8
- field: project
note: 项目ID
range: 1{3}, 2{3}, 3{2}
- field: product
note: 产品ID
range: 1{4}, 2{4}
- field: execution
note: 执行ID
range: 1{4}, 2{4}
- field: AType
note: A类型
range: story{8}
- field: AID
note: A对象ID(需求ID)
range: 1{2}, 2{2}, 3{2}, 4{1}, 5{1}
- field: AVersion
note: A版本
range: 1{8}
- field: relation
note: 关系类型
range: completedin{8}
- field: BType
note: B类型
range: commit{8}
- field: BID
note: B对象ID(提交ID)
range: 1-8
- field: BVersion
note: B版本
range: 1{8}
- field: extra
note: 额外信息
range: []{8}
@@ -0,0 +1,27 @@
---
title: 仓库历史记录数据定义
desc: 用于getLinkedCommits方法测试的仓库历史记录数据
fields:
- field: id
note: 历史记录ID
range: 1-10
- field: repo
note: 仓库ID
range: 1{5}, 2{3}, 3{2}
- field: revision
note: 版本号
range: abc123,def456,ghi789,jkl012,mno345
- field: commit
note: 提交ID
range: 1-10
- field: comment
note: 提交注释
range: Fix bug in user module,Add new feature to story,Update documentation,Refactor code structure,Optimize database queries,Add unit tests,Fix typo in comments,Remove unused code,Update configuration,Clean up old files
- field: committer
note: 提交者
range: admin{3},user1{2},user2{2},tester{2},developer{1}
- field: time
note: 提交时间
range: (-30D)-(-1D):1D
format: YYYY-MM-DD hh:mm:ss
@@ -0,0 +1,39 @@
---
title: 需求表数据定义
desc: 用于getLinkedCommits方法测试的需求表数据
fields:
- field: id
note: 需求ID
range: 1-5
- field: product
note: 产品ID
range: 1{3}, 2{2}
- field: branch
note: 分支ID
range: 0{5}
- field: title
note: 需求标题
range: 用户登录功能,产品管理模块,数据统计功能,权限管理系统,接口优化需求
- field: status
note: 需求状态
range: active{3}, draft{1}, closed{1}
- field: stage
note: 需求阶段
range: projected{2}, developing{2}, testing{1}
- field: type
note: 需求类型
range: story{5}
- field: estimate
note: 预计工时
range: 8{2}, 16{2}, 24{1}
- field: version
note: 版本号
range: 1{5}
- field: openedBy
note: 创建者
range: admin{2}, user1{2}, user2{1}
- field: openedDate
note: 创建时间
range: (-15D)-(-5D):2D
format: YYYY-MM-DD hh:mm:ss