diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index 8ee61ddc4d..c3a20e3d0f 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -3090,4 +3090,37 @@ class executionTest ->andWhere('count')->eq($count) ->fetch(); } + + /** + * 根据给定条件构建执行键值对。 + * Build execution id:name pairs through the conditions. + * + * @param int $projectID + * @param string $mode all|noclosed|stagefilter|withdelete|multiple|leaf|order_asc|noprefix|withobject|hideMultiple + * @access public + * @return array + */ + public function buildExecutionPairsTest(int $projectID, string $mode = ''): array + { + $executions = $this->executionModel->dao->select("*, IF(INSTR('done,closed', status) < 2, 0, 1) AS isDone, INSTR('doing,wait,suspended,closed', status) AS sortStatus")->from(TABLE_EXECUTION) + ->where('vision')->eq($this->executionModel->config->vision) + ->andWhere('type')->in('stage,sprint,kanban') + ->andWhere('project')->eq($projectID) + ->beginIF(strpos($mode, 'multiple') !== false)->andWhere('multiple')->eq('1')->fi() + ->beginIF(strpos($mode, 'withdelete') === false)->andWhere('deleted')->eq(0)->fi() + ->fetchAll('id'); + + $allExecutions = $this->executionModel->dao->select('id,name,parent,grade')->from(TABLE_EXECUTION) + ->where('type')->notin(array('program', 'project')) + ->andWhere('deleted')->eq('0') + ->andWhere('project')->eq($projectID) + ->fetchAll('id'); + + $parents = array(); + foreach($allExecutions as $exec) $parents[$exec->parent] = true; + + $projectPairs = strpos($mode, 'withobject') !== false ? $this->executionModel->dao->select('id,name')->from(TABLE_PROJECT)->fetchPairs('id') : array(); + + return $this->executionModel->buildExecutionPairs($mode, $allExecutions, $executions, $parents, $projectPairs); + } } diff --git a/module/execution/test/tao/buildexecutionpairs.php b/module/execution/test/tao/buildexecutionpairs.php new file mode 100644 index 0000000000..834e9eb373 --- /dev/null +++ b/module/execution/test/tao/buildexecutionpairs.php @@ -0,0 +1,54 @@ +#!/usr/bin/env php +gen(5); +su('admin'); + +zdTable('project')->config('execution')->gen(30); + +/** + +title=测试executionModel->buildExecutionPairs(); +timeout=0 +cid=1 + +*/ + +$projectIDList = array(11, 60, 100); +$modeList = array('', 'all', 'noclosed', 'stagefilter', 'withdelete', 'multiple', 'leaf', 'order_asc', 'noprefix', 'withobject', 'hideMultiple'); + +$executionTester = new executionTest(); +r($executionTester->buildExecutionPairsTest($projectIDList[0], $modeList[0])) && p('105') && e('敏捷项目1(不启用迭代的项目)'); // 敏捷项目执行查看 +r($executionTester->buildExecutionPairsTest($projectIDList[1], $modeList[0])) && p('109') && e('/阶段13'); // 瀑布项目执行查看 +r($executionTester->buildExecutionPairsTest($projectIDList[2], $modeList[0])) && p('126') && e('/看板30'); // 看板项目执行查看 +r($executionTester->buildExecutionPairsTest($projectIDList[0], $modeList[1])) && p('105') && e('敏捷项目1(不启用迭代的项目)'); // 敏捷项目查看所有执行 +r($executionTester->buildExecutionPairsTest($projectIDList[1], $modeList[1])) && p('109') && e('/阶段13'); // 瀑布项目查看所有执行 +r($executionTester->buildExecutionPairsTest($projectIDList[2], $modeList[1])) && p('126') && e('/看板30'); // 看板项目查看所有执行 +r($executionTester->buildExecutionPairsTest($projectIDList[0], $modeList[2])) && p('105') && e('敏捷项目1(不启用迭代的项目)'); // 敏捷项目查看未关闭执行 +r($executionTester->buildExecutionPairsTest($projectIDList[1], $modeList[2])) && p('109') && e('/阶段13'); // 瀑布项目查看未关闭执行 +r($executionTester->buildExecutionPairsTest($projectIDList[2], $modeList[2])) && p('126') && e('/看板30'); // 看板项目查看未关闭执行 +r($executionTester->buildExecutionPairsTest($projectIDList[0], $modeList[3])) && p('105') && e('敏捷项目1(不启用迭代的项目)'); // 敏捷项目查看非需求、设计、评审阶段的执行 +r($executionTester->buildExecutionPairsTest($projectIDList[1], $modeList[3])) && p('109') && e('/阶段13'); // 瀑布项目查看非需求、设计、评审阶段的执行 +r($executionTester->buildExecutionPairsTest($projectIDList[2], $modeList[3])) && p('126') && e('/看板30'); // 看板项目查看非需求、设计、评审阶段的执行 +r($executionTester->buildExecutionPairsTest($projectIDList[0], $modeList[4])) && p('105') && e('敏捷项目1(不启用迭代的项目)'); // 敏捷项目查看包括已删除的执行 +r($executionTester->buildExecutionPairsTest($projectIDList[1], $modeList[4])) && p('109') && e('/阶段13'); // 瀑布项目查看包括已删除的执行 +r($executionTester->buildExecutionPairsTest($projectIDList[2], $modeList[4])) && p('126') && e('/看板30'); // 看板项目查看包括已删除的执行 +r($executionTester->buildExecutionPairsTest($projectIDList[0], $modeList[5])) && p('103') && e('/迭代7'); // 敏捷项目查看包括非影子执行 +r($executionTester->buildExecutionPairsTest($projectIDList[1], $modeList[5])) && p('109') && e('/阶段13'); // 瀑布项目查看包括非影子执行 +r($executionTester->buildExecutionPairsTest($projectIDList[2], $modeList[5])) && p('126') && e('/看板30'); // 看板项目查看包括非影子执行 +r($executionTester->buildExecutionPairsTest($projectIDList[0], $modeList[6])) && p('105') && e('敏捷项目1(不启用迭代的项目)'); // 敏捷项目查看非父阶段执行 +r($executionTester->buildExecutionPairsTest($projectIDList[1], $modeList[6])) && p('112') && e('/阶段10/阶段16'); // 瀑布项目查看非父阶段执行 +r($executionTester->buildExecutionPairsTest($projectIDList[2], $modeList[6])) && p('126') && e('/看板30'); // 看板项目查看非父阶段执行 +r($executionTester->buildExecutionPairsTest($projectIDList[0], $modeList[7])) && p('105') && e('敏捷项目1(不启用迭代的项目)'); // 敏捷项目按照排序正序获取执行 +r($executionTester->buildExecutionPairsTest($projectIDList[1], $modeList[7])) && p('109') && e('/阶段13'); // 瀑布项目按照排序正序获取执行 +r($executionTester->buildExecutionPairsTest($projectIDList[2], $modeList[7])) && p('126') && e('/看板30'); // 看板项目按照排序正序获取执行 +r($executionTester->buildExecutionPairsTest($projectIDList[0], $modeList[8])) && p('105') && e('敏捷项目1(不启用迭代的项目)'); // 敏捷项目查看没有前缀/的执行 +r($executionTester->buildExecutionPairsTest($projectIDList[1], $modeList[8])) && p('109') && e('阶段13'); // 瀑布项目查看没有前缀/的执行 +r($executionTester->buildExecutionPairsTest($projectIDList[2], $modeList[8])) && p('126') && e('看板30'); // 看板项目查看没有前缀/的执行 +r($executionTester->buildExecutionPairsTest($projectIDList[0], $modeList[9])) && p('105') && e('敏捷项目1(不启用迭代的项目)'); // 敏捷项目获取带项目名称的执行 +r($executionTester->buildExecutionPairsTest($projectIDList[1], $modeList[9])) && p('109') && e('瀑布项目2/阶段13'); // 瀑布项目获取带项目名称的执行 +r($executionTester->buildExecutionPairsTest($projectIDList[2], $modeList[9])) && p('126') && e('看板项目4/看板30'); // 看板项目获取带项目名称的执行 +r($executionTester->buildExecutionPairsTest($projectIDList[0], $modeList[10])) && p('103') && e('/迭代7'); // 敏捷项目获取非影子执行 +r($executionTester->buildExecutionPairsTest($projectIDList[1], $modeList[10])) && p('109') && e('/阶段13'); // 瀑布项目获取非影子执行 +r($executionTester->buildExecutionPairsTest($projectIDList[2], $modeList[10])) && p('126') && e('/看板30'); // 看板项目获取非影子执行