* [unittest] fix mergebranch error.

This commit is contained in:
tianshujie
2025-06-11 09:35:55 +08:00
parent c8966928ad
commit c439e789da
2 changed files with 16 additions and 11 deletions
@@ -404,9 +404,9 @@ class branchTest
* @param string $mergedBranches
* @param object $data
* @access public
* @return array|int
* @return array
*/
public function mergeBranchTest(int $productID, string $mergedBranches, object $data): array|int
public function mergeBranchTest(int $productID, string $mergedBranches, object $data): array
{
$data->status = 'active';
$data->createdDate = helper::today();
@@ -414,8 +414,7 @@ class branchTest
if(dao::isError()) return dao::getError();
$branches = $this->objectModel->dao->select('*')->from(TABLE_BRANCH)->where('deleted')->eq(0)->andWhere('product')->eq($productID)->fetchAll();
return count($branches);
return $this->objectModel->dao->select('*')->from(TABLE_BRANCH)->where('deleted')->eq(0)->andWhere('product')->eq($productID)->fetchAll();
}
/**
+13 -7
View File
@@ -11,12 +11,18 @@ su('admin');
/**
title=测试 branchModel->mergeBranch();
timeout=1
timeout=0
cid=1
- 测试合并分支 1 到 分支 2 @2
- 测试合并分支 2 到 新建分支 @3
- 测试合并分支 3 4 到 主干 @1
- 测试合并分支 1 到 分支 2
- 第0条的product属性 @6
- 第0条的name属性 @分支2
- 测试合并分支 2 到 新建分支
- 第0条的product属性 @6
- 第0条的name属性 @分支2
- 测试合并分支 3 4 到 主干
- 第0条的product属性 @7
- 第0条的name属性 @分支5
*/
$productID = array(6, 7);
@@ -40,6 +46,6 @@ $mergeBranch3->mergedBranchIDList = array(4, 5);
$mergeBranch3->targetBranch = 0;
$branch = new branchTest();
r($branch->mergeBranchTest($productID[0], $mergedBranches[0], $mergeBranch1)) && p() && e('2'); // 测试合并分支 1 到 分支 2
r($branch->mergeBranchTest($productID[0], $mergedBranches[1], $mergeBranch2)) && p() && e('3'); // 测试合并分支 2 到 新建分支
r($branch->mergeBranchTest($productID[1], $mergedBranches[2], $mergeBranch3)) && p() && e('1'); // 测试合并分支 3 4 到 主干
r($branch->mergeBranchTest($productID[0], $mergedBranches[0], $mergeBranch1)) && p('0:product,name') && e('6,分支2'); // 测试合并分支 1 到 分支 2
r($branch->mergeBranchTest($productID[0], $mergedBranches[1], $mergeBranch2)) && p('0:product,name') && e('6,分支2'); // 测试合并分支 2 到 新建分支
r($branch->mergeBranchTest($productID[1], $mergedBranches[2], $mergeBranch3)) && p('0:product,name') && e('7,分支5'); // 测试合并分支 3 4 到 主干