* Refactor bugModel-getUserBugPairs, and modify its unit test.
This commit is contained in:
@@ -873,9 +873,10 @@ class bugModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试获取用户的bugs的 id => title 数组。
|
||||
* Get bug pairs of a user.
|
||||
*
|
||||
* @param int $account
|
||||
* @param string $account
|
||||
* @param bool $appendProduct
|
||||
* @param int $limit
|
||||
* @param array $skipProductIdList
|
||||
@@ -884,9 +885,9 @@ class bugModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getUserBugPairs($account, $appendProduct = true, $limit = 0, $skipProductIdList = array(), $skipExecutionIdList = array(), $appendBugID = 0)
|
||||
public function getUserBugPairs(string $account, bool $appendProduct = true, int $limit = 0, array $skipProductIdList = array(), array $skipExecutionIdList = array(), array|int $appendBugID = 0): array
|
||||
{
|
||||
$deletedProjectIdList = $this->dao->select('*')->from(TABLE_PROJECT)->where('deleted')->eq(1)->fetchPairs('id', 'id');
|
||||
$deletedProjectIdList = $this->dao->select('id')->from(TABLE_PROJECT)->where('deleted')->eq(1)->fetchPairs();
|
||||
|
||||
$bugs = array();
|
||||
$stmt = $this->dao->select('t1.id, t1.title, t2.name as product')
|
||||
|
||||
@@ -589,15 +589,21 @@ class bugTest
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试获取取用户的bugs的 id => title 数组。
|
||||
* Test get bug pairs of a user.
|
||||
*
|
||||
* @param string $account
|
||||
* @param bool $appendProduct
|
||||
* @param int $limit
|
||||
* @param array $skipProductIdList
|
||||
* @param array $skipExecutionIdList
|
||||
* @param int|array $appendBugID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getUserBugPairsTest($account)
|
||||
public function getUserBugPairsTest(string $account, bool $appendProduct = true, int $limit = 0, array $skipProductIdList = array(), array $skipExecutionIdList = array(), array|int $appendBugID = 0): array|int
|
||||
{
|
||||
$array = $this->objectModel->getUserBugPairs($account);
|
||||
$array = $this->objectModel->getUserBugPairs($account, $appendProduct, $limit, $skipProductIdList, $skipExecutionIdList, $appendBugID);
|
||||
|
||||
if(dao::isError())
|
||||
{
|
||||
|
||||
@@ -1,27 +1,37 @@
|
||||
#!/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(100);
|
||||
zdTable('product')->gen(100);
|
||||
|
||||
/**
|
||||
|
||||
title=bugModel->getUserBugPairs();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试获取用户admin的bug >> 85
|
||||
测试获取用户test1的bug >> 65
|
||||
测试获取用户test2的bug >> 0
|
||||
测试获取用户dev1的bug >> 55
|
||||
测试获取用户po1的bug >> 0
|
||||
|
||||
*/
|
||||
|
||||
$accountIDList = array('admin', 'test1', 'test2', 'dev1', 'po1');
|
||||
|
||||
$appendProduct = array(true, false);
|
||||
$limit = array(0, 10);
|
||||
$skipProductIdList = array(array(), array(2, 4));
|
||||
$skipExecutionIdList = array(array(), array(11, 13));
|
||||
$appendBugID = array(array(), array(2, 4));
|
||||
|
||||
$bug=new bugTest();
|
||||
r($bug->getUserBugPairsTest($accountIDList[0])) && p() && e('85'); // 测试获取用户admin的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[1])) && p() && e('65'); // 测试获取用户test1的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[2])) && p() && e('0'); // 测试获取用户test2的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[3])) && p() && e('55'); // 测试获取用户dev1的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[4])) && p() && e('0'); // 测试获取用户po1的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[0], $appendProduct[0], $limit[0], $skipProductIdList[0], $skipExecutionIdList[0], $appendBugID[0])) && p() && e('30'); // 测试获取用户admin 的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[0], $appendProduct[1], $limit[0], $skipProductIdList[0], $skipExecutionIdList[0], $appendBugID[0])) && p() && e('30'); // 测试获取用户admin 追加产品名称 的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[0], $appendProduct[0], $limit[1], $skipProductIdList[0], $skipExecutionIdList[0], $appendBugID[0])) && p() && e('10'); // 测试获取用户admin 限制数量10 的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[0], $appendProduct[0], $limit[0], $skipProductIdList[1], $skipExecutionIdList[0], $appendBugID[0])) && p() && e('24'); // 测试获取用户admin 跳过产品2 4 的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[0], $appendProduct[0], $limit[0], $skipProductIdList[0], $skipExecutionIdList[1], $appendBugID[0])) && p() && e('30'); // 测试获取用户admin 跳过执行 11 13 的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[0], $appendProduct[0], $limit[0], $skipProductIdList[0], $skipExecutionIdList[0], $appendBugID[1])) && p() && e('30'); // 测试获取用户admin 追加bug 2 4 的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[0], $appendProduct[1], $limit[1], $skipProductIdList[1], $skipExecutionIdList[1], $appendBugID[1])) && p() && e('10'); // 测试获取用户admin 追加产品名称 限制数量10 跳过产品2 4 跳过执行 11 13 追加bug 2 4 的bug
|
||||
|
||||
r($bug->getUserBugPairsTest($accountIDList[1], $appendProduct[0], $limit[0], $skipProductIdList[0], $skipExecutionIdList[0], $appendBugID[0])) && p() && e('20'); // 测试获取用户test1的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[2], $appendProduct[0], $limit[0], $skipProductIdList[0], $skipExecutionIdList[0], $appendBugID[0])) && p() && e('0'); // 测试获取用户test2的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[3], $appendProduct[0], $limit[0], $skipProductIdList[0], $skipExecutionIdList[0], $appendBugID[0])) && p() && e('20'); // 测试获取用户dev1的bug
|
||||
r($bug->getUserBugPairsTest($accountIDList[4], $appendProduct[0], $limit[0], $skipProductIdList[0], $skipExecutionIdList[0], $appendBugID[0])) && p() && e('0'); // 测试获取用户po1的bug
|
||||
|
||||
Reference in New Issue
Block a user