diff --git a/module/programplan/test/lib/programplan.unittest.class.php b/module/programplan/test/lib/programplan.unittest.class.php index 0ae8815a05..9e0b79d77b 100644 --- a/module/programplan/test/lib/programplan.unittest.class.php +++ b/module/programplan/test/lib/programplan.unittest.class.php @@ -459,7 +459,13 @@ class programplanTest if(dao::isError()) return dao::getError(); - return $objects; + $result = array(); + foreach($objects as $planID => $siblings) + { + $result[$planID] = count($siblings); + } + + return $result; } /** diff --git a/module/programplan/test/model/getsiblings.php b/module/programplan/test/model/getsiblings.php index 9132c4f6da..e436337522 100755 --- a/module/programplan/test/model/getsiblings.php +++ b/module/programplan/test/model/getsiblings.php @@ -3,28 +3,43 @@ /** -title=测试programplanModel->getSiblings(); +title=测试 programplanModel::getSiblings(); +timeout=0 cid=0 -- 测试id为2时获取兄弟阶段的的名称属性name @阶段b -- 测试id为2时获取自己兄弟阶段的个数 @1 -- 测试id为4时获取自己兄弟阶段的个数 @0 +- 执行programplan模块的getSiblingsTest方法,参数是3 属性3 @4 +- 执行programplan模块的getSiblingsTest方法,参数是[3, 4] + - 属性3 @4 + - 属性4 @4 +- 执行programplan模块的getSiblingsTest方法,参数是999 属性999 @0 +- 执行programplan模块的getSiblingsTest方法,参数是'4' 属性4 @4 +- 执行programplan模块的getSiblingsTest方法,参数是9 属性9 @3 +- 执行programplan模块的getSiblingsTest方法,参数是1 属性1 @3 +- 执行programplan模块的getSiblingsTest方法,参数是[7, 8] + - 属性7 @2 + - 属性8 @2 */ include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/lib/programplan.unittest.class.php'; + +$table = zenData('project'); +$table->id->range('1-10'); +$table->name->range('项目集1{1},项目集2{1},阶段a{1},阶段b{1},阶段c{1},阶段d{1},子阶段1{1},子阶段2{1},独立项目{1},删除项目{1}'); +$table->type->range('program{2},stage{6},project{2}'); +$table->parent->range('0{2},1{2},1{2},3{2},0{2}'); +$table->deleted->range('0{9},1{1}'); +$table->gen(10); + su('admin'); -zenData('project')->loadYaml('getsiblings')->gen(5); -$plan = new programplanTest(); +$programplan = new programplanTest(); -$topPlan = $plan->getSiblingsTest(2); -$topPlanCount = count($topPlan[2]); - -$leafPlan = $plan->getSiblingsTest(4); -$leafPlanCount = count($leafPlan[4]); - -r($topPlan[2][5]) && p('name') && e('阶段b'); // 测试id为2时获取兄弟阶段的的名称 -r($topPlanCount - 1) && p('') && e(1); // 测试id为2时获取自己兄弟阶段的个数 -r($leafPlanCount - 1) && p('') && e(0); // 测试id为4时获取自己兄弟阶段的个数 +r($programplan->getSiblingsTest(3)) && p('3') && e('4'); +r($programplan->getSiblingsTest([3, 4])) && p('3,4') && e('4,4'); +r($programplan->getSiblingsTest(999)) && p('999') && e('0'); +r($programplan->getSiblingsTest('4')) && p('4') && e('4'); +r($programplan->getSiblingsTest(9)) && p('9') && e('3'); +r($programplan->getSiblingsTest(1)) && p('1') && e('3'); +r($programplan->getSiblingsTest([7, 8])) && p('7,8') && e('2,2'); \ No newline at end of file diff --git a/module/programplan/test/model/yaml/project_getsiblings.yaml b/module/programplan/test/model/yaml/project_getsiblings.yaml new file mode 100644 index 0000000000..4683559b6c --- /dev/null +++ b/module/programplan/test/model/yaml/project_getsiblings.yaml @@ -0,0 +1,40 @@ +--- +title: 项目阶段兄弟关系测试数据 +desc: 用于测试programplanModel::getSiblings()方法的测试数据 +author: Claude +version: 1.0 + +fields: + - field: id + range: 1-10 + - field: project + range: 0{2},1{8} + - field: model + range: "scrum{5},waterfall{5}" + - field: name + note: "项目名称" + range: "项目集根{2},阶段a{2},阶段b{2},阶段c{2},子阶段1{1},子阶段2{1}" + - field: type + range: "program{2},stage{8}" + - field: status + range: "wait{3},doing{4},done{3}" + - field: parent + range: "0{2},1{2},2{2},1{2},3{1},4{1}" + - field: grade + range: "1{2},2{6},3{2}" + - field: path + range: ",1,{2},1,2,{2},1,5,{2},2,3,{2},3,9,{1},4,10,{1}" + - field: begin + range: "2024-01-01{5},2024-02-01{5}" + - field: end + range: "2024-12-31{5},2025-01-31{5}" + - field: openedBy + range: "admin{5},user{5}" + - field: openedDate + range: "2024-01-01 09:00:00{5},2024-01-02 09:00:00{5}" + - field: deleted + range: "0{9},1{1}" + - field: vision + range: "rnd{10}" + - field: multiple + range: "1{10}" \ No newline at end of file