From 7b0dd36f826f874bb3070f974b679f555e44dd1f Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 12 Jan 2023 10:06:45 +0800 Subject: [PATCH] * Add test case. --- module/execution/model.php | 2 + test/class/execution.class.php | 12 +++++ test/model/execution/getswitcher.php | 2 +- test/model/execution/syncnomultiplesprint.php | 51 +++++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 test/model/execution/syncnomultiplesprint.php diff --git a/module/execution/model.php b/module/execution/model.php index 9a3ac752f5..5f9a55b30a 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -5251,6 +5251,8 @@ class executionModel extends model public function syncNoMultipleSprint($projectID) { $project = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch(); + if(empty($project)) return 0; + $post = $_POST; $_POST = array(); diff --git a/test/class/execution.class.php b/test/class/execution.class.php index 6bb8e7798d..27b45ec6d6 100644 --- a/test/class/execution.class.php +++ b/test/class/execution.class.php @@ -2497,4 +2497,16 @@ class executionTest { return $this->objectModel->getSwitcher($executionID, 'execution', $method); } + + /** + * Test sync no multiple sprint. + * + * @param int $projectID + * @access public + * @return void + */ + public function syncNoMultipleSprintTest($projectID) + { + return $this->objectModel->syncNoMultipleSprint($projectID); + } } diff --git a/test/model/execution/getswitcher.php b/test/model/execution/getswitcher.php index dff19a0d8c..4053ac143f 100644 --- a/test/model/execution/getswitcher.php +++ b/test/model/execution/getswitcher.php @@ -17,7 +17,7 @@ $execution->gen(5); su('admin'); /** -title=测试 executionModel::saveState(); +title=测试 executionModel::getSwitcher(); cid=1 pid=1 diff --git a/test/model/execution/syncnomultiplesprint.php b/test/model/execution/syncnomultiplesprint.php new file mode 100644 index 0000000000..809567348e --- /dev/null +++ b/test/model/execution/syncnomultiplesprint.php @@ -0,0 +1,51 @@ +#!/usr/bin/env php +id->range('1-5'); +$execution->name->range('项目1,项目2,迭代1,迭代2,迭代3'); +$execution->type->range('project{2},sprint,stage,kanban'); +$execution->status->range('doing{3},closed,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->multiple->range("`0`"); +$execution->path->range('1,2,`1,3`,`1,4`,`2,5`')->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); + +$product = zdTable('product'); +$product->id->range('1-3'); +$product->name->range('1-3')->prefix('产品'); +$product->code->range('1-3')->prefix('product'); +$product->type->range('normal'); +$product->status->range('normal'); +$product->gen(3); + +$projectproduct = zdTable('projectproduct'); +$projectproduct->project->range('2-5'); +$projectproduct->product->range('1-3'); +$projectproduct->branch->range('1,0'); +$projectproduct->gen(5); + +su('admin'); + +/** + +title=测试executionModel->syncNoMultipleSprint(); +cid=1 +pid=1 + +同步没有执行的项目 >> 5 +同步错误的项目 >> 0 + +*/ + +$projectIDList = array('2', '15'); + +$execution = new executionTest(); +r($execution->syncNoMultipleSprintTest($projectIDList[0])) && p() && e('5'); // 同步没有执行的项目 +r($execution->syncNoMultipleSprintTest($projectIDList[1])) && p() && e('0'); // 同步错误的项目