diff --git a/module/execution/test/model/fetchexecutionsbyprojectidlist.php b/module/execution/test/model/fetchexecutionsbyprojectidlist.php old mode 100644 new mode 100755 index 6ca4f676c3..1f63b88972 --- a/module/execution/test/model/fetchexecutionsbyprojectidlist.php +++ b/module/execution/test/model/fetchexecutionsbyprojectidlist.php @@ -4,36 +4,56 @@ /** title=测试 executionModel::fetchExecutionsByProjectIdList(); +timeout=0 cid=0 -- 不传入数据。 @1 -- 传入不存在的项目ID。 @1 -- 检查有关联执行项目的执行数。 @2 -- 检查没有关联执行项目,是否在数据中存在。 @1 +- 测试步骤1:传入空数组参数 @0 +- 测试步骤2:传入不存在的项目ID @0 +- 测试步骤3:传入单个存在的项目ID @1 +- 测试步骤3:验证返回的执行数量 @4 +- 测试步骤4:传入多个项目ID(包含存在和不存在的) @3 +- 测试步骤4:验证按项目分组 @1 +- 测试步骤5:验证返回数据结构 @1 +- 测试步骤6:测试type过滤条件 @1 +- 测试步骤7:测试multiple和deleted过滤 @1 */ include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/execution.unittest.class.php'; $execution = zenData('project'); -$execution->id->range('1-5'); -$execution->name->range('项目1,项目2,迭代1,迭代2,迭代3'); -$execution->type->range('project{2},sprint,stage,kanban'); -$execution->status->range('doing'); -$execution->parent->range('0,0,1,1,2'); -$execution->project->range('0,0,1,1,2'); -$execution->grade->range('2{2},1{3}'); -$execution->path->range('1,2,`1,3`,`1,4`,`2,5`')->prefix(',')->postfix(','); +$execution->id->range('1-10'); +$execution->name->range('项目1,项目2,迭代1,迭代2,迭代3,阶段1,看板1,迭代4,已删除执行,多重执行'); +$execution->type->range('project{2},sprint{3},stage{2},kanban{2},sprint'); +$execution->status->range('doing{8},closed,suspended'); +$execution->parent->range('0,0,1,1,2,1,2,3,1,2'); +$execution->project->range('0,0,1,1,2,1,2,3,1,2'); +$execution->grade->range('2{2},1{8}'); +$execution->path->range('1,2,`1,3`,`1,4`,`2,5`,`1,6`,`2,7`,`3,8`,`1,9`,`2,10`')->prefix(',')->postfix(','); $execution->begin->range('20230102 000000:0')->type('timestamp')->format('YY/MM/DD'); $execution->end->range('20230212 000000:0')->type('timestamp')->format('YY/MM/DD'); -$execution->gen(5); +$execution->deleted->range('0{9},1'); +$execution->vision->range('rnd{10}'); +$execution->multiple->range('1{10}'); +$execution->gen(10); -global $tester; -$executionModel = $tester->loadModel('execution'); -$executionModel->app->user->admin = true; +su('admin'); -r(empty($executionModel->fetchExecutionsByProjectIdList(array()))) && p() && e('1'); //不传入数据。 -r(empty($executionModel->fetchExecutionsByProjectIdList(array(100)))) && p() && e('1'); //传入不存在的项目ID。 +$executionTest = new executionTest(); -$executionGroup = $executionModel->fetchExecutionsByProjectIdList(array(1, 100)); -r(count($executionGroup[1])) && p() && e('2'); //检查有关联执行项目的执行数。 -r(empty($executionGroup[100])) && p() && e('1'); //检查没有关联执行项目,是否在数据中存在。 +r(count($executionTest->fetchExecutionsByProjectIdListTest(array()))) && p() && e('0'); // 测试步骤1:传入空数组参数 +r(count($executionTest->fetchExecutionsByProjectIdListTest(array(999)))) && p() && e('0'); // 测试步骤2:传入不存在的项目ID + +$singleResult = $executionTest->fetchExecutionsByProjectIdListTest(array(1)); +r(count($singleResult)) && p() && e('1'); // 测试步骤3:传入单个存在的项目ID +r(count($singleResult[1])) && p() && e('4'); // 测试步骤3:验证返回的执行数量 + +$multiResult = $executionTest->fetchExecutionsByProjectIdListTest(array(1, 2, 3, 999)); +r(count($multiResult)) && p() && e('3'); // 测试步骤4:传入多个项目ID(包含存在和不存在的) +r(isset($multiResult[1]) && isset($multiResult[2]) && isset($multiResult[3]) && !isset($multiResult[999])) && p() && e('1'); // 测试步骤4:验证按项目分组 + +$detailResult = $executionTest->fetchExecutionsByProjectIdListTest(array(1)); +$execution = current($detailResult[1]); +r(isset($execution->id) && isset($execution->name) && isset($execution->projectName) && isset($execution->projectModel)) && p() && e('1'); // 测试步骤5:验证返回数据结构 +r(in_array($execution->type, array('sprint', 'stage', 'kanban'))) && p() && e('1'); // 测试步骤6:测试type过滤条件 +r($execution->multiple == '1' && $execution->deleted == '0') && p() && e('1'); // 测试步骤7:测试multiple和deleted过滤 \ No newline at end of file