* Refactor bugModel-getReleaseBugs, and modify its unit test.
This commit is contained in:
@@ -1159,17 +1159,18 @@ class bugModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过版本 id 和产品 id 获取 bugs。
|
||||
* Get bugs according to buildID and productID.
|
||||
*
|
||||
* @param int|string $buildIdList
|
||||
* @param int $productID
|
||||
* @param string $branch
|
||||
* @param string $linkedBugs
|
||||
* @param object $pager
|
||||
* @param array $buildIdList
|
||||
* @param int $productID
|
||||
* @param string $branch
|
||||
* @param string $linkedBugs
|
||||
* @param object $pager
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getReleaseBugs($buildIdList, $productID, $branch = 0, $linkedBugs = '', $pager = null)
|
||||
public function getReleaseBugs(array $buildIdList, int $productID, int $branch = 0, string $linkedBugs = '', object $pager = null): array
|
||||
{
|
||||
$executionIdList = $this->getLinkedExecutionByIdList($buildIdList);
|
||||
if(empty($executionIdList)) return array();
|
||||
@@ -1184,8 +1185,8 @@ class bugModel extends model
|
||||
}
|
||||
|
||||
return $this->dao->select('*')->from(TABLE_BUG)
|
||||
->where('resolvedDate')->ge($minBegin)
|
||||
->andWhere('resolution')->ne('postponed')
|
||||
->where('resolution')->ne('postponed')
|
||||
->beginIF(!empty($minBegin))->andWhere('resolvedDate')->ge($minBegin)->fi()
|
||||
->andWhere('product')->eq($productID)
|
||||
->beginIF($linkedBugs)->andWhere('id')->notIN($linkedBugs)->fi()
|
||||
->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi()
|
||||
|
||||
@@ -745,16 +745,17 @@ class bugTest
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试通过版本 id 和产品 id 获取 bugs。
|
||||
* Test get bugs according to buildID and productID.
|
||||
*
|
||||
* @param int $buildID
|
||||
* @param int $productID
|
||||
* @access public
|
||||
* @return string
|
||||
* @return string|array
|
||||
*/
|
||||
public function getReleaseBugsTest($buildID, $productID)
|
||||
public function getReleaseBugsTest(int $buildID, int $productID): string|array
|
||||
{
|
||||
$array = $this->objectModel->getReleaseBugs($buildID, $productID);
|
||||
$array = $this->objectModel->getReleaseBugs(array($buildID), $productID);
|
||||
|
||||
$title = '';
|
||||
foreach($array as $bug) $title .= ',' . $bug->title;
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php'; su('admin');
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/bug.class.php';
|
||||
|
||||
zdTable('bug')->gen(10);
|
||||
zdTable('product')->gen(10);
|
||||
|
||||
/**
|
||||
|
||||
title=bugModel->getReleaseBugs();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试获取buildID为11 productID为2的bug >> BUG4,BUG5,BUG6
|
||||
测试获取buildID为12 productID为2的bug >> 0
|
||||
测试获取buildID为13 productID为1的bug >> BUG1,BUG2,BUG3
|
||||
测试获取buildID为14 productID为2的bug >> BUG4,BUG5,BUG6
|
||||
测试获取buildID为15 productID为1的bug >> BUG1,BUG2,BUG3
|
||||
测试获取buildID为16 productID为2的bug >> BUG4,BUG5,BUG6
|
||||
|
||||
*/
|
||||
|
||||
$buildIDList = array('11', '12', '13', '14', '15', '16');
|
||||
$productIDList = array('1', '2');
|
||||
$buildIDList = array(11, 12, 13, 14, 15, 16);
|
||||
$productIDList = array(1, 2);
|
||||
|
||||
$bug=new bugTest();
|
||||
r($bug->getReleaseBugsTest($buildIDList[0], $productIDList[1])) && p('') && e('BUG4,BUG5,BUG6'); // 测试获取buildID为11 productID为2的bug
|
||||
@@ -27,4 +23,4 @@ r($bug->getReleaseBugsTest($buildIDList[1], $productIDList[1])) && p('') && e('0
|
||||
r($bug->getReleaseBugsTest($buildIDList[2], $productIDList[0])) && p('') && e('BUG1,BUG2,BUG3'); // 测试获取buildID为13 productID为1的bug
|
||||
r($bug->getReleaseBugsTest($buildIDList[3], $productIDList[1])) && p('') && e('BUG4,BUG5,BUG6'); // 测试获取buildID为14 productID为2的bug
|
||||
r($bug->getReleaseBugsTest($buildIDList[4], $productIDList[0])) && p('') && e('BUG1,BUG2,BUG3'); // 测试获取buildID为15 productID为1的bug
|
||||
r($bug->getReleaseBugsTest($buildIDList[5], $productIDList[1])) && p('') && e('BUG4,BUG5,BUG6'); // 测试获取buildID为16 productID为2的bug
|
||||
r($bug->getReleaseBugsTest($buildIDList[5], $productIDList[1])) && p('') && e('BUG4,BUG5,BUG6'); // 测试获取buildID为16 productID为2的bug
|
||||
|
||||
Reference in New Issue
Block a user