* Refactor testcase::getProductBugPairs, and modify its unit test.
This commit is contained in:
@@ -1080,14 +1080,15 @@ class bugModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* get Product Bug Pairs
|
||||
* 获取产品的bug键对。
|
||||
* Get product bug pairs.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int|string $branch
|
||||
* @access public
|
||||
* @return void
|
||||
* @return array
|
||||
*/
|
||||
public function getProductBugPairs($productID, $branch = '')
|
||||
public function getProductBugPairs(int $productID, int|string $branch = ''): array
|
||||
{
|
||||
$bugs = array();
|
||||
$data = $this->dao->select('id, title')->from(TABLE_BUG)
|
||||
@@ -1097,10 +1098,7 @@ class bugModel extends model
|
||||
->andWhere('deleted')->eq(0)
|
||||
->orderBy('id desc')
|
||||
->fetchAll();
|
||||
foreach($data as $bug)
|
||||
{
|
||||
$bugs[$bug->id] = $bug->id . ':' . $bug->title;
|
||||
}
|
||||
foreach($data as $bug) $bugs[$bug->id] = $bug->id . ':' . $bug->title;
|
||||
return $bugs;
|
||||
}
|
||||
|
||||
|
||||
@@ -695,6 +695,7 @@ class bugTest
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试获取产品的bug键对。
|
||||
* Test get bug pairs of a product.
|
||||
*
|
||||
* @param int $productID
|
||||
@@ -702,14 +703,14 @@ class bugTest
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getProductBugPairsTest($productID, $branch = '')
|
||||
public function getProductBugPairsTest(int $productID, int|string $branch = ''): array|string
|
||||
{
|
||||
$array = $this->objectModel->getProductBugPairs($productID, $branch);
|
||||
|
||||
$title = '';
|
||||
foreach($array as $bug) $title .= ',' . $bug;
|
||||
$title = trim($title, ',');
|
||||
$title = str_replace("'", '', $title);
|
||||
$title = str_replace(array("'", '@', '$', '%'), '', $title);
|
||||
|
||||
if(dao::isError())
|
||||
{
|
||||
|
||||
@@ -3,21 +3,37 @@
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php'; su('admin');
|
||||
include dirname(__FILE__, 2) . '/bug.class.php';
|
||||
|
||||
zdTable('bug')->gen(140);
|
||||
|
||||
/**
|
||||
|
||||
title=bugModel->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
|
||||
测试获取productID为45,主干分支的bug >> 133:BUG133
|
||||
测试获取productID为45,分支为9的bug >> 134:BUG134
|
||||
- 测试获取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
|
||||
|
||||
- 测试获取productID为45,主干分支的bug @133:BUG133
|
||||
|
||||
- 测试获取productID为45,分支为9的bug @134:BUG134
|
||||
|
||||
*/
|
||||
|
||||
@@ -27,9 +43,9 @@ $branchIDList = array('9');
|
||||
$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[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[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
|
||||
r($bug->getProductBugPairsTest($productIDList[7], 0)) && p() && e('133:BUG133'); // 测试获取productID为45,主干分支的bug
|
||||
|
||||
Reference in New Issue
Block a user