From 97506ed3c1dcf0fe906af23c49bc64e8b7aaa05a Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Sun, 29 Jan 2023 11:27:22 +0800 Subject: [PATCH] * Add test case. --- module/execution/model.php | 2 +- test/class/execution.class.php | 16 ++-- test/model/execution/buildstorysearchform.php | 96 +++++++++++++++++++ test/model/execution/filltasksintree.php | 4 +- 4 files changed, 108 insertions(+), 10 deletions(-) create mode 100644 test/model/execution/buildstorysearchform.php diff --git a/module/execution/model.php b/module/execution/model.php index e8da15ea9c..c161bbccf7 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -2283,7 +2283,7 @@ class executionModel extends model $productType = 'normal'; $productNum = count($products); $productPairs = array(0 => ''); - $branches = $this->loadModel('project')->getBranchesByProject($execution->id); + $branches = empty($execution) ? array() : $this->loadModel('project')->getBranchesByProject($execution->id); foreach($products as $product) { diff --git a/test/class/execution.class.php b/test/class/execution.class.php index 786e08f74e..dae6fb05bd 100644 --- a/test/class/execution.class.php +++ b/test/class/execution.class.php @@ -2739,19 +2739,21 @@ class executionTest /** * Test build story search form. * - * @param int $productID + * @param int $executionID * @param int $queryID * @access public * @return void */ - public function buildStorySearchFormTest($productID, $queryID) + public function buildStorySearchFormTest($executionID, $queryID) { - $product = $this->productModel->getByID($productID); - if(empty($product)) return '0'; + $execution = $this->executionModel->getByID($executionID); + if(empty($execution)) return '0'; - $this->executionModel->loadModel('bug'); - $this->executionModel->buildStorySearchForm(array($productID => $product), $queryID, 'searchBug'); + $this->executionModel->loadModel('story'); + $products = $this->productModel->getProducts($executionID); + $branchGroups = $this->executionModel->loadModel('branch')->getByProducts(array_keys($products)); + $this->executionModel->buildStorySearchForm($products, $branchGroups, array(), $queryID, 'searchStory', 'executionStory', $execution); - return $_SESSION['executionBugsearchParams']['queryID']; + return $_SESSION['executionStorysearchParams']['queryID']; } } diff --git a/test/model/execution/buildstorysearchform.php b/test/model/execution/buildstorysearchform.php new file mode 100644 index 0000000000..f8d2f10de2 --- /dev/null +++ b/test/model/execution/buildstorysearchform.php @@ -0,0 +1,96 @@ +#!/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'); +$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->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); + +$task = zdTable('task'); +$task->id->range('1-10'); +$task->execution->range('3'); +$task->name->range('1-10')->prefix('任务'); +$task->type->range('design,devel,test,study,discuss,ui,affair,misc'); +$task->status->range('wait,doing,done,closed'); +$task->gen(10); + +$product = zdTable('product'); +$product->id->range('1-2'); +$product->name->range('正常产品1,多分支产品1'); +$product->type->range('normal,branch'); +$product->status->range('normal'); +$product->createdBy->range('admin,user1'); +$product->gen(2); + +$branch = zdTable('branch'); +$branch->id->range('1-2'); +$branch->product->range('2'); +$branch->name->range('分支1,分支2'); +$branch->status->range('active'); +$branch->gen(2); + +$story = zdTable('story'); +$story->id->range('1-10'); +$story->name->range('1-10')->prefix('需求'); +$story->type->range('story'); +$story->product->range('1'); +$story->status->range('active'); +$story->staged->range('projected'); +$story->version->range('1'); +$story->gen(10); + +$projectStory = zdTable('projectstory'); +$projectStory->project->range('3'); +$projectStory->product->range('1,2'); +$projectStory->story->range('1-10'); +$projectStory->version->range('1'); +$projectStory->gen(10); + +$projectproduct = zdTable('projectproduct'); +$projectproduct->project->range('1-5'); +$projectproduct->product->range('1-2'); +$projectproduct->plan->range('0'); +$projectproduct->gen(5); + +$query = zdTable('userquery'); +$query->id->range('1'); +$query->account->range('admin'); +$query->module->range('story'); +$query->title->range('搜索条件1'); +$query->form->range('`a:59:{s:9:"fieldname";s:0:"";s:11:"fieldstatus";s:0:"";s:9:"fielddesc";s:0:"";s:15:"fieldassignedTo";s:0:"";s:8:"fieldpri";s:1:"0";s:14:"fieldexecution";s:0:"";s:11:"fieldmodule";s:4:"ZERO";s:13:"fieldestimate";s:0:"";s:9:"fieldleft";s:0:"";s:13:"fieldconsumed";s:0:"";s:9:"fieldtype";s:0:"";s:12:"fieldfromBug";s:0:"";s:17:"fieldclosedReason";s:0:"";s:13:"fieldopenedBy";s:0:"";s:15:"fieldfinishedBy";s:0:"";s:13:"fieldclosedBy";s:0:"";s:15:"fieldcanceledBy";s:0:"";s:17:"fieldlastEditedBy";s:0:"";s:11:"fieldmailto";s:0:"";s:15:"fieldopenedDate";s:0:"";s:13:"fielddeadline";s:0:"";s:15:"fieldestStarted";s:0:"";s:16:"fieldrealStarted";s:0:"";s:17:"fieldassignedDate";s:0:"";s:17:"fieldfinishedDate";s:0:"";s:15:"fieldclosedDate";s:0:"";s:17:"fieldcanceledDate";s:0:"";s:19:"fieldlastEditedDate";s:0:"";s:18:"fieldactivatedDate";s:0:"";s:7:"fieldid";s:0:"";s:6:"andOr1";s:3:"AND";s:6:"field1";s:4:"name";s:9:"operator1";s:7:"include";s:6:"value1";s:2:"需求";s:6:"andOr2";s:3:"and";s:6:"field2";s:2:"id";s:9:"operator2";s:1:"=";s:6:"value2";s:0:"";s:6:"andOr3";s:3:"and";s:6:"field3";s:6:"status";s:9:"operator3";s:1:"=";s:6:"value3";s:0:"";s:10:"groupAndOr";s:3:"and";s:6:"andOr4";s:3:"AND";s:6:"field4";s:4:"desc";s:9:"operator4";s:7:"include";s:6:"value4";s:0:"";s:6:"andOr5";s:3:"and";s:6:"field5";s:10:"assignedTo";s:9:"operator5";s:1:"=";s:6:"value5";s:0:"";s:6:"andOr6";s:3:"and";s:6:"field6";s:3:"pri";s:9:"operator6";s:1:"=";s:6:"value6";s:1:"0";s:6:"module";s:4:"task";s:9:"actionURL";s:41:"/execution-task-3-bySearch-myQueryID.html";s:10:"groupItems";s:1:"3";s:8:"formType";s:4:"lite";}`'); +$query->sql->range("`(( 1 AND `name` LIKE '%需求%' ) AND ( 1 )) AND deleted = '0'`"); +$query->gen(1); + +su('admin'); + +/** + +title=测试executionModel->buildStorySearchForm(); +cid=1 +pid=1 + +正确的执行,正确的queryID >> 1 +错误的执行,正确的queryID >> 0 +正确的执行,错误的queryID >> 0 +错误的执行,错误的queryID >> 0 + +*/ + +$executionIDList = array('3', '0'); +$queryIDList = array('0', '1'); + +$execution = new executionTest(); +r($execution->buildStorySearchFormTest($executionIDList[0], $queryIDList[1])) && p() && e('1'); // 正确的执行,正确的queryID +r($execution->buildStorySearchFormTest($executionIDList[1], $queryIDList[1])) && p() && e('0'); // 错误的执行,正确的queryID +r($execution->buildStorySearchFormTest($executionIDList[0], $queryIDList[0])) && p() && e('0'); // 正确的执行,错误的queryID +r($execution->buildStorySearchFormTest($executionIDList[1], $queryIDList[0])) && p() && e('0'); // 错误的执行,错误的queryID diff --git a/test/model/execution/filltasksintree.php b/test/model/execution/filltasksintree.php index cb6c9cd30f..ac095b2894 100644 --- a/test/model/execution/filltasksintree.php +++ b/test/model/execution/filltasksintree.php @@ -54,7 +54,7 @@ cid=1 pid=1 敏捷执行查询 >> 产品1 -瀑布执行查询 >> 产品1 +瀑布执行查询 >> 产品2 看板执行查询 >> 产品1 错误执行查询 >> 0 @@ -64,6 +64,6 @@ $executionIDList = array('0', '3', '4', '5'); $execution = new executionTest(); r($execution->fillTasksInTreeTest($executionIDList[1])) && p('name') && e('产品1'); // 敏捷执行查询 -r($execution->fillTasksInTreeTest($executionIDList[2])) && p('name') && e('产品1'); // 瀑布执行查询 +r($execution->fillTasksInTreeTest($executionIDList[2])) && p('name') && e('产品2'); // 瀑布执行查询 r($execution->fillTasksInTreeTest($executionIDList[3])) && p('name') && e('产品1'); // 看板执行查询 r($execution->fillTasksInTreeTest($executionIDList[0])) && p() && e('0'); // 错误执行查询