From 441200128a7cbb576540bdd34390a8e0baa45fbe Mon Sep 17 00:00:00 2001 From: liumengyi Date: Mon, 21 Mar 2022 14:29:19 +0800 Subject: [PATCH] * Add auto test of bug. --- module/execution/model.php | 1 - test/class/bug.class.php | 155 +++++++++++++++++++++++ test/model/bug/getexecutionbugs.php | 33 +++++ test/model/bug/getproductbugpairs.php | 32 +++++ test/model/bug/getproductleftbugs.php | 35 +++++ test/model/bug/getproductmemberpairs.php | 33 +++++ test/model/bug/getprojectbugs.php | 33 +++++ test/model/bug/getreleasebugs.php | 31 +++++ 8 files changed, 352 insertions(+), 1 deletion(-) create mode 100755 test/model/bug/getexecutionbugs.php create mode 100755 test/model/bug/getproductbugpairs.php create mode 100755 test/model/bug/getproductleftbugs.php create mode 100755 test/model/bug/getproductmemberpairs.php create mode 100755 test/model/bug/getprojectbugs.php create mode 100755 test/model/bug/getreleasebugs.php diff --git a/module/execution/model.php b/module/execution/model.php index 3c6ad82e4d..216204f54b 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -3056,7 +3056,6 @@ class executionModel extends model if($action == 'suspend') return $execution->status == 'wait' or $execution->status == 'doing'; if($action == 'putoff') return $execution->status == 'wait' or $execution->status == 'doing'; if($action == 'activate') return $execution->status == 'suspended' or $execution->status == 'closed'; - if($action == 'delete') return $execution->status == 'wait' or $execution->status == 'doing'; return true; } diff --git a/test/class/bug.class.php b/test/class/bug.class.php index c0b8e06d5d..4fec212792 100644 --- a/test/class/bug.class.php +++ b/test/class/bug.class.php @@ -1290,4 +1290,159 @@ class bugTest return count($array); } } + + /** + * Test get bugs of a project. + * + * @param int $projectID + * @access public + * @return array + */ + public function getProjectBugsTest($projectID) + { + $array = $this->objectModel->getProjectBugs($projectID); + + foreach($array as $bug) $bug->title = str_replace("'", '', $bug->title); + + if(dao::isError()) + { + return dao::getError(); + } + else + { + return $array; + } + } + + /** + * Test get bugs of a execution. + * + * @param int $executionID + * @access public + * @return string + */ + public function getExecutionBugsTest($executionID) + { + $array = $this->objectModel->getExecutionBugs($executionID); + + $title = ''; + foreach($array as $bug) $title .= ',' . $bug->title; + $title = trim($title, ','); + $title = str_replace("'", '', $title); + + if(dao::isError()) + { + return dao::getError(); + } + else + { + return $title; + } + } + + /** + * Test get product left bugs. + * + * @param int $buildID + * @param int $productID + * @access public + * @return array + */ + public function getProductLeftBugsTest($buildID, $productID) + { + $array = $this->objectModel->getProductLeftBugs($buildID, $productID); + + $title = ''; + foreach($array as $bug) $title .= ',' . $bug->title; + $title = trim($title, ','); + $title = str_replace("'", '', $title); + + if(dao::isError()) + { + return dao::getError(); + } + else + { + return $title; + } + } + + /** + * Test get bug pairs of a product. + * + * @param int $productID + * @access public + * @return array + */ + public function getProductBugPairsTest($productID) + { + $array = $this->objectModel->getProductBugPairs($productID); + + $title = ''; + foreach($array as $bug) $title .= ',' . $bug; + $title = trim($title, ','); + $title = str_replace("'", '', $title); + + if(dao::isError()) + { + return dao::getError(); + } + else + { + return $title; + } + } + + /** + * Test get bug member of a product. + * + * @param int $productID + * @access public + * @return array + */ + public function getProductMemberPairsTest($productID) + { + $array = $this->objectModel->getProductMemberPairs($productID); + + $title = ''; + foreach($array as $bug) $title .= ',' . $bug; + $title = trim($title, ','); + $title = str_replace("'", '', $title); + + if(dao::isError()) + { + return dao::getError(); + } + else + { + return $title; + } + } + + /** + * Test get bugs according to buildID and productID. + * + * @param int $buildID + * @param int $productID + * @access public + * @return array + */ + public function getReleaseBugsTest($buildID, $productID) + { + $array = $this->objectModel->getReleaseBugs($buildID, $productID); + + $title = ''; + foreach($array as $bug) $title .= ',' . $bug->title; + $title = trim($title, ','); + $title = str_replace("'", '', $title); + + if(dao::isError()) + { + return dao::getError(); + } + else + { + return $title; + } + } } diff --git a/test/model/bug/getexecutionbugs.php b/test/model/bug/getexecutionbugs.php new file mode 100755 index 0000000000..5147c28e72 --- /dev/null +++ b/test/model/bug/getexecutionbugs.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +getExecutionBugs(); +cid=1 +pid=1 + +测试获取执行ID为101的bug >> BUG3,BUG2,BUG1 +测试获取执行ID为102的bug >> BUG6,BUG5,BUG4 +测试获取执行ID为103的bug >> BUG9,bug8,缺陷!@()(){}|+=%^&*$#测试bug名称到底可以有多长!@#¥%&*":.<>。?/();7 +测试获取执行ID为104的bug >> BUG12,BUG11,BUG10 +测试获取执行ID为105的bug >> 缺陷!@()(){}|+=%^&*$#测试bug名称到底可以有多长!@#¥%&*":.<>。?/();15,BUG14,BUG13 +测试获取执行ID为106的bug >> BUG18,BUG17,bug16 +测试获取不存在的执行的bug >> 0 + + +*/ + + +$executionIDList = array('101', '102', '103', '104', '105', '106', '1000001'); + +$bug=new bugTest(); +r($bug->getExecutionBugsTest($executionIDList[0])) && p() && e('BUG3,BUG2,BUG1'); // 测试获取执行ID为101的bug +r($bug->getExecutionBugsTest($executionIDList[1])) && p() && e('BUG6,BUG5,BUG4'); // 测试获取执行ID为102的bug +r($bug->getExecutionBugsTest($executionIDList[2])) && p() && e('BUG9,bug8,缺陷!@()(){}|+=%^&*$#测试bug名称到底可以有多长!@#¥%&*":.<>。?/();7'); // 测试获取执行ID为103的bug +r($bug->getExecutionBugsTest($executionIDList[3])) && p() && e('BUG12,BUG11,BUG10'); // 测试获取执行ID为104的bug +r($bug->getExecutionBugsTest($executionIDList[4])) && p() && e('缺陷!@()(){}|+=%^&*$#测试bug名称到底可以有多长!@#¥%&*":.<>。?/();15,BUG14,BUG13'); // 测试获取执行ID为105的bug +r($bug->getExecutionBugsTest($executionIDList[5])) && p() && e('BUG18,BUG17,bug16'); // 测试获取执行ID为106的bug +r($bug->getExecutionBugsTest($executionIDList[6])) && p() && e('0'); // 测试获取不存在的执行的bug diff --git a/test/model/bug/getproductbugpairs.php b/test/model/bug/getproductbugpairs.php new file mode 100755 index 0000000000..c5231c70dc --- /dev/null +++ b/test/model/bug/getproductbugpairs.php @@ -0,0 +1,32 @@ +#!/usr/bin/env php +getProductBugPairs(); +cid=1 +pid=1 + +测试获取productID为1的bug >> 3:BUG3,2:BUG2,1:BUG1 +测试获取productID为2的bug >> 6:BUG6,5:BUG5,4:BUG4 +测试获取productID为3的bug >> 9:BUG9,8:bug8,7:缺陷!@()(){}|+=%^&*$#测试bug名称到底可以有多长!@#¥%&*":.<>。?/();7 +测试获取productID为4的bug >> 12:BUG12,11:BUG11,10:BUG10 +测试获取productID为5的bug >> 15:缺陷!@()(){}|+=%^&*$#测试bug名称到底可以有多长!@#¥%&*":.<>。?/();15,14:BUG14,13:BUG13 +测试获取productID为6的bug >> 18:BUG18,17:BUG17,16:bug16 +测试获取不存在的product的bug >> 0 + +*/ + + +$productIDList = array('1', '2', '3', '4','5', '6', '1000001'); + +$bug=new bugTest(); +r($bug->getProductBugPairsTest($productIDList[0])) && p() && e('3:BUG3,2:BUG2,1:BUG1'); // 测试获取productID为1的bug +r($bug->getProductBugPairsTest($productIDList[1])) && p() && e('6:BUG6,5:BUG5,4:BUG4'); // 测试获取productID为2的bug +r($bug->getProductBugPairsTest($productIDList[2])) && p() && e('9:BUG9,8:bug8,7:缺陷!@()(){}|+=%^&*$#测试bug名称到底可以有多长!@#¥%&*":.<>。?/();7'); // 测试获取productID为3的bug +r($bug->getProductBugPairsTest($productIDList[3])) && p() && e('12:BUG12,11:BUG11,10:BUG10'); // 测试获取productID为4的bug +r($bug->getProductBugPairsTest($productIDList[4])) && p() && e('15:缺陷!@()(){}|+=%^&*$#测试bug名称到底可以有多长!@#¥%&*":.<>。?/();15,14:BUG14,13:BUG13'); // 测试获取productID为5的bug +r($bug->getProductBugPairsTest($productIDList[5])) && p() && e('18:BUG18,17:BUG17,16:bug16'); // 测试获取productID为6的bug +r($bug->getProductBugPairsTest($productIDList[6])) && p() && e('0'); // 测试获取不存在的product的bug diff --git a/test/model/bug/getproductleftbugs.php b/test/model/bug/getproductleftbugs.php new file mode 100755 index 0000000000..3aad98a71b --- /dev/null +++ b/test/model/bug/getproductleftbugs.php @@ -0,0 +1,35 @@ +#!/usr/bin/env php +getProductLeftBugs(); +cid=1 +pid=1 + +测试获取buildID为11 productID为1的bug >> 0 +测试获取buildID为12 productID为41的bug >> 0 +测试获取buildID为13 productID为1的bug >> BUG1,BUG2,BUG3 +测试获取buildID为14 productID为41的bug >> BUG121,BUG122,BUG123 +测试获取buildID为15 productID为1的bug >> BUG1,BUG2,BUG3 +测试获取buildID为16 productID为1的bug >> BUG1,BUG2,BUG3 +测试获取不存在的build的bug >> 0 +测试获取不存在的product的bug >> 0 + +*/ + + +$buildIDList = array('1', '2', '3', '4', '5', '6', '1000001'); +$productIDList = array('1', '41', '1000001'); + +$bug=new bugTest(); +r($bug->getProductLeftBugsTest($buildIDList[0], $productIDList[0])) && p() && e('0'); // 测试获取buildID为11 productID为1的bug +r($bug->getProductLeftBugsTest($buildIDList[1], $productIDList[1])) && p() && e('0'); // 测试获取buildID为12 productID为41的bug +r($bug->getProductLeftBugsTest($buildIDList[2], $productIDList[0])) && p() && e('BUG1,BUG2,BUG3'); // 测试获取buildID为13 productID为1的bug +r($bug->getProductLeftBugsTest($buildIDList[3], $productIDList[1])) && p() && e('BUG121,BUG122,BUG123'); // 测试获取buildID为14 productID为41的bug +r($bug->getProductLeftBugsTest($buildIDList[4], $productIDList[0])) && p() && e('BUG1,BUG2,BUG3'); // 测试获取buildID为15 productID为1的bug +r($bug->getProductLeftBugsTest($buildIDList[5], $productIDList[0])) && p() && e('BUG1,BUG2,BUG3'); // 测试获取buildID为16 productID为1的bug +r($bug->getProductLeftBugsTest($buildIDList[6], $productIDList[0])) && p() && e('0'); // 测试获取不存在的build的bug +r($bug->getProductLeftBugsTest($buildIDList[0], $productIDList[2])) && p() && e('0'); // 测试获取不存在的product的bug diff --git a/test/model/bug/getproductmemberpairs.php b/test/model/bug/getproductmemberpairs.php new file mode 100755 index 0000000000..ef67526ee9 --- /dev/null +++ b/test/model/bug/getproductmemberpairs.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +getProductMemberPairs(); +cid=1 +pid=1 + +测试获取productID为1的bug的团队成员 >> A:admin,P:产品经理92,P:产品经理2,U:测试12 +测试获取productID为2的bug的团队成员 >> P:产品经理93,U:测试3,P:研发主管3,U:测试13 +测试获取productID为3的bug的团队成员 >> P:产品经理94,U:测试4,P:研发主管4,U:测试14 +测试获取productID为4的bug的团队成员 >> P:产品经理95,U:测试5,P:研发主管5,U:测试15 +测试获取productID为5的bug的团队成员 >> P:产品经理96,U:测试6,P:研发主管6,U:测试16 +测试获取productID为6的bug的团队成员 >> P:产品经理97,U:测试7,P:研发主管7,U:测试17 +测试获取不存在的product的bug的团队成员 >> 0 + + +*/ + + +$productIDList = array('1', '2', '3', '4','5', '6', '1000001'); + +$bug=new bugTest(); +r($bug->getProductMemberPairsTest($productIDList[0])) && p() && e('A:admin,P:产品经理92,P:产品经理2,U:测试12'); // 测试获取productID为1的bug的团队成员 +r($bug->getProductMemberPairsTest($productIDList[1])) && p() && e('P:产品经理93,U:测试3,P:研发主管3,U:测试13'); // 测试获取productID为2的bug的团队成员 +r($bug->getProductMemberPairsTest($productIDList[2])) && p() && e('P:产品经理94,U:测试4,P:研发主管4,U:测试14'); // 测试获取productID为3的bug的团队成员 +r($bug->getProductMemberPairsTest($productIDList[3])) && p() && e('P:产品经理95,U:测试5,P:研发主管5,U:测试15'); // 测试获取productID为4的bug的团队成员 +r($bug->getProductMemberPairsTest($productIDList[4])) && p() && e('P:产品经理96,U:测试6,P:研发主管6,U:测试16'); // 测试获取productID为5的bug的团队成员 +r($bug->getProductMemberPairsTest($productIDList[5])) && p() && e('P:产品经理97,U:测试7,P:研发主管7,U:测试17'); // 测试获取productID为6的bug的团队成员 +r($bug->getProductMemberPairsTest($productIDList[6])) && p() && e('0'); // 测试获取不存在的product的bug的团队成员 diff --git a/test/model/bug/getprojectbugs.php b/test/model/bug/getprojectbugs.php new file mode 100755 index 0000000000..a62cca874b --- /dev/null +++ b/test/model/bug/getprojectbugs.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +getProjectBugs(); +cid=1 +pid=1 + +测试获取项目ID为11的bug >> BUG3;BUG2;BUG1 +测试获取项目ID为12的bug >> BUG6;BUG5;BUG4 +测试获取项目ID为13的bug >> BUG9;bug8;缺陷!@()(){}|+=%^&*$#测试bug名称到底可以有多长!@#¥%&*":.<>。?/();7 +测试获取项目ID为14的bug >> BUG12;BUG11;BUG10 +测试获取项目ID为15的bug >> 缺陷!@()(){}|+=%^&*$#测试bug名称到底可以有多长!@#¥%&*":.<>。?/();15;BUG14;BUG13 +测试获取项目ID为16的bug >> BUG18;BUG17;bug16 +测试获取不存在的项目的bug >> 0 + + +*/ + + +$projectIDList = array('11', '12', '13', '14', '15', '16', '1000001'); + +$bug=new bugTest(); +r($bug->getProjectBugsTest($projectIDList[0])) && p('0:title;1:title;2:title') && e('BUG3;BUG2;BUG1'); // 测试获取项目ID为11的bug +r($bug->getProjectBugsTest($projectIDList[1])) && p('0:title;1:title;2:title') && e('BUG6;BUG5;BUG4'); // 测试获取项目ID为12的bug +r($bug->getProjectBugsTest($projectIDList[2])) && p('0:title;1:title;2:title') && e('BUG9;bug8;缺陷!@()(){}|+=%^&*$#测试bug名称到底可以有多长!@#¥%&*":.<>。?/();7'); // 测试获取项目ID为13的bug +r($bug->getProjectBugsTest($projectIDList[3])) && p('0:title;1:title;2:title') && e('BUG12;BUG11;BUG10'); // 测试获取项目ID为14的bug +r($bug->getProjectBugsTest($projectIDList[4])) && p('0:title;1:title;2:title') && e('缺陷!@()(){}|+=%^&*$#测试bug名称到底可以有多长!@#¥%&*":.<>。?/();15;BUG14;BUG13'); // 测试获取项目ID为15的bug +r($bug->getProjectBugsTest($projectIDList[5])) && p('0:title;1:title;2:title') && e('BUG18;BUG17;bug16'); // 测试获取项目ID为16的bug +r($bug->getProjectBugsTest($projectIDList[6])) && p('0:title;1:title;2:title') && e('0'); // 测试获取不存在的项目的bug diff --git a/test/model/bug/getreleasebugs.php b/test/model/bug/getreleasebugs.php new file mode 100755 index 0000000000..22f68e339f --- /dev/null +++ b/test/model/bug/getreleasebugs.php @@ -0,0 +1,31 @@ +#!/usr/bin/env php +getReleaseBugs(); +cid=1 +pid=1 + +测试获取buildID为11 productID为1的bug >> BUG1,BUG2,BUG3 +测试获取buildID为12 productID为41的bug >> 0 +测试获取buildID为13 productID为1的bug >> BUG1,BUG2,BUG3 +测试获取buildID为14 productID为41的bug >> BUG121,BUG122,BUG123 +测试获取buildID为15 productID为1的bug >> BUG1,BUG2,BUG3 +测试获取buildID为16 productID为1的bug >> BUG1,BUG2,BUG3 + +*/ + + +$buildIDList = array('1', '2', '3', '4', '5', '6', '1000001'); +$productIDList = array('1', '41'); + +$bug=new bugTest(); +r($bug->getReleaseBugsTest($buildIDList[0], $productIDList[0])) && p('') && e('BUG1,BUG2,BUG3'); // 测试获取buildID为11 productID为1的bug +r($bug->getReleaseBugsTest($buildIDList[1], $productIDList[1])) && p('') && e('0'); // 测试获取buildID为12 productID为41的bug +r($bug->getReleaseBugsTest($buildIDList[2], $productIDList[0])) && p('') && e('BUG121,BUG122,BUG123'); // 测试获取buildID为13 productID为1的bug +r($bug->getReleaseBugsTest($buildIDList[3], $productIDList[1])) && p('') && e('BUG1,BUG2,BUG3'); // 测试获取buildID为14 productID为41的bug +r($bug->getReleaseBugsTest($buildIDList[4], $productIDList[0])) && p('') && e('BUG1,BUG2,BUG3'); // 测试获取buildID为15 productID为1的bug +r($bug->getReleaseBugsTest($buildIDList[5], $productIDList[0])) && p('') && e('BUG1,BUG2,BUG3'); // 测试获取buildID为16 productID为1的bug