+ [misc] Add unit tests for treeZen::getBranches() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -25,4 +25,27 @@ class treeTest
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getBranches method.
|
||||
*
|
||||
* @param object $product
|
||||
* @param string $viewType
|
||||
* @param int $currentModuleID
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function getBranchesTest(object $product = null, string $viewType = '', int $currentModuleID = 0)
|
||||
{
|
||||
if($product === null) {
|
||||
$product = (object)array('id' => 1, 'type' => 'normal', 'name' => 'Test Product');
|
||||
}
|
||||
|
||||
$method = $this->objectZen->getMethod('getBranches');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invokeArgs($this->objectZen->newInstance(), array($product, $viewType, $currentModuleID));
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 treeZen::getBranches();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行treeTest模块的getBranchesTest方法,参数是$normalProduct, 'story', 0 @0
|
||||
- 执行treeTest模块的getBranchesTest方法,参数是$branchProduct, 'story', 0 @0
|
||||
- 执行treeTest模块的getBranchesTest方法,参数是$platformProduct, 'bug', 0 @0
|
||||
- 执行treeTest模块的getBranchesTest方法,参数是$branchProduct, 'task', 0 @0
|
||||
- 执行treeTest模块的getBranchesTest方法,参数是$platformProduct, 'case', 0 @0
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/treezen.unittest.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$treeTest = new treeTest();
|
||||
|
||||
// 测试用例1:普通产品(normal类型)在story视图类型下获取分支
|
||||
$normalProduct = (object)array('id' => 1, 'type' => 'normal', 'name' => 'Normal Product');
|
||||
r($treeTest->getBranchesTest($normalProduct, 'story', 0)) && p() && e('0');
|
||||
|
||||
// 测试用例2:多分支产品在story视图类型下获取分支
|
||||
$branchProduct = (object)array('id' => 2, 'type' => 'branch', 'name' => 'Branch Product');
|
||||
r($treeTest->getBranchesTest($branchProduct, 'story', 0)) && p() && e('0');
|
||||
|
||||
// 测试用例3:多分支产品在bug视图类型下获取分支
|
||||
$platformProduct = (object)array('id' => 3, 'type' => 'platform', 'name' => 'Platform Product');
|
||||
r($treeTest->getBranchesTest($platformProduct, 'bug', 0)) && p() && e('0');
|
||||
|
||||
// 测试用例4:非story/bug/case视图类型的产品获取分支
|
||||
$branchProduct = (object)array('id' => 4, 'type' => 'branch', 'name' => 'Branch Product');
|
||||
r($treeTest->getBranchesTest($branchProduct, 'task', 0)) && p() && e('0');
|
||||
|
||||
// 测试用例5:case视图类型的多分支产品获取分支
|
||||
$platformProduct = (object)array('id' => 5, 'type' => 'platform', 'name' => 'Platform Product');
|
||||
r($treeTest->getBranchesTest($platformProduct, 'case', 0)) && p() && e('0');
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: branch table for getBranches test
|
||||
author: Claude
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
note: "分支ID"
|
||||
range: 1-10
|
||||
- field: product
|
||||
note: "所属产品"
|
||||
range: 1{2},2{3},3{2},4{2},5{1}
|
||||
- field: name
|
||||
note: "分支名称"
|
||||
range: master{2},develop{3},release{2},feature{2},hotfix{1}
|
||||
- field: status
|
||||
note: "分支状态"
|
||||
range: active{8},closed{2}
|
||||
- field: order
|
||||
note: "排序"
|
||||
range: 1-10
|
||||
- field: deleted
|
||||
note: "是否删除"
|
||||
range: 0{9},1{1}
|
||||
...
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: module table for getBranches test
|
||||
author: Claude
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
note: "模块ID"
|
||||
range: 1-8
|
||||
- field: root
|
||||
note: "产品根ID"
|
||||
range: 1{2},2{2},3{2},4{1},5{1}
|
||||
- field: branch
|
||||
note: "分支ID"
|
||||
range: 1{2},2{2},3{2},0{2}
|
||||
- field: name
|
||||
note: "模块名称"
|
||||
range: 需求模块{2},缺陷模块{2},测试模块{2},任务模块{2}
|
||||
- field: type
|
||||
note: "模块类型"
|
||||
range: story{2},bug{2},case{2},task{2}
|
||||
- field: deleted
|
||||
note: "是否删除"
|
||||
range: 0
|
||||
...
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: product table for getBranches test
|
||||
author: Claude
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
note: "产品ID"
|
||||
range: 1-5
|
||||
- field: name
|
||||
note: "产品名称"
|
||||
range: 正常产品{1},分支产品{1},平台产品{1},任务产品{1},测试产品{1}
|
||||
- field: code
|
||||
note: "产品代号"
|
||||
range: normal{1},branch{1},platform{1},task{1},test{1}
|
||||
- field: type
|
||||
note: "产品类型"
|
||||
range: normal{1},branch{1},platform{1},normal{1},branch{1}
|
||||
- field: status
|
||||
note: "产品状态"
|
||||
range: normal{4},closed{1}
|
||||
- field: deleted
|
||||
note: "是否删除"
|
||||
range: 0
|
||||
...
|
||||
Reference in New Issue
Block a user